Get the latest tech news

Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)


An exciting feature just landed in the main branch of the Clangcompiler. Using the [[clang::musttail]] or__attribute__((musttail)) statement attributes, you ...

Theoretically, this control flow graph paired with a profile should give the compiler all of the information it needs to generate the most optimal code. The only opportunity for improvement I see here, aside from the jne fallback issue mentioned before, is that for some reason the compiler doesn’t want to generate jmp qword ptr [rsi + 8*rax]. We have not yet implemented this fallback in upb, but I expect it will involve a macro that either tail calls to dispatch or just returns, based on the availability of musttail.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Protobuf

Protobuf

Photo of tail calls

tail calls

Photo of 2+GB

2+GB

Related news:

News photo

Fivefold Slower Compared to Go? Optimizing Rust's Protobuf Decoding Performance

News photo

New Android MMRat malware uses Protobuf protocol to steal your data