-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Still another array access performance issue (in debug) #15685
Labels
bug
Observed behavior contradicts documented or intended behavior
optimization
regression
It worked in a previous version of Zig, but stopped working.
Milestone
Comments
IntegratedQuantum
added
the
bug
Observed behavior contradicts documented or intended behavior
label
May 13, 2023
I just updated my zig version and the problem got a lot worse. EDIT: I updated again and it is now back to how it was originally. ExpandThis simplified example was not affected in the past: const std = @import("std");
const len = 32*32*32;
var blocks: [len]u16 = undefined;
pub noinline fn regenerateMainMesh() u32 {
var sum: u32 = 0;
var i: u16 = 0;
while(i < len) : (i += 1) {
sum += blocks[i]; // ← workaround: (&blocks)[...]
}
return sum;
}
pub fn main() void {
for(&blocks, 0..) |*block, i| {
block.* = @intCast(u16, i);
}
const start = std.time.nanoTimestamp();
const sum = regenerateMainMesh();
const end = std.time.nanoTimestamp();
std.log.err("Time: {} Sum: {}", .{end - start, sum});
} But now it is also slow:
|
andrewrk
added
optimization
regression
It worked in a previous version of Zig, but stopped working.
labels
Oct 24, 2023
Fix landed in 2ab7893. |
Fix reverted in 9d5a133. |
silver-signal
pushed a commit
to silver-signal/zig
that referenced
this issue
Jan 25, 2024
…ers" This reverts commit 2ab7893. Premature merge - apologies for the disruption. Reopens ziglang#15685 Reopens ziglang#17580
bilaliscarioth
pushed a commit
to bilaliscarioth/zig
that referenced
this issue
Jan 27, 2024
…ers" This reverts commit 2ab7893. Premature merge - apologies for the disruption. Reopens ziglang#15685 Reopens ziglang#17580
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Observed behavior contradicts documented or intended behavior
optimization
regression
It worked in a previous version of Zig, but stopped working.
Zig Version
0.11.0-dev.3105+e46d7a369
Steps to Reproduce and Observed Behavior
This is a follow-up to #13938 which was only fixed in release mode(which means I still have to rely on the workaround to be able to run my code in debug mode). The reproduction code is basically identical:
Running this in debug mode is taking 93 ms for iterating over a 32768 element array:
Running this in a profiler, I can see that the bottleneck still is a
memcpy
that is called once every iteration and appears to be copying the entire array:Expected Behavior
When applying the workaround
the performance is significantly better, taking only 0.4 ms instead of 93 ms:
The text was updated successfully, but these errors were encountered: