lpgauth

lpgauth

Torque is a high-performance JSON library for Elixir built on sonic-rs via Rustler NIFs. It targets workloads where JSON throughput is a bottleneck — think bidstream processing, high-volume API ingestion, or any hot path that spends meaningful time in encode/decode.

Why Torque?

Raw throughput on a 1.2 KB OpenRTB payload (Apple M2 Pro, OTP 28, Elixir 1.19):

Decode

Library ips mean median p95 p99 memory
torque 255.8K 3.91 µs 3.58 µs 4.54 µs 9.21 µs 1.56 KB
simdjsone 185.9K 5.38 µs 5.00 µs 6.38 µs 12.67 µs 1.59 KB
jiffy 152.4K 6.56 µs 5.83 µs 8.58 µs 15.75 µs 1.56 KB
otp json 130.9K 7.64 µs 7.17 µs 9.33 µs 16.50 µs 7.73 KB
jason 109.1K 9.17 µs 8.54 µs 11.04 µs 18.13 µs 9.54 KB

Encode

Library ips mean median p95 p99 memory
torque encode (proplist) 869.6K 1.15 µs 1.04 µs 1.29 µs 1.42 µs 88 B
torque iodata (proplist) 854.7K 1.17 µs 1.08 µs 1.33 µs 1.46 µs 64 B
torque iodata (map) 775.2K 1.29 µs 1.17 µs 1.46 µs 1.63 µs 64 B
torque encode (map) 800.0K 1.25 µs 1.17 µs 1.25 µs 1.50 µs 88 B
otp json (iodata) 735.3K 1.36 µs 0.83 µs 1.25 µs 13.54 µs 3928 B
jiffy 537.6K 1.86 µs 1.63 µs 2.00 µs 2.29 µs 120 B
otp json (binary) 448.4K 2.23 µs 1.58 µs 2.63 µs 15.00 µs 3992 B
jason 284.9K 3.51 µs 2.42 µs 14.63 µs 16.63 µs 3912 B

Features

  • SIMD-accelerated decoding (AVX2/SSE2 on x86_64, NEON on ARM)

  • Ultra-low memory encoder — 64 B per encode vs ~4 KB for OTP json / Jason

  • parse/1 + get/2 / get_many/2 for selective field extraction (JSON Pointer / RFC 6901)

  • Batch field extraction via a single NIF call

  • Automatic dirty CPU scheduler dispatch for large inputs

  • jiffy-compatible {proplist} encoding for easy migration

Installation

elixir

def deps do
  [{:torque, "~> 0.1.1"}]
end

Precompiled binaries are available for common targets. To build from source, install a stable Rust toolchain and set TORQUE_BUILD=true.

Hex: https://hex.pm/packages/torque

https://github.com/lpgauth/torque

Showing Posts 1 to 5

Asd

Asd

Given that your library uses SIMD instructions, precompiled binaries is a bad option, since precompilation works only for OS+CPU arch combination and it doesnt account for target CPU to have the proper flags which would indicate that it supports SIMD instructions

manhvu

manhvu

Nice! I used jsonrs before, but I switched back to the OTP JSON library. I wish I had seen this earlier. Now I’m taking a different approach by replacing JSON with TOON.

lpgauth

lpgauth OP

Yes, you’re right. The default binaries assume the host CPU will support SSE2 or NEON. For better performance (AVX2 or AVX512) or if your CPU doesn’t support the base SSE2/NEON you can build from source by passing TORQUE_BUILD=true.

lpgauth

lpgauth OP

I didn’t know about jsonrs. I will add it to the benchmark suite!

lpgauth

lpgauth OP

Hi, quick follow-up. I ended up adding specific binaries per CPU variants on x86_64.

https://github.com/lpgauth/torque?tab=readme-ov-file#cpu-optimized-variants

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews