maciejhirsz / ramhorns

Fast Mustache template engine implementation in pure Rust.
https://crates.io/crates/ramhorns
Mozilla Public License 2.0
293 stars 29 forks source link

Parsing perf #31

Closed maciejhirsz closed 4 years ago

maciejhirsz commented 4 years ago

So I've decided to add a benchmark for parsing performance, it was running at roughly 300mb/s. So then I've naturally decided to see how far I can push it, some preallocations and a whole lot of unsafe blocks later I got to 500mb/s.

Then I decided to just give Logos a go, after all why am I working on it, right? It took some work to figure out what the most efficient way of using it here would be, but I think I landed at something pretty neat.

The parse method is now a single loop without any recursion, it uses a single ArrayVec<[usize; 16]> to keep track of nested sections. So now it's at 820mb/s, and will benefit from all performance improvements I introduce upstream in Logos :nerd_face:.