-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
performanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version
Description
I noticed while testing #30471 that printing deeply nested Pair types seems absurdly slow. In Julia 1.0, I get:
julia> p = mapfoldl(abs, =>, -27:-1); @time println(p)
(((((((((((((((((((((((((27=>26)=>25)=>24)=>23)=>22)=>21)=>20)=>19)=>18)=>17)=>16)=>15)=>14)=>13)=>12)=>11)=>10)=>9)=>8)=>7)=>6)=>5)=>4)=>3)=>2) => 1
48.127456 seconds (1.36 M allocations: 67.004 MiB, 0.04% gc time)Almost a minute and over a million allocations to print a 150-character string doesn't seem right.
In contrast, mapfoldl(abs, Pair{Any,Any}, -50:-1) prints instantly, and similarly for calling println(p) a second time above, so the problem must have to do with compiling lots of code specialized for the different nested Pair types above.
It might be fixed by adding @nospecialize to the show function for Pair, but I wonder if there is a deeper problem & solution for nested parameterized types.
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version