nimlsp icon indicating copy to clipboard operation
nimlsp copied to clipboard

sleep 16ms when using synchronous io on windows for reducing cpu usage

Open bung87 opened this issue 2 years ago • 5 comments

bung87 avatar Jan 06 '24 04:01 bung87

Why would we need to sleep with synchronous IO? It should just block on the read of stdin. And why 16ms?

PMunch avatar Jan 11 '24 12:01 PMunch

it's 1000ms / 60fps, the infinite loop cause cpu high, but it doesn't has to be. as the server is for text editor not game nor real time application, I think it's fine.

bung87 avatar Jan 11 '24 12:01 bung87

Ah right, I guess 16ms makes sense. But it still doesn't make sense that it busy loops in an infinite loop. Since its using synchronous IO it should be blocking on trying to read input from standard input. If you're seeing high CPU usage with nimlsp it's much more likely a nimsuggest issue.

PMunch avatar Jan 11 '24 13:01 PMunch

yeah, the result is it get lower cpu usage on some projects, some still very high.

bung87 avatar Jan 12 '24 03:01 bung87

Again, it doesn't make any sense that sleeping before a synchronous read should affect CPU performance short of just limiting the amount of actual work it's able to do.

PMunch avatar Jan 12 '24 09:01 PMunch