Propel rocketboost.rs

Template cache

The dev renderer keeps each parsed template in memory. A template is parsed once, and it is parsed again only when its file changes. This site compiles its views instead, so it does not read templates at run time, and the cache does not apply to it. The numbers below are for apps that render with the dev renderer.

Try it

The value below comes from the handler in src/main.rs. Change it there, and bacon rebuilds the app.

Value from the handler: v1

Benchmark

The numbers below come from the benchmark in propel_runtime/benches/render.rs, run in a release build on an Apple Silicon Mac. They render posts.index with a layout, so they include reading the templates from disk.

CaseBefore the cacheWith the cache
Render, 10 posts49 µs7.5 µs
Render, 100 posts84 µs41 µs
Render, 1,000 posts444 µs388 µs
Parse posts.index and layouts.app23–28 µsavoided on each request

The cache removes the parsing, which is about a quarter of a 100-post request. With 1,000 posts the rest of the time goes to building the HTML, so the cache helps less.

Run the benchmark

cargo bench -p propel_runtime

Run it from the Propel repository. The results are saved in target/criterion.