lpgauth

lpgauth

Torque - SIMD-accelerated JSON encoding and decoding

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

Most Liked

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

lpgauth

lpgauth

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

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 10167 134
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement