projectfluent / fluent-rs

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

Replace ouroboros with self_cell #227

Closed Voultapher closed 3 years ago

Voultapher commented 3 years ago

Before (fluent-bundle):

$ cargo build ... 37 dependencies Finished dev [unoptimized + debuginfo] target(s) in 18.39s

After:

$ cargo build ... 27 dependencies Finished dev [unoptimized + debuginfo] target(s) in 14.59s

That's 26% faster in this very rough test. But the 10 fewer dependencies make this seem plausible. There are still some proc-macro dependencies like syn left, but they have nothing to do with self_cell as it has 0 dependencies and doesn't use proc-macros.

Disclaimer I'm the author of self_cell.

I ran cargo test and all non skipped tests passed before and after.

This is a continuation of https://github.com/projectfluent/fluent-rs/pull/221 which seems to have become stale.

I also ran the iai benchmarks:

Before:

iai_resolve_preferences
Instructions:             1875919 (No change)
L1 Accesses:              2669397 (No change)
L2 Accesses:                 9929 (No change)
RAM Accesses:                6519 (No change)
Estimated Cycles:         2947207 (No change)

After:

iai_resolve_preferences
Instructions:             1873556 (-0.125965%)
L1 Accesses:              2667079 (-0.086836%)
L2 Accesses:                 9848 (-0.815792%)
RAM Accesses:                6516 (-0.046019%)
Estimated Cycles:         2944379 (-0.095955%)

And it's slightly faster than ouroboros.

zbraniecki commented 3 years ago

This looks great! Thank you so much for taking time to come up with a PR!