You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the following zig program to observe performance of the compiler when the program contains code that formats an enum that contains many values with long names.
I'd expect zig to be able to compile the program above faster. In the worst case (a non-exhaustive enum with 4000 values) it takes 94 seconds to compile. Also notes that 3000 values takes 43 seconds so the performance growth is super-linear. Here is the output from running on an M1 macbook air:
starting zig...
zig took 4 second(s) (1 values, exhaustive_enum=true)
starting zig...
zig took 4 second(s) (1 values, exhaustive_enum=false)
starting zig...
zig took 8 second(s) (2000 values, exhaustive_enum=true)
starting zig...
zig took 16 second(s) (2000 values, exhaustive_enum=false)
starting zig...
zig took 7 second(s) (3000 values, exhaustive_enum=true)
starting zig...
zig took 43 second(s) (3000 values, exhaustive_enum=false)
starting zig...
zig took 7 second(s) (4000 values, exhaustive_enum=true)
starting zig...
zig took 94 second(s) (4000 values, exhaustive_enum=false)
Note that this issue was discovered when I was printing an win32 error code which comes from an enum with almost 4000 values. I normally call a fmt function that uses a code-generated switch to avoid having to use the inline for statement that std.fmt uses (see https://github.com/marlersoft/zigwin32/blob/32d085ee67374ad2ec24fc012e6876ca27958fb7/win32/foundation.zig#L9737), however in one place I accidently printed the enum value instead of calling the function that uses the switch and I thought the compiler was hanging, but turns it it was just taking multiple minutes to compile with that one line change.
The text was updated successfully, but these errors were encountered:
Thanks @Rexicon226, I've corrected the example and output. This time I tested it on my windows machine with an i9-10900K (base speed is 3.7 GHz turbos up to 5.3 GHz) desktop which is almost twice as bad as my little M1 macbook air:
starting zig...
zig took 6 second(s) (1 values, exhaustive_enum=true)
starting zig...
zig took 6 second(s) (1 values, exhaustive_enum=false)
starting zig...
zig took 13 second(s) (2000 values, exhaustive_enum=true)
starting zig...
zig took 25 second(s) (2000 values, exhaustive_enum=false)
starting zig...
zig took 10 second(s) (3000 values, exhaustive_enum=true)
starting zig...
zig took 71 second(s) (3000 values, exhaustive_enum=false)
starting zig...
zig took 11 second(s) (4000 values, exhaustive_enum=true)
starting zig...
zig took 162 second(s) (4000 values, exhaustive_enum=false)
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Run the following zig program to observe performance of the compiler when the program contains code that formats an enum that contains many values with long names.
Expected Behavior
I'd expect zig to be able to compile the program above faster. In the worst case (a non-exhaustive enum with 4000 values) it takes 94 seconds to compile. Also notes that 3000 values takes 43 seconds so the performance growth is super-linear. Here is the output from running on an M1 macbook air:
Note that this issue was discovered when I was printing an win32 error code which comes from an enum with almost 4000 values. I normally call a
fmt
function that uses a code-generated switch to avoid having to use theinline for
statement thatstd.fmt
uses (see https://github.com/marlersoft/zigwin32/blob/32d085ee67374ad2ec24fc012e6876ca27958fb7/win32/foundation.zig#L9737), however in one place I accidently printed the enum value instead of calling the function that uses the switch and I thought the compiler was hanging, but turns it it was just taking multiple minutes to compile with that one line change.The text was updated successfully, but these errors were encountered: