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

[turbopack] Minimal implementation of local Vcs #68469

Merged
merged 2 commits into from
Aug 5, 2024
Merged

[turbopack] Minimal implementation of local Vcs #68469

merged 2 commits into from
Aug 5, 2024

Conversation

bgw
Copy link
Member

@bgw bgw commented Aug 2, 2024

This is a migrated PR. This was in the turbo repository before the next.js merge.
Migrated From: vercel/turborepo#8780

Description

Local Vcs store task-local values inside of the current task's state. The SharedReference holding onto their values is dropped when the task exits.

The contents of a local Vc must still use a refcounted SharedReference/triomphe::Arc because they can be turned into ReadRef objects (https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html), which require a 'static lifetime. We can experiment with adding a lifetime to ReadRef in a future iteration, but there's little advantage to doing this until we have local tasks.

Limitations

This implements just enough to create and read local Vcs (with a test!). There are many things that are still unimplemented with todo!(). Most notably:

  • We can't resolve a local Vc to a ResolvedVc.
  • There's no way to return or pass a local Vc as an argument yet.
  • For safety, we should only allow construction of local Vcs in functions where we know that the return value is a ResolvedValue.

Grand plan: https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

Memory Usage

  • This increases the size of Vc/RawVc from 96 bits to 128 bits. With clever packing this could (in theory) be solved. However, that it increase the number of machine words (2x 64bit), so it might not have any real impact after alignment happens.

  • This increase the size of CurrentTaskState. I suspect this isn't too bad as there should be a smallish number of tasks active at any given time.

I was not able to measure any change to peak memory/heap usage.

Built using

cargo build --release -p next-build-test

Ran heaptrack on a single page (/sink) in shadcn/ui with:

cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'

And analyzed the results with

heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20

Before

total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K

After

total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K

Testing Instructions

cargo nextest r -p turbo-tasks -p turbo-tasks-memory

@bgw bgw changed the title Minimal implementation of local cells [turbopack] Minimal implementation of local Vcs Aug 2, 2024
@bgw bgw requested a review from arlyon August 2, 2024 21:17
@bgw bgw marked this pull request as ready for review August 2, 2024 21:18
@ijjk
Copy link
Member

ijjk commented Aug 2, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary vercel/next.js bgw/local-cell Change
buildDuration 17.5s 15.1s N/A
buildDurationCached 8.4s 7.3s N/A
nodeModulesSize 352 MB 352 MB
nextStartRea..uration (ms) 424ms 425ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js bgw/local-cell Change
124-HASH.js gzip 37.3 kB 37.3 kB N/A
5121a57b-HASH.js gzip 51.9 kB 51.9 kB N/A
7480.HASH.js gzip 169 B 169 B
935-HASH.js gzip 5.19 kB 5.19 kB N/A
framework-HASH.js gzip 56.7 kB 56.7 kB
main-app-HASH.js gzip 224 B 227 B N/A
main-HASH.js gzip 32.1 kB 32.1 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB
Overall change 58.6 kB 58.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js bgw/local-cell Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js bgw/local-cell Change
_app-HASH.js gzip 193 B 194 B N/A
_error-HASH.js gzip 193 B 192 B N/A
amp-HASH.js gzip 509 B 511 B N/A
css-HASH.js gzip 342 B 343 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB
edge-ssr-HASH.js gzip 265 B 266 B N/A
head-HASH.js gzip 362 B 364 B N/A
hooks-HASH.js gzip 393 B 393 B
image-HASH.js gzip 4.4 kB 4.4 kB
index-HASH.js gzip 268 B 267 B N/A
link-HASH.js gzip 2.81 kB 2.81 kB N/A
routerDirect..HASH.js gzip 329 B 327 B N/A
script-HASH.js gzip 395 B 396 B N/A
withRouter-HASH.js gzip 325 B 323 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 6.74 kB 6.74 kB
Client Build Manifests
vercel/next.js canary vercel/next.js bgw/local-cell Change
_buildManifest.js gzip 748 B 748 B
Overall change 748 B 748 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js bgw/local-cell Change
index.html gzip 520 B 520 B
link.html gzip 535 B 537 B N/A
withRouter.html gzip 517 B 517 B
Overall change 1.04 kB 1.04 kB
Edge SSR bundle Size
vercel/next.js canary vercel/next.js bgw/local-cell Change
edge-ssr.js gzip 127 kB 127 kB
page.js gzip 168 kB 168 kB N/A
Overall change 127 kB 127 kB
Middleware size
vercel/next.js canary vercel/next.js bgw/local-cell Change
middleware-b..fest.js gzip 668 B 667 B N/A
middleware-r..fest.js gzip 155 B 156 B N/A
middleware.js gzip 29.6 kB 29.6 kB N/A
edge-runtime..pack.js gzip 1.03 kB 1.03 kB
Overall change 1.03 kB 1.03 kB
Next Runtimes
vercel/next.js canary vercel/next.js bgw/local-cell Change
928-experime...dev.js gzip 310 B 310 B
928.runtime.dev.js gzip 301 B 301 B
app-page-exp...dev.js gzip 245 kB 245 kB
app-page-exp..prod.js gzip 120 kB 120 kB
app-page-tur..prod.js gzip 132 kB 132 kB
app-page-tur..prod.js gzip 128 kB 128 kB
app-page.run...dev.js gzip 232 kB 232 kB
app-page.run..prod.js gzip 117 kB 117 kB
app-route-ex...dev.js gzip 23.1 kB 23.1 kB
app-route-ex..prod.js gzip 18.8 kB 18.8 kB
app-route-tu..prod.js gzip 18.8 kB 18.8 kB
app-route-tu..prod.js gzip 18.6 kB 18.6 kB
app-route.ru...dev.js gzip 24.4 kB 24.4 kB
app-route.ru..prod.js gzip 18.6 kB 18.6 kB
pages-api-tu..prod.js gzip 9.6 kB 9.6 kB
pages-api.ru...dev.js gzip 9.87 kB 9.87 kB
pages-api.ru..prod.js gzip 9.59 kB 9.59 kB
pages-turbo...prod.js gzip 21.6 kB 21.6 kB
pages.runtim...dev.js gzip 22.2 kB 22.2 kB
pages.runtim..prod.js gzip 21.6 kB 21.6 kB
server.runti..prod.js gzip 56.8 kB 56.8 kB
Overall change 1.25 MB 1.25 MB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js bgw/local-cell Change
0.pack gzip 1.41 MB 1.41 MB ⚠️ +238 B
index.pack gzip 120 kB 120 kB N/A
Overall change 1.41 MB 1.41 MB ⚠️ +238 B
Diff details
Diff for page.js
@@ -15,7 +15,7 @@
       /***/
     },
 
-    /***/ 6010: /***/ (
+    /***/ 2529: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -30,7 +30,7 @@
         default: () => /* binding */ nHandler,
       });
 
-      // NAMESPACE OBJECT: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapp-edge-ssr%2Fpage&page=%2Fapp-edge-ssr%2Fpage&pagePath=private-next-app-dir%2Fapp-edge-ssr%2Fpage.js&appDir=%2Ftmp%2Fnext-statsPScn4m%2Fstats-app%2Fapp&appPaths=%2Fapp-edge-ssr%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&flyingShuttle=false&preferredRegion=&middlewareConfig=e30%3D!./app/app-edge-ssr/page.js?__next_edge_ssr_entry__
+      // NAMESPACE OBJECT: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapp-edge-ssr%2Fpage&page=%2Fapp-edge-ssr%2Fpage&pagePath=private-next-app-dir%2Fapp-edge-ssr%2Fpage.js&appDir=%2Ftmp%2Fnext-statsPScn4m%2Fstats-app%2Fapp&appPaths=%2Fapp-edge-ssr%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&flyingShuttle=false&preferredRegion=&middlewareConfig=e30%3D!./app/app-edge-ssr/page.js?__next_edge_ssr_entry__
       var page_next_edge_ssr_entry_namespaceObject = {};
       __webpack_require__.r(page_next_edge_ssr_entry_namespaceObject);
       __webpack_require__.d(page_next_edge_ssr_entry_namespaceObject, {
@@ -69,35 +69,35 @@
         tree: () => tree,
       });
 
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/web/globals.js
-      var globals = __webpack_require__(2152);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/web/adapter.js + 3 modules
-      var adapter = __webpack_require__(1232);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js + 87 modules
-      var render = __webpack_require__(9946);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/lib/incremental-cache/index.js + 3 modules
-      var incremental_cache = __webpack_require__(8809);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/app-render/app-render.js + 72 modules
-      var app_render = __webpack_require__(1472);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/route-modules/app-page/module.compiled.js
-      var module_compiled = __webpack_require__(5428);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/route-kind.js
-      var route_kind = __webpack_require__(5320);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/client/components/error-boundary.js
-      var error_boundary = __webpack_require__(9574);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/app-render/entry-base.js + 9 modules
-      var entry_base = __webpack_require__(18); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapp-edge-ssr%2Fpage&page=%2Fapp-edge-ssr%2Fpage&pagePath=private-next-app-dir%2Fapp-edge-ssr%2Fpage.js&appDir=%2Ftmp%2Fnext-statsPScn4m%2Fstats-app%2Fapp&appPaths=%2Fapp-edge-ssr%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&flyingShuttle=false&preferredRegion=&middlewareConfig=e30%3D!./app/app-edge-ssr/page.js?__next_edge_ssr_entry__
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/web/globals.js
+      var globals = __webpack_require__(3866);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/web/adapter.js + 3 modules
+      var adapter = __webpack_require__(1284);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js + 87 modules
+      var render = __webpack_require__(4419);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/lib/incremental-cache/index.js + 3 modules
+      var incremental_cache = __webpack_require__(8579);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/app-render/app-render.js + 72 modules
+      var app_render = __webpack_require__(9027);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/route-modules/app-page/module.compiled.js
+      var module_compiled = __webpack_require__(5011);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/route-kind.js
+      var route_kind = __webpack_require__(6482);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/client/components/error-boundary.js
+      var error_boundary = __webpack_require__(466);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/app-render/entry-base.js + 9 modules
+      var entry_base = __webpack_require__(3258); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapp-edge-ssr%2Fpage&page=%2Fapp-edge-ssr%2Fpage&pagePath=private-next-app-dir%2Fapp-edge-ssr%2Fpage.js&appDir=%2Ftmp%2Fnext-statsPScn4m%2Fstats-app%2Fapp&appPaths=%2Fapp-edge-ssr%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&flyingShuttle=false&preferredRegion=&middlewareConfig=e30%3D!./app/app-edge-ssr/page.js?__next_edge_ssr_entry__
       const component0 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 2601)
+          __webpack_require__.bind(__webpack_require__, 8692)
         );
       const component1 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 3986)
+          __webpack_require__.bind(__webpack_require__, 7930)
         );
       const page2 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 3010)
+          __webpack_require__.bind(__webpack_require__, 8681)
         );
 
       // We inject the tree and pages here so that we can use them in the route
@@ -163,12 +163,12 @@
       });
 
       //# sourceMappingURL=app-page.js.map
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/lib/page-types.js
-      var page_types = __webpack_require__(7816);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/app-render/encryption-utils.js
-      var encryption_utils = __webpack_require__(505);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/esm/server/app-render/action-utils.js
-      var action_utils = __webpack_require__(7049); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?{"absolute500Path":"","absoluteAppPath":"next/dist/pages/_app","absoluteDocumentPath":"next/dist/pages/_document","absoluteErrorPath":"next/dist/pages/_error","absolutePagePath":"private-next-app-dir/app-edge-ssr/page.js","dev":false,"isServerComponent":true,"page":"/app-edge-ssr/page","stringifiedConfig":"eyJlbnYiOnt9LCJlc2xpbnQiOnsiaWdub3JlRHVyaW5nQnVpbGRzIjpmYWxzZX0sInR5cGVzY3JpcHQiOnsiaWdub3JlQnVpbGRFcnJvcnMiOmZhbHNlLCJ0c2NvbmZpZ1BhdGgiOiJ0c2NvbmZpZy5qc29uIn0sImRpc3REaXIiOiIubmV4dCIsImNsZWFuRGlzdERpciI6dHJ1ZSwiYXNzZXRQcmVmaXgiOiIiLCJjYWNoZU1heE1lbW9yeVNpemUiOjUyNDI4ODAwLCJjb25maWdPcmlnaW4iOiJuZXh0LmNvbmZpZy5qcyIsInVzZUZpbGVTeXN0ZW1QdWJsaWNSb3V0ZXMiOnRydWUsImdlbmVyYXRlRXRhZ3MiOnRydWUsInBhZ2VFeHRlbnNpb25zIjpbInRzeCIsInRzIiwianN4IiwianMiXSwicG93ZXJlZEJ5SGVhZGVyIjp0cnVlLCJjb21wcmVzcyI6dHJ1ZSwiaW1hZ2VzIjp7ImRldmljZVNpemVzIjpbNjQwLDc1MCw4MjgsMTA4MCwxMjAwLDE5MjAsMjA0OCwzODQwXSwiaW1hZ2VTaXplcyI6WzE2LDMyLDQ4LDY0LDk2LDEyOCwyNTYsMzg0XSwicGF0aCI6Ii9fbmV4dC9pbWFnZSIsImxvYWRlciI6ImRlZmF1bHQiLCJsb2FkZXJGaWxlIjoiIiwiZG9tYWlucyI6W10sImRpc2FibGVTdGF0aWNJbWFnZXMiOmZhbHNlLCJtaW5pbXVtQ2FjaGVUVEwiOjYwLCJmb3JtYXRzIjpbImltYWdlL3dlYnAiXSwiZGFuZ2Vyb3V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mFsc2UmcHJlZmVycmVkUmVnaW9uPSZtaWRkbGV3YXJlQ29uZmlnPWUzMCUzRCE=","sriEnabled":false,"middlewareConfig":"e30="}!
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/lib/page-types.js
+      var page_types = __webpack_require__(1627);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/app-render/encryption-utils.js
+      var encryption_utils = __webpack_require__(9622);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/esm/server/app-render/action-utils.js
+      var action_utils = __webpack_require__(2443); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?{"absolute500Path":"","absoluteAppPath":"next/dist/pages/_app","absoluteDocumentPath":"next/dist/pages/_document","absoluteErrorPath":"next/dist/pages/_error","absolutePagePath":"private-next-app-dir/app-edge-ssr/page.js","dev":false,"isServerComponent":true,"page":"/app-edge-ssr/page","stringifiedConfig":"eyJlbnYiOnt9LCJlc2xpbnQiOnsiaWdub3JlRHVyaW5nQnVpbGRzIjpmYWxzZX0sInR5cGVzY3JpcHQiOnsiaWdub3JlQnVpbGRFcnJvcnMiOmZhbHNlLCJ0c2NvbmZpZ1BhdGgiOiJ0c2NvbmZpZy5qc29uIn0sImRpc3REaXIiOiIubmV4dCIsImNsZWFuRGlzdERpciI6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mRlbmNpZXMiOmZhbHNlLCJjb25maWdGaWxlIjoiL3RtcC9uZXh0LXN0YXRzUFNjbjRtL3N0YXRzLWFwcC9uZXh0LmNvbmZpZy5qcyIsImNvbmZpZ0ZpbGVOYW1lIjoibmV4dC5jb25maWcuanMifQ==","pagesType":"app","appDirLoader":"bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBwLWVkZ2Utc3NyJTJGcGFnZSZwYWdlPSUyRmFwcC1lZGdlLXNzciUyRnBhZ2UmcGFnZVBhdGg9cHJpdmF0ZS1uZXh0LWFwcC1kaXIlMkZhcHAtZWRnZS1zc3IlMkZwYWdlLmpzJmFwcERpcj0lMkZ0bXAlMkZuZXh0LXN0YXRzUFNjbjRtJTJGc3RhdHMtYXBwJTJGYXBwJmFwcFBhdGhzPSUyRmFwcC1lZGdlLXNzciUyRnBhZ2UmcGFnZUV4dGVuc2lvbnM9dHN4JnBhZ2VFeHRlbnNpb25zPXRzJnBhZ2VFeHRlbnNpb25zPWpzeCZwYWdlRXh0ZW5zaW9ucz1qcyZiYXNlUGF0aD0mYXNzZXRQcmVmaXg9Jm5leHRDb25maWdPdXRwdXQ9JmZseWluZ1NodXR0bGU9ZmFsc2UmcHJlZmVycmVkUmVnaW9uPSZtaWRkbGV3YXJlQ29uZmlnPWUzMCUzRCE=","sriEnabled":false,"middlewareConfig":"e30="}!
       var _self___RSC_MANIFEST;
 
       const incrementalCacheHandler = null;
@@ -431,50 +431,50 @@
       /***/
     },
 
-    /***/ 8418: /***/ (
+    /***/ 7984: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 2916)
+        __webpack_require__.bind(__webpack_require__, 907)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1538)
+        __webpack_require__.bind(__webpack_require__, 6791)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 9334)
+        __webpack_require__.bind(__webpack_require__, 3429)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 6403)
+        __webpack_require__.bind(__webpack_require__, 4497)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7073)
+        __webpack_require__.bind(__webpack_require__, 4002)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1702)
+        __webpack_require__.bind(__webpack_require__, 694)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7887)
+        __webpack_require__.bind(__webpack_require__, 1371)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 2529)
+        __webpack_require__.bind(__webpack_require__, 4422)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 8095)
+        __webpack_require__.bind(__webpack_require__, 4072)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 4670)
+        __webpack_require__.bind(__webpack_require__, 6839)
       );
 
       /***/
     },
 
-    /***/ 5994: /***/ () => {
+    /***/ 402: /***/ () => {
       /***/
     },
 
-    /***/ 3010: /***/ (
+    /***/ 8681: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -494,7 +494,7 @@
       /***/
     },
 
-    /***/ 2601: /***/ (
+    /***/ 8692: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -506,7 +506,7 @@
         /* harmony export */
       });
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
-        __webpack_require__(1645);
+        __webpack_require__(4673);
 
       function RootLayout({ children }) {
         return /*#__PURE__*/ (0,
@@ -525,7 +525,7 @@
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
-    /******/ __webpack_require__.O(0, [86, 613], () => __webpack_exec__(6010));
+    /******/ __webpack_require__.O(0, [979, 32], () => __webpack_exec__(2529));
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ (_ENTRIES = typeof _ENTRIES === "undefined" ? {} : _ENTRIES)[
       "middleware_app/app-edge-ssr/page"
Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for image-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [8358],
   {
-    /***/ 8316: /***/ (
+    /***/ 8834: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(4765);
+          return __webpack_require__(5780);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 1112: /***/ (module, exports, __webpack_require__) => {
+    /***/ 7481: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,17 +40,17 @@
         __webpack_require__(5596)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(9382)
+        __webpack_require__(9639)
       );
-      const _getimgprops = __webpack_require__(2097);
-      const _imageconfig = __webpack_require__(8714);
-      const _imageconfigcontextsharedruntime = __webpack_require__(1327);
-      const _warnonce = __webpack_require__(6055);
-      const _routercontextsharedruntime = __webpack_require__(8275);
+      const _getimgprops = __webpack_require__(1607);
+      const _imageconfig = __webpack_require__(2867);
+      const _imageconfigcontextsharedruntime = __webpack_require__(1015);
+      const _warnonce = __webpack_require__(6694);
+      const _routercontextsharedruntime = __webpack_require__(9562);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6067)
+        __webpack_require__(3463)
       );
-      const _usemergedref = __webpack_require__(1261);
+      const _usemergedref = __webpack_require__(1057);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 1261: /***/ (module, exports, __webpack_require__) => {
+    /***/ 1057: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -440,7 +440,7 @@
       /***/
     },
 
-    /***/ 2097: /***/ (
+    /***/ 1607: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -456,9 +456,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(6055);
-      const _imageblursvg = __webpack_require__(9254);
-      const _imageconfig = __webpack_require__(8714);
+      const _warnonce = __webpack_require__(6694);
+      const _imageblursvg = __webpack_require__(9866);
+      const _imageconfig = __webpack_require__(2867);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -830,7 +830,7 @@
       /***/
     },
 
-    /***/ 9254: /***/ (__unused_webpack_module, exports) => {
+    /***/ 9866: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -885,7 +885,7 @@
       /***/
     },
 
-    /***/ 9331: /***/ (
+    /***/ 3484: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -912,10 +912,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(4345);
-      const _getimgprops = __webpack_require__(2097);
-      const _imagecomponent = __webpack_require__(1112);
+      const _getimgprops = __webpack_require__(1607);
+      const _imagecomponent = __webpack_require__(7481);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6067)
+        __webpack_require__(3463)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -947,7 +947,7 @@
       /***/
     },
 
-    /***/ 6067: /***/ (__unused_webpack_module, exports) => {
+    /***/ 3463: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -982,7 +982,7 @@
       /***/
     },
 
-    /***/ 4765: /***/ (
+    /***/ 5780: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -999,8 +999,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(3262);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_432dyi3er6pnalgpduyz2i6axm/node_modules/next/image.js
-      var next_image = __webpack_require__(2692);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-06d0b89e-20240801_re_wusbvjw3sleq6d7g7gklhdw6bm/node_modules/next/image.js
+      var next_image = __webpack_require__(8565);
       var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // CONCATENATED MODULE: ./pages/nextjs.png
       /* harmony default export */ const nextjs = {
         src: "/_next/static/media/nextjs.cae0b805.png",
@@ -1030,12 +1030,12 @@
       /***/
     },
 
-    /***/ 2692: /***/ (
+    /***/ 8565: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(9331);
+      module.exports = __webpack_require__(3484);
 
       /***/
     },
@@ -1045,7 +1045,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
-      __webpack_exec__(8316)
+      __webpack_exec__(8834)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for 124-HASH.js

Diff too large to display

Diff for main-HASH.js

Diff too large to display

Commit: 71382c4

@ijjk
Copy link
Member

ijjk commented Aug 2, 2024

Tests Passed

Copy link
Contributor

@arlyon arlyon left a comment

Choose a reason for hiding this comment

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

Linking a comment from the other PR for posterity

https://github.com/vercel/turbo/pull/8780/files#r1698335930

Base automatically changed from bgw/cell-mode-raw to canary August 5, 2024 20:19
@bgw bgw merged commit 9511ae2 into canary Aug 5, 2024
107 checks passed
Copy link
Member Author

bgw commented Aug 5, 2024

Merge activity

  • Aug 5, 5:01 PM EDT: @bgw merged this pull request with Graphite.

@bgw bgw deleted the bgw/local-cell branch August 5, 2024 21:01
samcx pushed a commit that referenced this pull request Aug 5, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
bgw added a commit that referenced this pull request Aug 5, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8826

### Description

Builds on the minimal implementation of local Vcs in #68469

At some point, we need to return local Vcs or pass them to another
function as an argument. However, local Vcs are only valid within the
context of the current task.

The solution is that we need to convert local `Vc`s to non-local `Vc`s,
and the easiest way to do that is to `.resolve()` it!

This PR creates the new non-local cell on the current task, re-using the
SharedReference the was used for the local cell, along with it's type id
information.

`RawVc` lacks information about the compile-time type `T`. Even `Vc` may
know the real type of `T` if the `Vc` has been downcast to `Vc<Box<dyn
...>>`. To solve for this, we perform a lookup of the
`VcCellMode::raw_cell` method using the type id (I added `raw_cell` in
#68467).

### Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
bgw added a commit that referenced this pull request Aug 5, 2024
…#68474)

*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8871

## Description

With these changes, local Vcs (introduced in #68469) should have a fully
functional implementation.

These remaining methods were pretty straightforward.

After this, my focus will shift back towards the changes needed to tasks
to allow us to make use of local Vcs.

## New `resolve_type_inner` helper method

I merged the implementations of `resolve_trait` and `resolve_value`,
since their implementations were 95% identical. I think this is an
overall win, though the logic to prevent duplicate `ValueType` lookups
(they're not expensive, but this code is also potentially very hot) is a
bit messy.

## Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 14, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 14, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8826

### Description

Builds on the minimal implementation of local Vcs in #68469

At some point, we need to return local Vcs or pass them to another
function as an argument. However, local Vcs are only valid within the
context of the current task.

The solution is that we need to convert local `Vc`s to non-local `Vc`s,
and the easiest way to do that is to `.resolve()` it!

This PR creates the new non-local cell on the current task, re-using the
SharedReference the was used for the local cell, along with it's type id
information.

`RawVc` lacks information about the compile-time type `T`. Even `Vc` may
know the real type of `T` if the `Vc` has been downcast to `Vc<Box<dyn
...>>`. To solve for this, we perform a lookup of the
`VcCellMode::raw_cell` method using the type id (I added `raw_cell` in
#68467).

### Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 14, 2024
…#68474)

*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8871

## Description

With these changes, local Vcs (introduced in #68469) should have a fully
functional implementation.

These remaining methods were pretty straightforward.

After this, my focus will shift back towards the changes needed to tasks
to allow us to make use of local Vcs.

## New `resolve_type_inner` helper method

I merged the implementations of `resolve_trait` and `resolve_value`,
since their implementations were 95% identical. I think this is an
overall win, though the logic to prevent duplicate `ValueType` lookups
(they're not expensive, but this code is also potentially very hot) is a
bit messy.

## Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 15, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 15, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8826

### Description

Builds on the minimal implementation of local Vcs in #68469

At some point, we need to return local Vcs or pass them to another
function as an argument. However, local Vcs are only valid within the
context of the current task.

The solution is that we need to convert local `Vc`s to non-local `Vc`s,
and the easiest way to do that is to `.resolve()` it!

This PR creates the new non-local cell on the current task, re-using the
SharedReference the was used for the local cell, along with it's type id
information.

`RawVc` lacks information about the compile-time type `T`. Even `Vc` may
know the real type of `T` if the `Vc` has been downcast to `Vc<Box<dyn
...>>`. To solve for this, we perform a lookup of the
`VcCellMode::raw_cell` method using the type id (I added `raw_cell` in
#68467).

### Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 15, 2024
…#68474)

*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8871

## Description

With these changes, local Vcs (introduced in #68469) should have a fully
functional implementation.

These remaining methods were pretty straightforward.

After this, my focus will shift back towards the changes needed to tasks
to allow us to make use of local Vcs.

## New `resolve_type_inner` helper method

I merged the implementations of `resolve_trait` and `resolve_value`,
since their implementations were 95% identical. I think this is an
overall win, though the logic to prevent duplicate `ValueType` lookups
(they're not expensive, but this code is also potentially very hot) is a
bit messy.

## Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 16, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 16, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8826

### Description

Builds on the minimal implementation of local Vcs in #68469

At some point, we need to return local Vcs or pass them to another
function as an argument. However, local Vcs are only valid within the
context of the current task.

The solution is that we need to convert local `Vc`s to non-local `Vc`s,
and the easiest way to do that is to `.resolve()` it!

This PR creates the new non-local cell on the current task, re-using the
SharedReference the was used for the local cell, along with it's type id
information.

`RawVc` lacks information about the compile-time type `T`. Even `Vc` may
know the real type of `T` if the `Vc` has been downcast to `Vc<Box<dyn
...>>`. To solve for this, we perform a lookup of the
`VcCellMode::raw_cell` method using the type id (I added `raw_cell` in
#68467).

### Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit that referenced this pull request Aug 16, 2024
…#68474)

*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8871

## Description

With these changes, local Vcs (introduced in #68469) should have a fully
functional implementation.

These remaining methods were pretty straightforward.

After this, my focus will shift back towards the changes needed to tasks
to allow us to make use of local Vcs.

## New `resolve_type_inner` helper method

I merged the implementations of `resolve_trait` and `resolve_value`,
since their implementations were 95% identical. I think this is an
overall win, though the logic to prevent duplicate `ValueType` lookups
(they're not expensive, but this code is also potentially very hot) is a
bit messy.

## Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Turbopack team PRs by the Turbopack team. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants