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

[WIP]: speed up rope iteration and serving #4008

Closed
wants to merge 15 commits into from
Closed

Conversation

jridgewell
Copy link
Contributor

This is just a test to see if Bytes equality is secretly very slow. It uses slice equality, which uses memcmp for &[u8]. But maybe memcmp doesn't have the obvious optimization for pointer equality? This is the only reason that I can think of leading to the performance improvements in #3955. The rope traversal can't be that expensive, right?

@jridgewell jridgewell requested a review from a team as a code owner February 28, 2023 17:54
@vercel
Copy link

vercel bot commented Feb 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
examples-vite-web 🔄 Building (Inspect) Mar 1, 2023 at 6:42PM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Mar 1, 2023 at 6:42PM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Mar 1, 2023 at 6:42PM (UTC)

@@ -686,6 +702,22 @@ impl From<RopeElem> for StackElem {
}
}

trait PtrEq {
Copy link
Contributor

@ForsakenHarmony ForsakenHarmony Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a new trait for this?
Could add a small helper function for Bytes, but even that might be more overhead to read than just copy pasting 2 times

let mut left = RopeReader::new(left, index);
let mut right = RopeReader::new(right, index);
loop {
match (left.fill_buf(), right.fill_buf()) {
match (left.next(), right.next()) {
// fill_buf should always return Ok, with either some number of bytes or 0 bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment probable needs to be changed

@github-actions
Copy link
Contributor

github-actions bot commented Feb 28, 2023

🟢 CI successful 🟢

Thanks

@github-actions
Copy link
Contributor

Benchmark for 9eac652

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 2607.44ms ± 7.96ms 2567.41ms ± 9.37ms -1.54% -0.21%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9896.00µs ± 54.11µs 9973.54µs ± 54.21µs +0.78%
bench_hmr_to_commit/Turbopack RCC/1000 modules 12.77ms ± 0.21ms 12.59ms ± 0.20ms -1.34%
bench_hmr_to_commit/Turbopack RSC/1000 modules 513.09ms ± 0.94ms 511.97ms ± 1.61ms -0.22%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9974.97µs ± 72.23µs 9918.14µs ± 51.05µs -0.57%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8765.43µs ± 44.36µs 8943.25µs ± 47.16µs +2.03%
bench_hmr_to_eval/Turbopack RCC/1000 modules 11.33ms ± 0.17ms 11.19ms ± 0.10ms -1.26%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8887.91µs ± 51.69µs 8821.83µs ± 31.63µs -0.74%
bench_hydration/Turbopack RCC/1000 modules 3893.53ms ± 10.55ms 3922.85ms ± 19.30ms +0.75%
bench_hydration/Turbopack RSC/1000 modules 3555.25ms ± 16.53ms 3539.73ms ± 17.39ms -0.44%
bench_hydration/Turbopack SSR/1000 modules 3428.58ms ± 14.78ms 3434.65ms ± 14.43ms +0.18%
bench_startup/Turbopack CSR/1000 modules 2607.44ms ± 7.96ms 2567.41ms ± 9.37ms -1.54% -0.21%
bench_startup/Turbopack RCC/1000 modules 2394.66ms ± 7.00ms 2397.08ms ± 6.68ms +0.10%
bench_startup/Turbopack RSC/1000 modules 2334.73ms ± 9.63ms 2350.39ms ± 7.00ms +0.67%
bench_startup/Turbopack SSR/1000 modules 2095.08ms ± 3.84ms 2089.70ms ± 3.27ms -0.26%

@jridgewell
Copy link
Contributor Author

jridgewell commented Feb 28, 2023

Appears this was not the cause, rope iteration must just be really slow.

@jridgewell jridgewell changed the title Use ptr equality for Ropes [WIP]: speed up rope iteration and serving Mar 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2023

Benchmark for 8674b47

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 3901.75ms ± 11.28ms 3953.03ms ± 9.30ms +1.31% +0.26%
bench_hydration/Turbopack RSC/1000 modules 3540.67ms ± 6.68ms 3613.00ms ± 7.98ms +2.04% +1.21%
bench_hydration/Turbopack SSR/1000 modules 3408.76ms ± 8.44ms 3481.20ms ± 9.99ms +2.13% +1.04%
bench_startup/Turbopack CSR/1000 modules 2607.24ms ± 7.33ms 2643.72ms ± 7.91ms +1.40% +0.23%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 10.10ms ± 0.03ms 9970.87µs ± 45.74µs -1.23%
bench_hmr_to_commit/Turbopack RCC/1000 modules 12.95ms ± 0.27ms 12.35ms ± 0.15ms -4.59%
bench_hmr_to_commit/Turbopack RSC/1000 modules 523.22ms ± 1.56ms 521.58ms ± 0.78ms -0.31%
bench_hmr_to_commit/Turbopack SSR/1000 modules 10.16ms ± 0.05ms 10.20ms ± 0.05ms +0.40%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8972.38µs ± 48.84µs 8848.13µs ± 26.57µs -1.38%
bench_hmr_to_eval/Turbopack RCC/1000 modules 11.20ms ± 0.06ms 11.04ms ± 0.06ms -1.43%
bench_hmr_to_eval/Turbopack SSR/1000 modules 9036.62µs ± 56.67µs 9040.45µs ± 30.94µs +0.04%
bench_hydration/Turbopack RCC/1000 modules 3901.75ms ± 11.28ms 3953.03ms ± 9.30ms +1.31% +0.26%
bench_hydration/Turbopack RSC/1000 modules 3540.67ms ± 6.68ms 3613.00ms ± 7.98ms +2.04% +1.21%
bench_hydration/Turbopack SSR/1000 modules 3408.76ms ± 8.44ms 3481.20ms ± 9.99ms +2.13% +1.04%
bench_startup/Turbopack CSR/1000 modules 2607.24ms ± 7.33ms 2643.72ms ± 7.91ms +1.40% +0.23%
bench_startup/Turbopack RCC/1000 modules 2388.46ms ± 8.04ms 2390.34ms ± 5.55ms +0.08%
bench_startup/Turbopack RSC/1000 modules 2341.35ms ± 10.83ms 2343.15ms ± 7.10ms +0.08%
bench_startup/Turbopack SSR/1000 modules 2095.00ms ± 3.09ms 2086.38ms ± 2.97ms -0.41%

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2023

Benchmark for 02d2dd6

Test Base PR % Significant %
bench_hydration/Turbopack SSR/1000 modules 3515.15ms ± 10.88ms 3558.62ms ± 9.78ms +1.24% +0.06%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9906.59µs ± 35.46µs 9966.42µs ± 42.12µs +0.60%
bench_hmr_to_commit/Turbopack RCC/1000 modules 12.44ms ± 0.11ms 12.45ms ± 0.05ms +0.11%
bench_hmr_to_commit/Turbopack RSC/1000 modules 519.45ms ± 1.50ms 521.10ms ± 1.62ms +0.32%
bench_hmr_to_commit/Turbopack SSR/1000 modules 10.07ms ± 0.05ms 10.05ms ± 0.05ms -0.22%
bench_hmr_to_eval/Turbopack CSR/1000 modules 9034.78µs ± 38.06µs 9127.92µs ± 66.70µs +1.03%
bench_hmr_to_eval/Turbopack RCC/1000 modules 11.24ms ± 0.07ms 11.15ms ± 0.06ms -0.80%
bench_hmr_to_eval/Turbopack SSR/1000 modules 9022.87µs ± 66.70µs 9056.10µs ± 24.10µs +0.37%
bench_hydration/Turbopack RCC/1000 modules 4003.46ms ± 23.09ms 4038.71ms ± 10.42ms +0.88%
bench_hydration/Turbopack RSC/1000 modules 3628.82ms ± 11.86ms 3674.30ms ± 12.42ms +1.25%
bench_hydration/Turbopack SSR/1000 modules 3515.15ms ± 10.88ms 3558.62ms ± 9.78ms +1.24% +0.06%
bench_startup/Turbopack CSR/1000 modules 2721.79ms ± 12.91ms 2739.62ms ± 7.47ms +0.66%
bench_startup/Turbopack RCC/1000 modules 2439.70ms ± 12.41ms 2419.13ms ± 15.14ms -0.84%
bench_startup/Turbopack RSC/1000 modules 2364.71ms ± 9.28ms 2355.01ms ± 6.88ms -0.41%
bench_startup/Turbopack SSR/1000 modules 2125.50ms ± 4.40ms 2128.91ms ± 3.59ms +0.16%

@jridgewell jridgewell closed this Mar 1, 2023
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