Re:“Clean” Code, Horrible Performance
by celrod on Tuesday February 28, 2023 @10:06PM
(#34978282)
There was a fun example in the Julia compiler around a year ago.
Part of the compiler was O(N^2) in `let` block nesting depth. That is
let x = foo(), y = y, z = 2y
...
end
would be a depth of 3. It didn't seem like that should be a problem, N is never going to be 10, let alone 100, right?
Until suddenly, `N` was in the thousands in some critical generated code spit out by some modeling software, so that handling the scoping introduced by `let` suddenly dominated the compilation time...
Part of the compiler was O(N^2) in `let` block nesting depth. That is
would be a depth of 3. It didn't seem like that should be a problem, N is never going to be 10, let alone 100, right?Until suddenly, `N` was in the thousands in some critical generated code spit out by some modeling software, so that handling the scoping introduced by `let` suddenly dominated the compilation time...