I have a Discord bot that allows me to run snippets of DM code and get the results back easily. Recently I noticed that it became incredibly slow, taking 20+ seconds to run, whereas usually it was almost instant.
The bot works by grabbing the code, wrapping it in some other code so it instantly runs then exits. The code that gets produced looks like this:
var/a/b=new
/a/New()
world.log << "derp"
var/c/d=new
/c/New()
shutdown()
So DD just runs it immediately, exits (20 seconds later apparently) and my bot reads the output back to Discord.
Running the code snippets with DD manually and the code instantly executes, then DD proceeds to hang doing nothing, not even consuming any CPU, for 20+ seconds.
While attempting to figure out id:2293882 I ran DD with strace and I noticed it was throwing a TON of SIGALRMs while it's doing nothing, so that's probably related.
$ strace -feprocess byond/bin/DreamDaemon code.dmb
execve("byond/bin/DreamDaemon", ["byond/bin/DreamDaemon", "code.dmb"], [/* 28 vars */]) = 0
strace: [ Process PID=32215 runs in 32 bit mode. ]
Thu Sep 14 23:06:35 2017
Auto-safety mode: ultrasafe (no file access)
World opened on network port 35594.
Welcome BYOND! (5.0 Public Version 511.1385)
derp
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_USER, si_pid=32215, si_uid=1001} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
exit_group(0) = ?
+++ exited with 0 +++
I'm not sure why the shutdown is being delayed. It's possible that maybe the world is trying to determine hub reachability and is waiting for the hub to call it back.