Skip to content

Conversation

@sunng87
Copy link
Owner

@sunng87 sunng87 commented Jan 6, 2026

This patch uses smol_str library to hold template and path strings. Thanks to the inline and stack based string, we gain some performance improvements with this:

     Running benches/bench.rs (target/release/deps/bench-b84c4a320f8d765c)
Gnuplot not found, using plotters backend
parse_template          time:   [15.024 µs 15.292 µs 15.701 µs]
                        change: [+1.1207% +2.2612% +3.7369%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high severe

render_template         time:   [1.6720 µs 1.6745 µs 1.6774 µs]
                        change: [12.666% −12.469% −12.246%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  2 (2.00%) high mild
  12 (12.00%) high severe

large_loop_helper       time:   [111.68 µs 111.86 µs 112.06 µs]
                        change: [13.894% −13.667% −13.431%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe

large_loop_helper_with_context_creation
                        time:   [290.04 µs 290.43 µs 290.75 µs]
                        change: [7.6980% −7.4180% −7.1419%] (p = 0.00 < 0.05)
                        Performance has improved.

large_nested_loop       time:   [117.20 µs 117.41 µs 117.66 µs]
                        change: [20.581% −20.093% −19.617%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  7 (7.00%) high mild
  1 (1.00%) high severe

deeply_nested_partial   time:   [185.19 µs 185.42 µs 185.72 µs]
                        change: [+1.6880% +1.8193% +1.9683%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

For the large_nested_loop where we have a lot of context/path string manipulations, we get up to 20% speed up.

However, this patch can be considered as breaking change for users who access to TemplateElement directly.

@coveralls
Copy link

coveralls commented Jan 6, 2026

Coverage Status

coverage: 83.49% (+0.04%) from 83.449%
when pulling 3fc6688 on feature/smol-str
into b1b39cd on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants