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

improve caching of worker pool for postcss #3260

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

sokra
Copy link
Member

@sokra sokra commented Jan 11, 2023

No description provided.

@sokra sokra requested a review from a team as a code owner January 11, 2023 13:41
@vercel
Copy link

vercel bot commented Jan 11, 2023

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

Name Status Preview Updated
turbo-site ✅ Ready (Inspect) Visit Preview Jan 11, 2023 at 1:41PM (UTC)
9 Ignored Deployments
Name Status Preview Updated
examples-basic-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)
turbo-vite-web ⬜️ Ignored (Inspect) Jan 11, 2023 at 1:41PM (UTC)

@github-actions
Copy link
Contributor

Benchmark for d988bd5

Test Base PR % Significant %
bench_hydration/Turbopack RSC/1000 modules 2845.43ms ± 3.56ms 2870.70ms ± 7.06ms +0.89% +0.14%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8604.68µs ± 85.07µs 8568.98µs ± 72.49µs -0.41%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8944.82µs ± 47.08µs 8870.89µs ± 75.32µs -0.83%
bench_hmr_to_commit/Turbopack RSC/1000 modules 465.13ms ± 2.61ms 467.97ms ± 1.25ms +0.61%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8744.28µs ± 94.13µs 8704.96µs ± 62.89µs -0.45%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7705.61µs ± 62.32µs 7686.00µs ± 55.06µs -0.25%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7751.06µs ± 75.60µs 7679.81µs ± 77.96µs -0.92%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7710.11µs ± 74.26µs 7720.03µs ± 63.29µs +0.13%
bench_hydration/Turbopack RCC/1000 modules 3387.30ms ± 12.46ms 3394.85ms ± 9.93ms +0.22%
bench_hydration/Turbopack RSC/1000 modules 2845.43ms ± 3.56ms 2870.70ms ± 7.06ms +0.89% +0.14%
bench_hydration/Turbopack SSR/1000 modules 2642.86ms ± 11.60ms 2663.15ms ± 12.74ms +0.77%
bench_startup/Turbopack CSR/1000 modules 1651.34ms ± 5.78ms 1671.11ms ± 7.04ms +1.20%
bench_startup/Turbopack RCC/1000 modules 2495.57ms ± 6.09ms 2507.99ms ± 9.16ms +0.50%
bench_startup/Turbopack RSC/1000 modules 2410.78ms ± 9.35ms 2401.30ms ± 8.54ms -0.39%
bench_startup/Turbopack SSR/1000 modules 2057.16ms ± 2.72ms 2058.22ms ± 8.24ms +0.05%

@github-actions
Copy link
Contributor

🟢 CI successful 🟢

Thanks

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Can you explain how this solves PostCSS pool not being reused? These changes look equivalent to the old code.

@sokra
Copy link
Member Author

sokra commented Jan 12, 2023

Can you explain how this solves PostCSS pool not being reused? These changes look equivalent to the old code.

PostCssTransformedAssetVc::process is called for every transformed file. Putting something in a cell will lead to different Vcs (even if the content is the same, turbo engine only cares cell identity). This can be avoided by extracting the logic into a different turbo tasks function which is called with the same arguments (postcss_executor is called with context and postcss config which is often the same across every transformed file). This change leads to postcss_executor being the same Vc for every processed file (if it's affected by the same postcss.config.js). Calling evaluate with the same executor (and other args except for args) will lead to get_evaluate_pool being called with exactly the same arguments, which will lead to pool reuse.

The same problem exists in ModuleOptionsVc::new which is called for every directory. It also called import_map.cell() which leads to different context passed to PostCssTransformVc::new.

@sokra sokra merged commit 8ac9009 into main Jan 12, 2023
@sokra sokra deleted the sokra/web-388-when-running-vercel-site-it-creates-new branch January 12, 2023 08:08
@jridgewell
Copy link
Contributor

The same problem exists in ModuleOptionsVc::new which is called for every directory. It also called import_map.cell() which leads to different context passed to PostCssTransformVc::new.

The actionable feedback I'm getting from this is that we should extract code which prepares a cell into a helper function if the current function is too large?

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