Skip to content
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

BREAKING: Bye bye, batches #63

Merged
merged 2 commits into from
Feb 27, 2025
Merged

BREAKING: Bye bye, batches #63

merged 2 commits into from
Feb 27, 2025

Conversation

rbino
Copy link
Owner

@rbino rbino commented Feb 27, 2025

Remove the input batch concept (i.e. a NIF resource that preallocated a binary with a fixed size to accomodate a certain number of Events) and replace it with a more idiomatic API.

I'll probably write a blogpost on this, but in short:

  • I was lured into this trying to replicate the Java client mechanism described in "Writing High-Performance Clients for Tigerbeetle"
  • ...but the API is excessively clunky when used in a language with immutable data
  • ...and it doesn't actually make things faster in the Elixir case
  • ...and it adds lots of code both on the Elixir and the Zig side

So, just use an idiomatic API for Elixir, passing lists of structs as input.
I've run the benchmark before and after and the throughput is fundamentally the same (when measuring the same thing, the old benchmark actually "cheated" a little).

Since we can access the completion context, we actually _have_ an env we can use
to copy the request ref, so we can avoid having to serialize it to binary.
While we're at it, clean up the submit function a little.
@rbino rbino changed the title Bye bye, batches BREAKING: Bye bye, batches Feb 27, 2025
@rbino rbino marked this pull request as ready for review February 27, 2025 18:07
@rbino rbino force-pushed the feat/bye-bye-batches branch from f22538f to 1750996 Compare February 27, 2025 18:08
Remove the input batch concept (i.e. a NIF resource that preallocated a binary
with a fixed size to accomodate a certain number of Events) and replace it with
a more idiomatic API.

I'll probably write a blogpost on this, but in short:
- I was lured into this trying to replicate the Java client mechanism described
in "Writing High-Performance Clients for Tigerbeetle"
- ...but the API is excessively clunky when used in a language with immutable
data
- ...and it doesn't actually make things faster in the Elixir case
- ...and it adds lots of code both on the Elixir and the Zig side

So, just use an idiomatic API for Elixir, passing lists of structs as input.
I've run the benchmark before and after and the throughput is fundamentally the
same (when measuring the same thing, the old benchmark actually "cheated" a
little).
@rbino rbino force-pushed the feat/bye-bye-batches branch from 1750996 to 13dbabb Compare February 27, 2025 18:13
@rbino rbino merged commit e98420e into main Feb 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant