-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sclang consumes high CPU when opening a session with multiple files #980
Comments
On Mac OS 10.8, using the latest master, I can't reproduce this behaviour. when testing, I used I noticed that when I run this bit of unrelated code: |
How long are your code files? The problem does not manifest with short files. Did some benchmarking -- the culprit is Usually this is very quick, but it seems quite time consuming for long files (here, I'm omitting the short files that took less than 0.1 sec):
The worst of them, 04-defs.scd, contains 59314 characters. So let's assume syncFromIDE receives an Int8Array.
Ouch.
Ouch. That's as far as I can go with it this morning... |
While I was out for lunch, I started to suspect that maybe String.fill uses concatenation. Indeed...
That makes sense, if we aren't assuming that every item will be a Char. If I rewrite syncFromIDE as follows:
... then 2.1364738941193 seconds to process 04-defs.scd in my earlier test turns into 0.012862205505371, some 166 times faster. I suppose it would be useful to add a *fillChars method to String? So that people would be less tempted to use the general-case but massively slower String.fill? |
Oh..... wslib overwrites String *fill with the slower version. So that's why nobody else could reproduce it. (Insert boilerplate lecture about overwriting core methods...) So I guess the best fix is the above, since quarks will not be able to interfere with it then (unless some...one decides that syncFromIDE would be a good candidate for "improvement"...). |
I think the best solution would be to have Wouter (or somebody else) switch that to a new method in wslib. Closing for now. |
ok, fixed in wslib. String:fill is now renamed to String:fillJoin (and String:collect to String:collectJoin) |
Thanks!
|
Consistently reproducible behavior here: Whenever I switch to a session in the IDE that contains, say, 9-10 files, sclang pushes one of the cores to 100% for several seconds. I've watched processes in top -- it's definitely sclang, not scide.
The attached screenshot was taken a few seconds after I reproduced the problem. I switched the session at what looks like about 12 seconds in the graph (reading from the right). CPU 2 (red line) spikes up for about 4 seconds after that.
The session's files add up to 159154 characters, computed as follows:
There must be some GC or other internal issue (memory management, perhaps?)... but I have no idea how to reproduce it using only sclang code. This doesn't do it:
The text was updated successfully, but these errors were encountered: