-
Notifications
You must be signed in to change notification settings - Fork 56
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
Show task performance #445
Conversation
Looks like my "meshgen" was just more lighting under the hood. Updated to reflect that. |
It crashes with division by zero error when I try it:
|
Is my divFloor different from yours? |
I don't know. Maybe you didn't test it in debug mode? |
Building in debug mode takes extra steps because zig ld crashes. |
Does it crash in release mode? |
Could you send me the issue link? Then we can add it to #308 |
It also crashes in release, looking at gdb it seems to be the same issue: Thread 1 "Cubyzig" received signal SIGFPE, Arithmetic exception.
0x000000000110878c in windows.debug.render () at /home/mint/Downloads/Cubyz/src/gui/windows/debug.zig:52
52 draw.print(" " ++ name ++ " time: {} ms ({} µs/task)", .{@divFloor(perf.utime[i], 1000), @divFloor(perf.utime[i], perf.tasks[i])}, 0, y, 8, .left); |
Resolved both complaints. |
It's really hard to read anything here. The numbers seem to get reset every frame: video-2024-06-06_08.17.52.mp4 |
In my defense, it is quite legible at 10 fps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of ideas how to improve it. Also zig reported a memory leak:
memory address 0x7fa9aed53040 leaked:
/home/mint/Downloads/Cubyz/src/utils.zig:627:31: 0x13250c2 in create__anon_13927 (Cubyzig)
return self.allocator.create(T) catch unreachable;
^
/home/mint/Downloads/Cubyz/src/utils.zig:1040:35: 0x13152e5 in init (Cubyzig)
.performance = allocator.create(Performance),
^
/home/mint/Downloads/Cubyz/src/main.zig:356:36: 0x1313028 in main (Cubyzig)
threadPool = utils.ThreadPool.init(globalAllocator, @max(1, (std.Thread.getCpuCount() catch 4) -| 1));
^
/home/mint/Cubyz/compiler/zig/lib/std/start.zig:501:22: 0x1312b49 in main (Cubyzig)
root.main();
^
This PR has been stale for 4 months now. Do you still intend to finish this? |
Didn't realize it was this old already. Sure, I'll finish it up. |
There are actually some controversial changes here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not very experienced with atomics, and I don't think my readAndReset is particularly sound. Maybe I should read the whole struct atomically by packing it with @vectors? Maybe I should have an array of {count, utime} tuples instead?
Yeah, your atomics are definitely incorrect here.
Sadly bigger atomics don't seem to work very well, see ziglang/zig#14235 (although it might be worth checking if this still happens)
The solution in this case would probably just be to use a Mutex instead of atomics.
Or I guess just don't reset the values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run this I get a memory leak:
memory address 0x756fcc252040 leaked:
/home/mint/Downloads/archbirdplus/src/utils.zig:627:31: 0x13ab6a2 in create__anon_15345 (Cubyzig)
return self.allocator.create(T) catch unreachable;
^
/home/mint/Downloads/archbirdplus/src/utils.zig:1058:33: 0x13499d6 in init (Cubyzig)
const self = allocator.create(Performance);
^
/home/mint/Downloads/archbirdplus/src/utils.zig:1083:35: 0x1332672 in init (Cubyzig)
.performance = Performance.init(allocator),
^
/home/mint/Downloads/archbirdplus/src/main.zig:519:36: 0x132c8e2 in main (Cubyzig)
threadPool = utils.ThreadPool.init(globalAllocator, settings.cpuThreads orelse @max(1, (std.Thread.getCpuCount() catch 4) -| 1));
^
/home/mint/Cubyz/compiler/zig/lib/std/start.zig:608:22: 0x132bfa9 in main (Cubyzig)
root.main();
^
Memory leak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good now, thanks for finishing this.
I think this will be quite useful for quick profiling and detecting some of the random performance regressions on zig updates.
Notes:
.misc
if the task doesn't take a significant amount of time