-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
GC bug: seems very slow where it shouldn't; maybe it leaks? #10040
Comments
|
The GC scans the stack for references conservatively and each call to |
but the stack is not that huge is it? |
Yeah, that indeed doesn't seem like it should cause such a performance issue. It looks like it's not the stack size that's the problem. I modified the test case a bit and the GC scan count stat looks really suspicious. proc foo =
for i in 0..100*100:
let a = "foo"
proc main =
const StringCount = 495
var strings: array[StringCount, string]
for i, p in mpairs strings: p = newString(1)
for i in 1..17:
echo i
for j in 1..12:
foo()
echo GC_getStatistics()
main() As the StringCount gets larger the amount of stack scans grows exponentially. Going from 494 to 495 increases it by 100k from 400k, from 495 to 496 by 170k! At 500 the scan count is >2m. |
Seems to be a simple logic bug: ZctThreshold is set to 500, so if the "zero count table" reaches 500 the GC runs. Now it happens to be the case that there is no "success rate" computed so every single collection triggers a GC run. |
see comment here: ef37e16#commitcomment-31738180 |
/cc @Araq
[painfully reduced from testament/tester]
there's a very strange bug that could be caused by memory leaks or other GC issue:
nim c -r -d:case_bug $timn_D/bugs/all/t0077.nim
will print foo:1 through foo:16 and then increasingly slow down, eventually completing in ~ 50 secondsnim c -r $timn_D/bugs/all/t0077.nim
will complete in < 1 secondMaybe, depending on your machine, you can add more
discard makeTest()
lines if you can't reproduce this bug on your machine.The program
The text was updated successfully, but these errors were encountered: