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.
| Case | Before the cache | With the cache |
|---|---|---|
| Render, 10 posts | 49 µs | 7.5 µs |
| Render, 100 posts | 84 µs | 41 µs |
| Render, 1,000 posts | 444 µs | 388 µs |
Parse posts.index and layouts.app | 23–28 µs | avoided 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.
Propel