这是indexloc提供的服务,不要输入任何密码
Skip to content

Implementing package inference #2112

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

Merged
merged 18 commits into from
Jan 24, 2023
Merged

Implementing package inference #2112

merged 18 commits into from
Jan 24, 2023

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented Sep 28, 2022

  • Adds TURBO_INVOCATION_DIR env var to global turbo's invocation of local turbo. This allows local turbos that support it to calculate package inference, without passing a bad argument to local turbos that don't yet have this feature.
  • Adds --pkg-inference-root flag, intended to be passed by the shim after calculating an appropriate value, based on the monorepo root and TURBO_INVOCATION_DIR env variable.
  • Adds code to update TargetSelector instances in the presence of an inferred directory. If there's a single package at or above the directory, use that. Otherwise, consider the directory to be a prefix on a parentDir specifier
  • Pass TargetSelector instances by reference so they can be updated in place
  • Add to the global integration test to demonstrate package inference from a directory, as well as bypassing inference by passing --cwd

@gsoltis gsoltis requested a review from a team as a code owner September 28, 2022 20:54
@gsoltis gsoltis requested a review from jaredpalmer September 28, 2022 20:54
@vercel
Copy link

vercel bot commented Sep 28, 2022

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

Name Status Preview Comments Updated
examples-svelte-web 🔄 Building (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-vite-web 🔄 Building (Inspect) Jan 23, 2023 at 11:13PM (UTC)
turborepo-docs-g413 ❌ Failed (Inspect) Jan 23, 2023 at 11:13PM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)
turbo-vite-web ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2023 at 11:13PM (UTC)

Copy link
Contributor

@NicholasLYang NicholasLYang left a comment

Choose a reason for hiding this comment

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

Any chance we could go over how this relates to the Rust shim? Like how the flag is supposed to be computed? I understand what the code is doing but I don't have a full mental model ready.

selector.namePattern = pi.PackageName
}
if selector.parentDir != "" {
parentDir := pi.DirectoryRoot.UntypedJoin(selector.parentDir).ToStringDuringMigration()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for parentDir to be an absolute path? From reading the code, it seems possible if, for instance, --cwd is set to an absolute path. In which case, does this do the right thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. We unfortunately have not plumbed through our paths here yet.

Looking through the code, specifying an absolute path will break currently, or at least not match anything. We join it with the repo root / cwd regardless. But that does mean the above behavior is incorrect, since if we have a parentDir, it is always going to be an absolute path, and the correct behavior for inference is to join what the user specified to the inferred directory.

I'm going to take a stab at using our path types to sort this out and hope it doesn't spiral out too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ported parentDir on TargetSelector to RelativeSystemPath, and pulled the thread to doing the right thing here.

It wasn't possible for the user input to parentDir to be an absolute path before, but that was not obvious.

@gsoltis gsoltis requested review from nathanhammond and removed request for jaredpalmer October 13, 2022 18:24
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2023

🟢 CI successful 🟢

Thanks

Greg Soltis and others added 3 commits January 23, 2023 08:03
@github-actions
Copy link
Contributor

Benchmark for 2136e79

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8797.11µs ± 66.56µs 8765.73µs ± 64.10µs -0.36%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8991.58µs ± 50.44µs 8971.30µs ± 65.58µs -0.23%
bench_hmr_to_commit/Turbopack RSC/1000 modules 458.78ms ± 2.32ms 467.21ms ± 3.13ms +1.84%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8948.74µs ± 81.35µs 8889.22µs ± 81.74µs -0.67%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7777.98µs ± 58.35µs 7761.41µs ± 57.31µs -0.21%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7813.37µs ± 63.71µs 7845.16µs ± 69.83µs +0.41%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7829.58µs ± 51.18µs 7868.50µs ± 89.44µs +0.50%
bench_hydration/Turbopack RCC/1000 modules 3428.34ms ± 12.07ms 3414.79ms ± 14.81ms -0.40%
bench_hydration/Turbopack RSC/1000 modules 2860.83ms ± 7.98ms 2855.69ms ± 8.74ms -0.18%
bench_hydration/Turbopack SSR/1000 modules 2650.83ms ± 7.52ms 2651.97ms ± 9.79ms +0.04%
bench_startup/Turbopack CSR/1000 modules 1653.15ms ± 4.10ms 1649.76ms ± 5.49ms -0.20%
bench_startup/Turbopack RCC/1000 modules 2529.70ms ± 9.17ms 2516.77ms ± 6.33ms -0.51%
bench_startup/Turbopack RSC/1000 modules 2429.16ms ± 7.59ms 2425.36ms ± 8.64ms -0.16%
bench_startup/Turbopack SSR/1000 modules 2081.70ms ± 2.67ms 2086.84ms ± 6.12ms +0.25%

@gsoltis gsoltis added the pr: automerge Kodiak will merge these automatically after checks pass label Jan 23, 2023
@github-actions
Copy link
Contributor

Benchmark for 0d4dc97

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8706.97µs ± 63.99µs 8739.43µs ± 44.49µs +0.37%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8964.64µs ± 54.00µs 9045.15µs ± 64.70µs +0.90%
bench_hmr_to_commit/Turbopack RSC/1000 modules 455.31ms ± 1.75ms 449.31ms ± 2.81ms -1.32%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8812.36µs ± 52.85µs 8878.35µs ± 44.86µs +0.75%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7721.74µs ± 69.39µs 7852.44µs ± 56.18µs +1.69%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7934.94µs ± 62.90µs 7861.04µs ± 103.47µs -0.93%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7975.99µs ± 71.58µs 7902.37µs ± 70.25µs -0.92%
bench_hydration/Turbopack RCC/1000 modules 3401.60ms ± 13.70ms 3414.73ms ± 14.60ms +0.39%
bench_hydration/Turbopack RSC/1000 modules 2850.77ms ± 13.67ms 2849.28ms ± 11.40ms -0.05%
bench_hydration/Turbopack SSR/1000 modules 2632.86ms ± 11.43ms 2648.52ms ± 11.47ms +0.60%
bench_startup/Turbopack CSR/1000 modules 1641.15ms ± 3.86ms 1634.92ms ± 3.40ms -0.38%
bench_startup/Turbopack RCC/1000 modules 2498.83ms ± 5.75ms 2520.84ms ± 5.89ms +0.88%
bench_startup/Turbopack RSC/1000 modules 2408.29ms ± 8.50ms 2423.09ms ± 10.75ms +0.61%
bench_startup/Turbopack SSR/1000 modules 2089.53ms ± 7.81ms 2077.27ms ± 6.25ms -0.59%

@github-actions
Copy link
Contributor

Benchmark for af3e613

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 7869.55µs ± 59.17µs 7921.62µs ± 38.18µs +0.66%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8188.33µs ± 59.59µs 8174.70µs ± 64.29µs -0.17%
bench_hmr_to_commit/Turbopack RSC/1000 modules 454.19ms ± 1.52ms 450.36ms ± 1.93ms -0.84%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8119.74µs ± 84.55µs 8069.99µs ± 82.92µs -0.61%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7116.05µs ± 27.56µs 7202.33µs ± 37.71µs +1.21%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7187.73µs ± 50.42µs 7215.85µs ± 48.73µs +0.39%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7180.75µs ± 44.91µs 7158.15µs ± 54.20µs -0.31%
bench_hydration/Turbopack RCC/1000 modules 3363.98ms ± 11.88ms 3356.99ms ± 15.21ms -0.21%
bench_hydration/Turbopack RSC/1000 modules 2857.30ms ± 18.30ms 2813.84ms ± 9.54ms -1.52%
bench_hydration/Turbopack SSR/1000 modules 2601.65ms ± 13.24ms 2586.91ms ± 7.28ms -0.57%
bench_startup/Turbopack CSR/1000 modules 1608.54ms ± 3.57ms 1620.46ms ± 11.58ms +0.74%
bench_startup/Turbopack RCC/1000 modules 2459.10ms ± 6.08ms 2463.91ms ± 8.53ms +0.20%
bench_startup/Turbopack RSC/1000 modules 2361.89ms ± 8.30ms 2341.58ms ± 5.88ms -0.86%
bench_startup/Turbopack SSR/1000 modules 2023.67ms ± 4.22ms 2037.76ms ± 5.36ms +0.70%

@kodiakhq kodiakhq bot merged commit aa2d651 into main Jan 24, 2023
@kodiakhq kodiakhq bot deleted the gsoltis/infer_pkg branch January 24, 2023 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants