yarn rw dev on my Dell XPS 15 9550 (16 GB ram) running Windows 10 is extremely slow. Other Windows users seems to be reporting similar problems on our Discord server.
So I added some timing logs to the dev cli command, and this is what I got
dev.js::handler() base time Sun, 19 Jul 2020 00:04:27 GMT
DB startup. Delta: 0.003 sec
Shutting down "api" side. Delta: 0.066 sec
Shutting down "web" side. Delta: 100.539 sec
Starting everything. Delta: 693.201 sec
dev.js::handler() base time Sun, 19 Jul 2020 00:26:20 GMT
DB startup. Delta: 0.002 sec
Shutting down "api" side. Delta: 0.068 sec
Shutting down "web" side. Delta: 146.419 sec
Starting everything. Delta: 392.674 sec
dev.js::handler() base time Sun, 19 Jul 2020 00:34:38 GMT
DB startup. Delta: 0.003 sec
Shutting down "api" side. Delta: 0.076 sec
Shutting down "web" side. Delta: 579.419 sec
Starting everything. Delta: 1253.326 sec
Clearly what's taking time is shutting down stuff. Actually starting the dev server only takes 3 - 4 seconds (timing not shown above). That last one in particular is horrible, with 21 minutes to just shutting everything down. I almost gave up several times, thinking it had crashed or frozen.
So the question then becomes, how do we make it shut down stuff faster, not how do we make it start faster.
This looks relevant https://github.com/tiaanduplessis/kill-port/issues/43 A fix was released just 4 days ago. I'll try to upgrade that package and see what happens :)
kill-port 1.6.0 was using netstat -ao
$ time netstat -ao
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 XPS9550:0 LISTENING 1176
TCP 0.0.0.0:445 XPS9550:0 LISTENING 4
TCP 0.0.0.0:5040 XPS9550:0 LISTENING 8640
[...]
real 4m12.881s
user 0m0.000s
sys 0m0.015s
kill-port 1.6.1 is using netstat -aon
$ time netstat -aon
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1176
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:5040 0.0.0.0:0 LISTENING 8640
[...]
real 0m0.899s
user 0m0.000s
sys 0m0.031s
From 4m13s to 1s!
WOOT! @Tobbe that's amazing work!
Could you bump the dependency and open a PR?
@Tobbe Whoa! That speed change.
From what I can tell, the -n flag will simply not resolve the names during lookup. For the purpose of killing a listening port, it makes sense to not resolve the underlying names. I know that netstat can be a bit slow, especially when resolving names, but I did not imagine it being that slow.
Great find!
Edit: I checked the kill-port package, and it does not take any resolved name into account so it's a good addtional option. :)
yarn rw dev with latest version of kill-port
dev.js::handler() base time Sun, 19 Jul 2020 10:51:15 GMT
DB startup. Delta: 0.003 sec
Shutting down "api" side. Delta: 0.08 sec
Shutting down "web" side. Delta: 0.224 sec
Starting everything. Delta: 0.345 sec
1253.326 sec (previous worst-case) to 0.345 sec 😁
Most helpful comment
kill-port 1.6.0 was using
netstat -aokill-port 1.6.1 is using
netstat -aonFrom 4m13s to 1s!