maciejhirsz / logos

Create ridiculously fast Lexers
https://logos.maciej.codes
Apache License 2.0
2.71k stars 105 forks source link

chore: move `lazy_static` to `once_cell`, and some clippy fix #380

Open attila-lin opened 4 months ago

jeertmans commented 4 months ago

Hello @attila-lin, could you please provide some motivation why changes from lazy_static to once_cell`?

Also, I assume you ran Clippy with the Nightly toolchain?

attila-lin commented 4 months ago

Hello @attila-lin, could you please provide some motivation why changes from lazy_static to once_cell`?

maintenance = { status = "passively-maintained" }

this crate is passively-maintained. The std choose the once_cell impl.

Also, I assume you ran Clippy with the Nightly toolchain?

Yes.

jeertmans commented 4 months ago

Hello @attila-lin, could you please provide some motivation why changes from lazy_static to once_cell`?

maintenance = { status = "passively-maintained" }

this crate is passively-maintained. The std choose the once_cell impl.

The fact that it is passively maintained is not an issue to me, but the second argument looks ok. But I assume we would go for std::cell::LazyCell once https://github.com/rust-lang/rust/issues/109736 is merged (so stabilized).

Also, I assume you ran Clippy with the Nightly toolchain?

Yes.

Fair enough

jeertmans commented 4 months ago

Benchmarks show a large decreasing in performances, which is surprising:

group                                         before                                 changes
-----                                         ------                                 -------
count_ok/identifiers                          1.06    866.3±5.20ns   857.6 MB/sec    1.00   818.1±20.90ns   908.1 MB/sec
count_ok/keywords_operators_and_punctators    1.00      2.5±0.05µs   805.5 MB/sec    1.02      2.6±0.04µs   790.1 MB/sec
count_ok/strings                              1.00   554.8±12.18ns  1497.3 MB/sec    1.24   689.4±33.73ns  1204.9 MB/sec
iterate/identifiers                           1.02   869.3±19.49ns   854.6 MB/sec    1.00    850.5±4.32ns   873.5 MB/sec
iterate/keywords_operators_and_punctators     1.05      2.7±0.02µs   762.7 MB/sec    1.00      2.5±0.02µs   799.9 MB/sec
iterate/strings                               1.00   585.3±21.16ns  1419.1 MB/sec    1.22   716.3±23.00ns  1159.6 MB/sec

I just restarted the benchmarks, to see if that stays the same.

attila-lin commented 4 months ago

interesting!

jeertmans commented 4 months ago

This is very surprising... Do you observe the same benchmark changes locally?

attila-lin commented 3 months ago

let me try unsync version!