Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Rc<str> in cycle for all strings #27

Merged
merged 1 commit into from
Jun 28, 2024
Merged

use Rc<str> in cycle for all strings #27

merged 1 commit into from
Jun 28, 2024

Conversation

emuell
Copy link
Owner

@emuell emuell commented Jun 27, 2024

  • should not affect parsing time, but speeds up event generation time by ~25%, as all those strings no longer need to be cloned/copied for each generated event

  • ideally those strings should be string slices, pointing to the original input string, using Cow, but this really hard to realize with Rust lifetimes

@unlessgames
This is the second most low hanging fruit after #26 (which I'm having build troubles with) and partly my "fault" as I've introduced that "string" copy in Event. Also a good test for the PR benchmarks.

The Rc stuff isn't nice, but at least a common pattern in Rust in such cases...

Fine with me to skip this. Your decision. The performance gains are not that big.

@emuell emuell requested a review from unlessgames June 27, 2024 11:13
@emuell emuell force-pushed the perf/cycle-strings branch from f2f3f9d to e52aebd Compare June 27, 2024 13:17
Repository owner deleted a comment from github-actions bot Jun 27, 2024
Copy link

Benchmark for 2dc1a4e

Click to view benchmark
Test Base PR %
Cycle/Generate 69.8±1.14µs 58.5±0.22µs -16.19%
Cycle/Parse 331.2±2.34µs 338.3±3.04µs +2.14%
Rust Phrase/Clone 97.6±0.50ns 93.1±0.66ns -4.61%
Rust Phrase/Create 70.3±1.75µs 69.7±0.73µs -0.85%
Rust Phrase/Run 1587.6±19.95µs 1430.1±3.71µs -9.92%
Scripted Phrase/Clone 80.9±1.16ns 81.9±0.30ns +1.24%
Scripted Phrase/Create 1244.1±32.12µs 1229.9±17.51µs -1.14%
Scripted Phrase/Run 3.9±0.03ms 3.4±0.09ms -12.82%

@unlessgames
Copy link
Collaborator

Looks good to me!

- should not affect parsing time, but speeds up event generation time by ~25%, as all those strings no longer need to be cloned/copied for each generated event

- ideally those strings should be string slices, pointing to the original input string, using Cow, but this really hard to realize with Rust lifetimes
@emuell emuell force-pushed the perf/cycle-strings branch from e52aebd to 2478498 Compare June 28, 2024 13:40
Copy link

Benchmark for 45b5b54

Click to view benchmark
Test Base PR %
Cycle/Generate 70.9±0.40µs 59.0±0.21µs -16.78%
Cycle/Parse 336.7±4.58µs 318.1±2.57µs -5.52%
Rust Phrase/Clone 87.3±0.73ns 88.1±0.30ns +0.92%
Rust Phrase/Create 68.3±0.42µs 66.1±0.40µs -3.22%
Rust Phrase/Run 1595.3±5.69µs 1386.0±14.75µs -13.12%
Scripted Phrase/Clone 79.6±0.94ns 80.9±0.58ns +1.63%
Scripted Phrase/Create 822.0±16.31µs 825.8±8.28µs +0.46%
Scripted Phrase/Run 3.8±0.02ms 3.3±0.03ms -13.16%

@emuell emuell merged commit 6399e69 into master Jun 28, 2024
2 checks passed
@emuell emuell deleted the perf/cycle-strings branch June 28, 2024 13:46
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.

2 participants