Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
1BRC merykitty’s magic SWAR: 8 lines of code explained in 3k words (questdb.io)
1 point by mfiguiere on March 7, 2024 | hide | past | favorite | 1 comment


This post explains a piece of code that appeared on the recent One Billion Row Challenge, it parses a variable-layout string whose bytes are packed into a single 64-bit variable, and doesn't use any if statements to achieve it. The string represents a decimal number from the range [-99.9, 99.9].

The general class of techniques used is called SWAR -- SIMD Within A Register, because it uses the regular ALU instruction set to achieve the effect of SIMD (Single Instruction, Multiple Data).

The code in question was submitted by Quan Anh Mai (@merykitty on GitHub).




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: