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

[stdlib] Micro-optimize string splitlines and isnewline #3825

Closed
wants to merge 3 commits into from

Conversation

martinvuyk
Copy link
Contributor

@martinvuyk martinvuyk commented Nov 29, 2024

Micro-optimize string splitlines and isnewline.

Benchmark results:

CPU: Intel® Core™ i7-7700HQ

improvement metric: markdown percentage improvement ((old_value - new_value) / old_value)

Average improvement: 1.2% . Many of the discrepancies are likely because of runtime (nano-second scale) pipelining (and other) differences during testing. The most robust estimates are the biggest tests which show around 4.2% improvement.

Name old_value (ms) new_value (ms) improvement
bench_string_splitlines[10] 0.000100497059839818 0.00010261460376 -2.11%
bench_string_splitlines[30] 0.000171998352418428 0.000174028055158599 -1.18%
bench_string_splitlines[50] 0.000264958575880379 0.000251598931395228 5.04%
bench_string_splitlines[100] 0.000417350538881514 0.000415764808815687 0.38%
bench_string_splitlines[1000] 0.00320600819966129 0.00322517645847026 -0.60%
bench_string_splitlines[10000] 0.0302790238107332 0.0305872863513719 -1.02%
bench_string_splitlines[100000] 0.319274428592796 0.304513179279761 4.62%
bench_string_splitlines[1000000] 3.24098357344348 3.10220707742267 4.28%

@martinvuyk martinvuyk requested a review from a team as a code owner November 29, 2024 19:15
@JoeLoser
Copy link
Collaborator

JoeLoser commented Dec 4, 2024

!sync

@JoeLoser
Copy link
Collaborator

JoeLoser commented Dec 5, 2024

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label Dec 5, 2024
@JoeLoser
Copy link
Collaborator

JoeLoser commented Dec 7, 2024

!sync

@modularbot
Copy link
Collaborator

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

@modularbot modularbot added the merged-internally Indicates that this pull request has been merged internally label Dec 9, 2024
modularbot pushed a commit that referenced this pull request Dec 10, 2024
…` (#52307)

[External] [stdlib] Micro-optimize string `splitlines` and `isnewline`

## Micro-optimize string `splitlines` and `isnewline`.

Benchmark results:

CPU: Intel® Core™ i7-7700HQ

improvement metric: markdown percentage improvement (`(old_value -
new_value) / old_value`)

Average improvement: 1.2% . Many of the discrepancies are likely because
of runtime (nano-second scale) pipelining (and other) differences during
testing. The most robust estimates are the biggest tests which show
around 4.2% improvement.

|Name | old_value (ms) | new_value (ms) | improvement|

|:-----------------------------|---------------------:|----------------:|------:|
|`bench_string_splitlines[10]` | 0.000100497059839818 | 0.00010261460376
| -2.11% |
|`bench_string_splitlines[30]` | 0.000171998352418428 |
0.000174028055158599 | -1.18% |
|`bench_string_splitlines[50]` | 0.000264958575880379 |
0.000251598931395228 | 5.04% |
|`bench_string_splitlines[100]` | 0.000417350538881514 |
0.000415764808815687 | 0.38% |
|`bench_string_splitlines[1000]` | 0.00320600819966129 |
0.00322517645847026 | -0.60% |
|`bench_string_splitlines[10000]` | 0.0302790238107332 |
0.0305872863513719 | -1.02% |
|`bench_string_splitlines[100000]` | 0.319274428592796 |
0.304513179279761 | 4.62% |
|`bench_string_splitlines[1000000]` | 3.24098357344348 |
3.10220707742267 | 4.28% |

Co-authored-by: martinvuyk <[email protected]>
Closes #3825
MODULAR_ORIG_COMMIT_REV_ID: 433b5ea2f49164bf08572004da1541ac42f1eed2
@modularbot modularbot added the merged-externally Merged externally in public mojo repo label Dec 10, 2024
@modularbot
Copy link
Collaborator

Landed in fc9fe84! Thank you for your contribution 🎉

@modularbot modularbot closed this Dec 10, 2024
@martinvuyk martinvuyk deleted the optimize-isnewline branch December 10, 2024 18:50
modularbot pushed a commit that referenced this pull request Dec 17, 2024
…` (#52307)

[External] [stdlib] Micro-optimize string `splitlines` and `isnewline`

## Micro-optimize string `splitlines` and `isnewline`.

Benchmark results:

CPU: Intel® Core™ i7-7700HQ

improvement metric: markdown percentage improvement (`(old_value -
new_value) / old_value`)

Average improvement: 1.2% . Many of the discrepancies are likely because
of runtime (nano-second scale) pipelining (and other) differences during
testing. The most robust estimates are the biggest tests which show
around 4.2% improvement.

|Name | old_value (ms) | new_value (ms) | improvement|

|:-----------------------------|---------------------:|----------------:|------:|
|`bench_string_splitlines[10]` | 0.000100497059839818 | 0.00010261460376
| -2.11% |
|`bench_string_splitlines[30]` | 0.000171998352418428 |
0.000174028055158599 | -1.18% |
|`bench_string_splitlines[50]` | 0.000264958575880379 |
0.000251598931395228 | 5.04% |
|`bench_string_splitlines[100]` | 0.000417350538881514 |
0.000415764808815687 | 0.38% |
|`bench_string_splitlines[1000]` | 0.00320600819966129 |
0.00322517645847026 | -0.60% |
|`bench_string_splitlines[10000]` | 0.0302790238107332 |
0.0305872863513719 | -1.02% |
|`bench_string_splitlines[100000]` | 0.319274428592796 |
0.304513179279761 | 4.62% |
|`bench_string_splitlines[1000000]` | 3.24098357344348 |
3.10220707742267 | 4.28% |

Co-authored-by: martinvuyk <[email protected]>
Closes #3825
MODULAR_ORIG_COMMIT_REV_ID: 433b5ea2f49164bf08572004da1541ac42f1eed2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported-internally Signals that a given pull request has been imported internally. merged-externally Merged externally in public mojo repo merged-internally Indicates that this pull request has been merged internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants