Programming-Language-Benchmarks icon indicating copy to clipboard operation
Programming-Language-Benchmarks copied to clipboard

Zig binary tree search with optimizations

Open zigster64 opened this issue 3 years ago • 4 comments

This patch fixes the binarytree results for zig

It also tweaks the binarytree search by using multiple threads to process the trees in parallel

Compared to Go :

  • single threaded Zig is about 3x faster than go
  • multi threaded Zig is about 9x faster than go

zigster64 avatar Jul 12 '22 06:07 zigster64

Thanks for your contribution! However, neither arena nor parallelization is accepted for this problem

hanabi1224 avatar Jul 13 '22 05:07 hanabi1224

Thanks for your contribution! However, neither arena nor parallelization is accepted for this problem

No probs - I should read the contributor guidelines :)

With the arena allocator - I think some runtimes (such as the memory allocation in the Go runtime, or JVM, or Erlang) ... use an arena strategy instead of raw OS allocations. They allocate from the OS once up front, and then manage application level allocations themselves. May bias the results towards languages that have fat runtimes. (maybe)

zigster64 avatar Jul 13 '22 22:07 zigster64

I think some runtimes (such as the memory allocation in the Go runtime, or JVM, or Erlang) ... use an arena strategy instead of raw OS allocations.

I believe this is true for JVM, but not Go. And the downside of this strategy has been reflected in JVM's huge memory usage

hanabi1224 avatar Jul 14 '22 01:07 hanabi1224

From what I understand GO approach ("mark and sweep") is also somewhat similar to "Arena-like" as in they allocate in large chunks and deallocate in chunks. I believe majority of runtimes that employ GC do that for more efficient memory management. It's a little bit hard to understand why not to allow it as ability to fine-tune memory management per problem is really one of the main reasons why anyone would chose low level languages such as C/C++ etc and when working with large collections of objects this sort of memory optimization techniques are very common. For instance in Programming Language Benchmark Game c++ solution employs "arena" strategy with monotonic_buffer_resource

I've added solution that borrows some ideas from here, and from C++ implementation in bechmarksgame: https://github.com/hanabi1224/Programming-Language-Benchmarks/pull/381. Let me know what you think. 🙏

skyjur avatar Mar 28 '23 22:03 skyjur