-
-
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
for ai in a
has quadratic complexity in VM when a
is const
#16790
Comments
If it is |
that's a separate and broader issue; this issue concerns only |
Same issue https://forum.nim-lang.org/t/8003, the quadratic code here: Lines 475 to 479 in df429fa
|
Maybe start marking those places with something like |
So ... Instead of fixing the bug, we will tell you exactly the source location where it hides? Maybe ideas are better when they have a connection to reality, I dunno. |
I agree, I am talking when it means a break on the public API of the module. |
…stant seqs; don't inline them in the VM; big performance boost (nim-lang#21318) * don't inline arrays in VM * add a test for nim-lang#19075
…stant seqs; don't inline them in the VM; big performance boost (nim-lang#21318) * don't inline arrays in VM * add a test for nim-lang#19075
…stant seqs; don't inline them in the VM; big performance boost (nim-lang#21318) * don't inline arrays in VM * add a test for nim-lang#19075
this is the root cause for #16703
compilation 5x slower (33s => 171s for nim_temp c testament)
, which had occurred when themimetypes.mimes
constant (1800 elements) was used in a (single) for loop in VM.Example
Current Output
n = 4000: 5s
n = 8000: 18s
n = 16000: 70s
Expected Output
linear instead of quadratic complexity
workaround
transform the const used in VM into a var/let either via
let arr = arr
or usingidentity(arr)
instead ofarr
Additional Information
1.5.1 2b5841c
adding medium priority because this bug is easy to go un-noticed and can drastically affect compile times; in other words fixing this can significantly improve compile times in case your code uses a const in VM with
for ai in a
what probably happens is that the const value is copy/pasted in each iteration, which exactly would explain the quadratic complexity
The text was updated successfully, but these errors were encountered: