g-andrade

g-andrade

Xb5_elixir - B-tree ordered maps / sets / multisets

Hi all,

I’m pleased to announce xb5_elixir, a wrapper of xb5, providing B-tree (order 5) alternatives to OTP’s gb_trees and gb_sets, as well as a multiset with order-statistic operations.

If you need ordered collections, xb5 benchmarks show 1.2–2.5× faster execution compared to the OTP modules for most operations, and equal or lower heap usage.

The three Elixir modules are:

  • Xb5.Bag - ordered multiset with order-statistic O(log n) operations (rank, access by index, percentile)

  • Xb5.Set - ordered set, alternative to gb_sets

  • Xb5.Tree - ordered key-value store, alternative to gb_trees

Performance

The underlying Erlang modules were benchmarked together with gb_sets and gb_trees on two separate computers. All tests ran across three build types, and collection sizes from 0 through 15,000.

Two interactive performance reports are published:

Benchmarking code and raw data are available in the xb5_benchmark repo.


https://github.com/g-andrade/xb5_elixir

Most Liked

g-andrade

g-andrade

Thank you @Asd! Map is generally faster at mutations and lookups - potentially much faster as collection size grows. Trees are useful when it’s a requirement to have the data sorted at all times with scalable performance.

Regarding benchmarks, I did use Benchee for a long time but struggled to get stable performance curves covering a wide range of collection sizes (0 to 15k) for the same test (the graphs on the report), or getting consistent results across runs without very long warm up times (and even then).

I solved this with a custom benchmarking framework that maximizes CPU cache pressure while keeping testing conditions overall uniform for all the cases, and that runs repeatedly until some semblance of stability has been achieved instead of running for a fixed amount of time. To be honest, a lot of the work in this project went into benchmarking alone.

Asd

Asd

Wow, very good library. I did some benchmarks against maps and found that xb5 is slower than maps for put, but slightly faster for get and many times faster for conversion to ordered list

However, I find separate repo for benchmarks a little overengineered, given that I was able to reproduce your results with Benchee in like 10 minutes or so.

Asd

Asd

I think that you should add GitHub - discord/sorted_set_nif: Elixir SortedSet backed by a Rust-based NIF · GitHub to your benchmarks. I assume that NIF will be just a little bit faster, which is a huge win for you

Again, congratulations on the initial release. Very solid work. I am definitely going to use it in my projects!

Where Next?

Popular in Announcing Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
ityonemo
Currently just starting out on a new mini-project - getting zig NIFs to run in elixir. https://github.com/ityonemo/zigler The idea here...
New
dominicletz
Hi, I thought I had posted my library before but seems I hadn’t. The project is still in early stages but it’s growing and so I think it...
New
brainlid
LangChain is short for Language Chain. An LLM, or Large Language Model, is the “Language” part. This library makes it easier for Elixir a...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamPipe ...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement