projectfluent / fluent-rs

Rust implementation of Project Fluent
https://projectfluent.org
Apache License 2.0
1.08k stars 97 forks source link

Use `memchr` to optimize `get_text_slice` #344

Closed clubby789 closed 4 months ago

clubby789 commented 7 months ago

Running the benchmarks on my machine, I get these results:

parse_ctx_runtime/browser                                                                            
                        time:   [106.61 µs 106.73 µs 106.85 µs]
                        change: [-17.886% -17.720% -17.552%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  8 (8.00%) high mild
  1 (1.00%) high severe
parse_ctx_runtime/preferences                                                                            
                        time:   [277.45 µs 277.83 µs 278.29 µs]
                        change: [-8.5355% -8.3601% -8.1949%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  5 (5.00%) high mild
  2 (2.00%) high severe

With some stress tests against Fluent files used in rustc, I saw improvements of 20-30%.

clubby789 commented 7 months ago

Some notable improvements when used in rustc:

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.3%, -0.2%] 3
Improvements ✅
(secondary)
-1.5% [-4.1%, -0.3%] 41
All ❌✅ (primary) -0.3% [-0.3%, -0.2%] 3
waywardmonkeys commented 7 months ago

@flodolo You might want to approve the CI runs for this.