-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Introduce
RcStr
(vercel/turborepo#8221)
### Description If we accept `: String` from a function, invoking the function needs one owned `String` and it means allocation even if the value isn't changed. But with this PR, functions now accept `RcStr`, which is shared, so invoking the same function with the same value does not involve allocation for `String` . --- I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. I used `ast-grep` with ```yml id: convert-expr-into language: rust rule: kind: function_item all: - has: kind: parameters pattern: $PARAMS - any: - has: kind: visibility_modifier pattern: $VIS - not: has: kind: visibility_modifier - any: - has: kind: function_modifiers pattern: $MOD - not: has: kind: function_modifiers - has: field: return_type pattern: $RET - has: field: body pattern: $BODY - has: kind: identifier pattern: $NAME - follows: kind: attribute_item pattern: '#[turbo_tasks::function]' transform: NEW_PARAMS: replace: replace: 'String' by: 'RcStr' source: $PARAMS fix: $VIS $MOD fn $NAME $NEW_PARAMS -> $RET $BODY ``` ### Performance difference: #### `main`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 65.6s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1476 s 4.1625 s 4.1752 s] Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.5s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0396 s 4.0673 s 4.0956 s] Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 69.7s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.7222 s 4.7508 s 4.7790 s] ``` #### `pr`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 66.2s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1175 s 4.1310 s 4.1496 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high severe Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.7s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0401 s 4.0714 s 4.1105 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 70.2s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.6696 s 4.6900 s 4.7107 s] Benchmarking bench_startup/Next.js 14 Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.9s. ``` --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
- Loading branch information
Showing
227 changed files
with
2,606 additions
and
2,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.