Add Zig solution for binarytrees that makes use of MemoryPool #381
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About
Nodestruct: it doesn't really make sense to repeat this value 10000s of times in memory.Comparing performance
built with
zig build-exe -O ReleaseFast --library c 1.zig.Difference in time from
1.42sdown to0.44s, memory use down from50.520kbto23.792kbOriginal 1.zig output:
/usr/bin/time -v ./1 18 stretch tree of depth 19 check: 1048575 262144 trees of depth 4 check: 8126464 65536 trees of depth 6 check: 8323072 16384 trees of depth 8 check: 8372224 4096 trees of depth 10 check: 8384512 1024 trees of depth 12 check: 8387584 256 trees of depth 14 check: 8388352 64 trees of depth 16 check: 8388544 16 trees of depth 18 check: 8388592 long lived tree of depth 18 check: 524287 Command being timed: "./1 18" User time (seconds): 1.42 System time (seconds): 0.01 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.43 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 50520 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 2 Minor (reclaiming a frame) page faults: 12357 Voluntary context switches: 45 Involuntary context switches: 4 Swaps: 0 File system inputs: 280 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0Updated 2.zig output:
/usr/bin/time -v ./2 18 stretch tree of depth 19 check: 1048575 262144 trees of depth 4 check: 8126464 65536 trees of depth 6 check: 8323072 16384 trees of depth 8 check: 8372224 4096 trees of depth 10 check: 8384512 1024 trees of depth 12 check: 8387584 256 trees of depth 14 check: 8388352 64 trees of depth 16 check: 8388544 16 trees of depth 18 check: 8388592 long lived tree of depth 18 check: 524287 Command being timed: "./2 18" User time (seconds): 0.44 System time (seconds): 0.00 Percent of CPU this job got: 98% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.46 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 23792 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 2 Minor (reclaiming a frame) page faults: 7475 Voluntary context switches: 45 Involuntary context switches: 0 Swaps: 0 File system inputs: 280 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0