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

perf(turbo-tasks): Call .shrink_to_fit() on common collection types when constructing a cell #72113

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

bgw
Copy link
Member

@bgw bgw commented Oct 30, 2024

Cell contents are immutable once constructed, so there's no chance that they'll grow in size again. Common collections can be shrunk to avoid storing empty spare capacity in this case (note: if they're already correctly sized, shrink_to_fit bails out early).

Result: This gives a ~1.4% decrease in top-line peak memory consumption, for a theoretical CPU/Wall time cost that's too small to measure.

Inspiration: The inspiration for this was vercel/turborepo#2873, which decreased task storage (not the top-line memory usage?) by ~14%, vercel/turborepo#8657, and other similar optimization PRs.

Additional Opportunities

  • There may be more places where cell are constructed (e.g. persistent storage deserialization) where a cell's SharedReference is constructed that is not currently captured by this.

    • Depending on the library used, deserialization may already construct exact-sized collections.
    • As an additional example, manually constructing a ReadRef and converting it into a cell skips this optimization because ReadRef::cell internally uses the type-erased shared-reference raw_cell API which is incompatible with this optimization. We could special-case that in the ReadRef::new_owned constructor (not in ReadRef::new_arc though), but nobody should be manually constructing ReadRefs.
  • We still don't use shrink_to_fit on RcStr types. Some of these are in-place extended (when they have a refcount of 1) with RcStr::map, so we probably don't want to be too aggressive about this to avoid O(n^2) time complexity blowups.

Memory Benchmark Setup

cd ~/next.js
cargo run -p next-build-test --release -- generate ~/shadcn-ui/apps/www/ > ~/shadcn-ui/apps/www/project_options.json
pnpm pack-next --project ~/shadcn-ui/apps/www/
cd ~/shadcn-ui
pnpm i
cd ~/shadcn-ui/apps/www/
heaptrack ~/next.js/target/release/next-build-test run sequential 1 1 '/sink'
heaptrack --analyze ~/shadcn-ui/apps/www/heaptrack.next-build-test.3604648.zst

Memory Before (canary branch)

First Run:

peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G

Second Run:

peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G

Memory After (this PR)

First Run:

peak heap memory consumption: 3.18G
peak RSS (including heaptrack overhead): 4.74G

Second Run:

peak heap memory consumption: 3.19G
peak RSS (including heaptrack overhead): 4.73G

This is about a 1.4% decrease in top-line memory consumption.

Wall Time with hyperfine (Counter-Metric)

This is theoretically a time-memory tradeoff, as we'll spend some time memcpying things into smaller allocations, though in some cases reducing memory usage can improve cache locality, so it's not always obvious.

hyperfine --warmup 3 -r 30 --time-unit millisecond '~/next.js/target/release/next-build-test run sequential 1 1 /sink'

This benchmark is slow and takes about 30 minutes to run.

Before:

Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56387.5 ms ± 212.6 ms    [User: 107807.5 ms, System: 9509.8 ms]
  Range (min … max):   55934.4 ms … 56872.9 ms    30 runs

After:

Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56020.9 ms ± 235.4 ms    [User: 107483.8 ms, System: 9371.8 ms]
  Range (min … max):   55478.2 ms … 56563.6 ms    30 runs

This is a ~0.65% reduction in wall time. This is small enough (<2 standard deviations) to likely just be noise.

Wall Time with turbopack-bench (Counter-Metric)

cargo bench -p turbopack-bench -p turbopack-cli -- "hmr_to_eval/Turbopack CSR"

Gives:

bench_hmr_to_eval/Turbopack CSR/1000 modules
                        time:   [15.123 ms 15.208 ms 15.343 ms]
                        change: [-0.8471% +0.4882% +1.9719%] (p = 0.55 > 0.05)
                        No change in performance detected.

Using https://github.com/bgw/benchmark-scripts/

In practice, it's not really possible to measure changes in wall time <1%, so this is within "noise" territory (as noted in the criterion output).

Closes PACK-3361

@ijjk ijjk added the created-by: Turbopack team PRs by the Turbopack team. label Oct 30, 2024
Copy link
Member Author

bgw commented Oct 30, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bgw and the rest of your teammates on Graphite Graphite

@ijjk
Copy link
Member

ijjk commented Oct 31, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
buildDuration 20.3s 17.3s N/A
buildDurationCached 16.5s 14.6s N/A
nodeModulesSize 403 MB 403 MB
nextStartRea..uration (ms) 471ms 473ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
4673-HASH.js gzip 45.4 kB 45.3 kB N/A
8760.HASH.js gzip 169 B 170 B N/A
9684-HASH.js gzip 5.27 kB 5.27 kB N/A
9d9f3bb1-HASH.js gzip 52.5 kB 52.5 kB N/A
framework-HASH.js gzip 57.3 kB 57.3 kB
main-app-HASH.js gzip 234 B 234 B
main-HASH.js gzip 33.1 kB 33.1 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB
Overall change 59.3 kB 59.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 192 B 191 B N/A
amp-HASH.js gzip 512 B 511 B N/A
css-HASH.js gzip 342 B 342 B
dynamic-HASH.js gzip 1.84 kB 1.84 kB N/A
edge-ssr-HASH.js gzip 265 B 265 B
head-HASH.js gzip 365 B 362 B N/A
hooks-HASH.js gzip 393 B 389 B N/A
image-HASH.js gzip 4.41 kB 4.41 kB N/A
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.78 kB 2.78 kB N/A
routerDirect..HASH.js gzip 327 B 329 B N/A
script-HASH.js gzip 397 B 397 B
withRouter-HASH.js gzip 323 B 325 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.57 kB 1.57 kB
Client Build Manifests
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
_buildManifest.js gzip 747 B 745 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
index.html gzip 523 B 521 B N/A
link.html gzip 536 B 537 B N/A
withRouter.html gzip 518 B 519 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
edge-ssr.js gzip 128 kB 128 kB N/A
page.js gzip 189 kB 189 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
middleware-b..fest.js gzip 669 B 667 B N/A
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 31 kB 31 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 1 kB 1 kB
Next Runtimes
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
973-experime...dev.js gzip 322 B 322 B
973.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 318 kB 318 kB
app-page-exp..prod.js gzip 122 kB 122 kB
app-page-tur..prod.js gzip 135 kB 135 kB
app-page-tur..prod.js gzip 130 kB 130 kB
app-page.run...dev.js gzip 309 kB 309 kB
app-page.run..prod.js gzip 118 kB 118 kB
app-route-ex...dev.js gzip 35.9 kB 35.9 kB
app-route-ex..prod.js gzip 24.4 kB 24.4 kB
app-route-tu..prod.js gzip 24.4 kB 24.4 kB
app-route-tu..prod.js gzip 24.2 kB 24.2 kB
app-route.ru...dev.js gzip 37.5 kB 37.5 kB
app-route.ru..prod.js gzip 24.2 kB 24.2 kB
pages-api-tu..prod.js gzip 9.61 kB 9.61 kB
pages-api.ru...dev.js gzip 11.4 kB 11.4 kB
pages-api.ru..prod.js gzip 9.61 kB 9.61 kB
pages-turbo...prod.js gzip 20.9 kB 20.9 kB
pages.runtim...dev.js gzip 26.5 kB 26.5 kB
pages.runtim..prod.js gzip 20.9 kB 20.9 kB
server.runti..prod.js gzip 914 kB 914 kB
Overall change 2.32 MB 2.32 MB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js bgw/cell-shrink-to-fit Change
0.pack gzip 1.85 MB 1.86 MB ⚠️ +4.51 kB
index.pack gzip 143 kB 144 kB ⚠️ +304 B
Overall change 2 MB 2 MB ⚠️ +4.82 kB
Diff details
Diff for page.js
@@ -15,7 +15,7 @@
       /***/
     },
 
-    /***/ 15: /***/ (
+    /***/ 9193: /***/ (
       __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-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.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-statsxH5FAO%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-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.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-statsxH5FAO%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, {
@@ -82,35 +82,35 @@
         workUnitAsyncStorage: () => entry_base /* workUnitAsyncStorage */.Sz,
       });
 
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/web/globals.js
-      var globals = __webpack_require__(3964);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/web/adapter.js + 3 modules
-      var adapter = __webpack_require__(5699);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js + 86 modules
-      var render = __webpack_require__(7101);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/lib/incremental-cache/index.js + 5 modules
-      var incremental_cache = __webpack_require__(9751);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/app-render/app-render.js + 63 modules
-      var app_render = __webpack_require__(5232);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/route-modules/app-page/module.compiled.js
-      var module_compiled = __webpack_require__(2977);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/route-kind.js
-      var route_kind = __webpack_require__(3494);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/client/components/error-boundary.js
-      var error_boundary = __webpack_require__(7206);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/app-render/entry-base.js + 23 modules
-      var entry_base = __webpack_require__(8862); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.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-statsxH5FAO%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-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/web/globals.js
+      var globals = __webpack_require__(159);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/web/adapter.js + 3 modules
+      var adapter = __webpack_require__(5043);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render.js + 86 modules
+      var render = __webpack_require__(2837);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/lib/incremental-cache/index.js + 5 modules
+      var incremental_cache = __webpack_require__(7652);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/app-render/app-render.js + 63 modules
+      var app_render = __webpack_require__(1778);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/route-modules/app-page/module.compiled.js
+      var module_compiled = __webpack_require__(3774);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/route-kind.js
+      var route_kind = __webpack_require__(5318);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/client/components/error-boundary.js
+      var error_boundary = __webpack_require__(28);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/app-render/entry-base.js + 23 modules
+      var entry_base = __webpack_require__(7011); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.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-statsxH5FAO%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 module0 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 6719)
+          __webpack_require__.bind(__webpack_require__, 1187)
         );
       const module1 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 2552)
+          __webpack_require__.bind(__webpack_require__, 408)
         );
       const page2 = () =>
         Promise.resolve(/* import() eager */).then(
-          __webpack_require__.bind(__webpack_require__, 5312)
+          __webpack_require__.bind(__webpack_require__, 2344)
         );
 
       // We inject the tree and pages here so that we can use them in the route
@@ -173,12 +173,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-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/lib/page-types.js
-      var page_types = __webpack_require__(8198);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/app-render/encryption-utils.js
-      var encryption_utils = __webpack_require__(7128);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/dist/esm/server/app-render/action-utils.js
-      var action_utils = __webpack_require__(8219); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/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":"eyJlbnYiOnt9LCJlc2xpbnQiOnsiaWdub3JlRHVyaW5nQnVpbGRzIjpmYWxzZX0sInR5cGVzY3JpcHQiOnsiaWdub3JlQnVpbGRFcnJvcnMiOmZhbHNlLCJ0c2NvbmZpZ1BhdGgiOiJ0c2NvbmZpZy5qc29uIn0sImRpc3REaXIiOiIubmV4dCIsImNsZWFuRGlzdERpciI6dHJ1ZSwiYXNzZXRQcmVmaXgiOiIiLCJjYWNoZU1heE1lbW9yeVNpemUiOjUyNDI4ODAwLCJjb25maWdPcmlnaW4iOiJuZXh0LmNvbmZpZy5qcyIsInVzZUZpbGVTeXN0ZW1QdWJsaWNSb3V0ZXMiOnRydWUs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NzciUyRnBhZ2UmcGFnZUV4dGVuc2lvbnM9dHN4JnBhZ2VFeHRlbnNpb25zPXRzJnBhZ2VFeHRlbnNpb25zPWpzeCZwYWdlRXh0ZW5zaW9ucz1qcyZiYXNlUGF0aD0mYXNzZXRQcmVmaXg9Jm5leHRDb25maWdPdXRwdXQ9JmZseWluZ1NodXR0bGU9ZmFsc2UmcHJlZmVycmVkUmVnaW9uPSZtaWRkbGV3YXJlQ29uZmlnPWUzMCUzRCE=","sriEnabled":false,"middlewareConfig":"e30=","cacheHandlers":"{}"}!
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/lib/page-types.js
+      var page_types = __webpack_require__(7681);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/app-render/encryption-utils.js
+      var encryption_utils = __webpack_require__(4277);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/dist/esm/server/app-render/action-utils.js
+      var action_utils = __webpack_require__(5786); // CONCATENATED MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/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":"ey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QuY29uZmlnLmpzIiwiY29uZmlnRmlsZU5hbWUiOiJuZXh0LmNvbmZpZy5qcyJ9","pagesType":"app","appDirLoader":"bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBwLWVkZ2Utc3NyJTJGcGFnZSZwYWdlPSUyRmFwcC1lZGdlLXNzciUyRnBhZ2UmcGFnZVBhdGg9cHJpdmF0ZS1uZXh0LWFwcC1kaXIlMkZhcHAtZWRnZS1zc3IlMkZwYWdlLmpzJmFwcERpcj0lMkZ0bXAlMkZuZXh0LXN0YXRzeEg1RkFPJTJGc3RhdHMtYXBwJTJGYXBwJmFwcFBhdGhzPSUyRmFwcC1lZGdlLXNzciUyRnBhZ2UmcGFnZUV4dGVuc2lvbnM9dHN4JnBhZ2VFeHRlbnNpb25zPXRzJnBhZ2VFeHRlbnNpb25zPWpzeCZwYWdlRXh0ZW5zaW9ucz1qcyZiYXNlUGF0aD0mYXNzZXRQcmVmaXg9Jm5leHRDb25maWdPdXRwdXQ9JmZseWluZ1NodXR0bGU9ZmFsc2UmcHJlZmVycmVkUmVnaW9uPSZtaWRkbGV3YXJlQ29uZmlnPWUzMCUzRCE=","sriEnabled":false,"middlewareConfig":"e30=","cacheHandlers":"{}"}!
       var _self___RSC_MANIFEST;
 
       const incrementalCacheHandler = null;
@@ -460,105 +460,105 @@
       /***/
     },
 
-    /***/ 1765: /***/ (
+    /***/ 8223: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 6158)
+        __webpack_require__.bind(__webpack_require__, 1974)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 5713)
+        __webpack_require__.bind(__webpack_require__, 8366)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 786)
+        __webpack_require__.bind(__webpack_require__, 5350)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7206)
+        __webpack_require__.bind(__webpack_require__, 28)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1122)
+        __webpack_require__.bind(__webpack_require__, 4742)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1641)
+        __webpack_require__.bind(__webpack_require__, 6261)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7817)
+        __webpack_require__.bind(__webpack_require__, 3956)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7251)
+        __webpack_require__.bind(__webpack_require__, 5267)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 289)
+        __webpack_require__.bind(__webpack_require__, 5698)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 8527)
+        __webpack_require__.bind(__webpack_require__, 1885)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 8016)
+        __webpack_require__.bind(__webpack_require__, 7470)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 3773)
+        __webpack_require__.bind(__webpack_require__, 6879)
       );
 
       /***/
     },
 
-    /***/ 2240: /***/ (
+    /***/ 5204: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 9550)
+        __webpack_require__.bind(__webpack_require__, 848)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 9667)
+        __webpack_require__.bind(__webpack_require__, 9491)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 8548)
+        __webpack_require__.bind(__webpack_require__, 5499)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 9549)
+        __webpack_require__.bind(__webpack_require__, 8213)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1629)
+        __webpack_require__.bind(__webpack_require__, 120)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 5202)
+        __webpack_require__.bind(__webpack_require__, 7194)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 7830)
+        __webpack_require__.bind(__webpack_require__, 2567)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 4776)
+        __webpack_require__.bind(__webpack_require__, 4009)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 52)
+        __webpack_require__.bind(__webpack_require__, 3209)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 2118)
+        __webpack_require__.bind(__webpack_require__, 7619)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 2894)
+        __webpack_require__.bind(__webpack_require__, 6417)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 253)
+        __webpack_require__.bind(__webpack_require__, 72)
       );
 
       /***/
     },
 
-    /***/ 2180: /***/ () => {
+    /***/ 4408: /***/ () => {
       /***/
     },
 
-    /***/ 8944: /***/ () => {
+    /***/ 3278: /***/ () => {
       /***/
     },
 
-    /***/ 5312: /***/ (
+    /***/ 2344: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -578,7 +578,7 @@
       /***/
     },
 
-    /***/ 6719: /***/ (
+    /***/ 1187: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -590,7 +590,7 @@
         /* harmony export */
       });
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
-        __webpack_require__(1220);
+        __webpack_require__(5391);
 
       function RootLayout({ children }) {
         return /*#__PURE__*/ (0,
@@ -609,7 +609,7 @@
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
-    /******/ __webpack_require__.O(0, [85, 619], () => __webpack_exec__(15));
+    /******/ __webpack_require__.O(0, [145, 212], () => __webpack_exec__(9193));
     /******/ 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],
   {
-    /***/ 8672: /***/ (
+    /***/ 7631: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(4462);
+          return __webpack_require__(4037);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 4515: /***/ (module, exports, __webpack_require__) => {
+    /***/ 1041: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,17 +40,17 @@
         __webpack_require__(3651)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2336)
+        __webpack_require__(6947)
       );
-      const _getimgprops = __webpack_require__(7648);
-      const _imageconfig = __webpack_require__(8572);
-      const _imageconfigcontextsharedruntime = __webpack_require__(8277);
-      const _warnonce = __webpack_require__(9598);
-      const _routercontextsharedruntime = __webpack_require__(2366);
+      const _getimgprops = __webpack_require__(2736);
+      const _imageconfig = __webpack_require__(3066);
+      const _imageconfigcontextsharedruntime = __webpack_require__(8498);
+      const _warnonce = __webpack_require__(8553);
+      const _routercontextsharedruntime = __webpack_require__(54);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2625)
+        __webpack_require__(4599)
       );
-      const _usemergedref = __webpack_require__(7603);
+      const _usemergedref = __webpack_require__(3027);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 7603: /***/ (module, exports, __webpack_require__) => {
+    /***/ 3027: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -432,7 +432,7 @@
       /***/
     },
 
-    /***/ 7648: /***/ (
+    /***/ 2736: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -448,9 +448,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(9598);
-      const _imageblursvg = __webpack_require__(6541);
-      const _imageconfig = __webpack_require__(8572);
+      const _warnonce = __webpack_require__(8553);
+      const _imageblursvg = __webpack_require__(8684);
+      const _imageconfig = __webpack_require__(3066);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -824,7 +824,7 @@
       /***/
     },
 
-    /***/ 6541: /***/ (__unused_webpack_module, exports) => {
+    /***/ 8684: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -879,7 +879,7 @@
       /***/
     },
 
-    /***/ 6911: /***/ (
+    /***/ 2383: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -906,10 +906,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(9608);
-      const _getimgprops = __webpack_require__(7648);
-      const _imagecomponent = __webpack_require__(4515);
+      const _getimgprops = __webpack_require__(2736);
+      const _imagecomponent = __webpack_require__(1041);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2625)
+        __webpack_require__(4599)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -941,7 +941,7 @@
       /***/
     },
 
-    /***/ 2625: /***/ (__unused_webpack_module, exports) => {
+    /***/ 4599: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -976,7 +976,7 @@
       /***/
     },
 
-    /***/ 4462: /***/ (
+    /***/ 4037: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -993,8 +993,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(6091);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_hkctxqey4uoasz5bdrxodeqyxe/node_modules/next/image.js
-      var next_image = __webpack_require__(9306);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-603e6108-20241029_re_3hkrdvzmhg3z5hqggw7xkpavcq/node_modules/next/image.js
+      var next_image = __webpack_require__(1148);
       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",
@@ -1024,12 +1024,12 @@
       /***/
     },
 
-    /***/ 9306: /***/ (
+    /***/ 1148: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(6911);
+      module.exports = __webpack_require__(2383);
 
       /***/
     },
@@ -1039,7 +1039,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
-      __webpack_exec__(8672)
+      __webpack_exec__(7631)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for main-HASH.js

Diff too large to display

Commit: 1533a66

@bgw bgw requested review from arlyon, sokra and kdy1 October 31, 2024 21:11
@bgw bgw marked this pull request as ready for review October 31, 2024 21:11
@ijjk
Copy link
Member

ijjk commented Oct 31, 2024

Tests Passed

@@ -0,0 +1 @@
../../turbo-tasks-testing/tests/shrink_to_fit.rs
Copy link
Member

Choose a reason for hiding this comment

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

Is this file symlink? Asking because GitHub shows it strangely

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is a symlink.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

LGTM, except the symlink. I'm not sure if symlink will work well with Windows git.
AFAIK, symlinking on Windows required a specific permission, but for most users it's not straightforward to enable it for the main user because the permission cannot be granted to administrator account while the first account configured while installing OS is an administrator account

Copy link
Member Author

bgw commented Nov 1, 2024

@sokra adopted this symlink pattern for tests that we share between the memory and persistent backends. I'm just continuing it here, so I'm not going to block this PR on it.

It does look like you're right that symlinks can be a pain-point on Windows git, and there are permissions issues, but it seems like they're not too bad on modern Windows? ("Developer Mode" does the required things)
https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201#59761201

We could try some alternative approach to sharing tests, but I think the goal is to remove the memory backend once the persistent backend is stable (and just optionally run it without a database+serialization for the in-memory usecase). At that point we won't need to share the tests anymore.

@bgw bgw merged commit 5d3bc2b into canary Nov 1, 2024
113 checks passed
@bgw bgw deleted the bgw/cell-shrink-to-fit branch November 1, 2024 20:23
stipsan pushed a commit to sanity-io/next.js that referenced this pull request Nov 6, 2024
… when constructing a cell (vercel#72113)

Cell contents are immutable once constructed, so there's no chance that they'll grow in size again. Common collections can be shrunk to avoid storing empty spare capacity in this case (note: if they're already correctly sized, `shrink_to_fit` bails out early).

**Result:** This gives a ~1.4% decrease in top-line peak memory consumption, for a theoretical CPU/Wall time cost that's too small to measure.

**Inspiration:** The inspiration for this was vercel/turborepo#2873, which decreased task storage (not the top-line memory usage?) by ~14%, vercel/turborepo#8657, and other similar optimization PRs.

## Additional Opportunities

- There may be more places where cell are constructed (e.g. persistent storage deserialization) where a cell's `SharedReference` is constructed that is not currently captured by this.
  - Depending on the library used, deserialization may already construct exact-sized collections.
  - As an additional example, manually constructing a `ReadRef` and converting it into a cell skips this optimization because `ReadRef::cell` internally uses the type-erased shared-reference `raw_cell` API which is incompatible with this optimization. We could special-case that in the `ReadRef::new_owned` constructor (not in `ReadRef::new_arc` though), but nobody should be manually constructing `ReadRef`s.

- We still don't use `shrink_to_fit` on `RcStr` types. Some of these are in-place extended (when they have a refcount of 1) with `RcStr::map`, so we probably don't want to be too aggressive about this to avoid `O(n^2)` time complexity blowups.

## Memory Benchmark Setup

```bash
cd ~/next.js
cargo run -p next-build-test --release -- generate ~/shadcn-ui/apps/www/ > ~/shadcn-ui/apps/www/project_options.json
pnpm pack-next --project ~/shadcn-ui/apps/www/
```

```bash
cd ~/shadcn-ui
pnpm i
cd ~/shadcn-ui/apps/www/
heaptrack ~/next.js/target/release/next-build-test run sequential 1 1 '/sink'
heaptrack --analyze ~/shadcn-ui/apps/www/heaptrack.next-build-test.3604648.zst
```

### Memory Before (canary branch)

First Run:

```
peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G
```

Second Run:

```
peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G
```

### Memory After (this PR)

First Run:

```
peak heap memory consumption: 3.18G
peak RSS (including heaptrack overhead): 4.74G
```

Second Run:

```
peak heap memory consumption: 3.19G
peak RSS (including heaptrack overhead): 4.73G
```

This is about a 1.4% decrease in top-line memory consumption.

## Wall Time with `hyperfine` (Counter-Metric)

This is theoretically a time-memory tradeoff, as we'll spend some time `memcpy`ing things into smaller allocations, though in some cases reducing memory usage can improve cache locality, so it's not always obvious.

```
hyperfine --warmup 3 -r 30 --time-unit millisecond '~/next.js/target/release/next-build-test run sequential 1 1 /sink'
```

This benchmark is slow and takes about 30 minutes to run.

Before:

```
Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56387.5 ms ± 212.6 ms    [User: 107807.5 ms, System: 9509.8 ms]
  Range (min … max):   55934.4 ms … 56872.9 ms    30 runs
```

After:

```
Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56020.9 ms ± 235.4 ms    [User: 107483.8 ms, System: 9371.8 ms]
  Range (min … max):   55478.2 ms … 56563.6 ms    30 runs
```

This is a ~0.65% *reduction* in wall time. This is small enough (<2 standard deviations) to likely just be noise.

## Wall Time with `turbopack-bench` (Counter-Metric)

```
cargo bench -p turbopack-bench -p turbopack-cli -- "hmr_to_eval/Turbopack CSR"
```

Gives:

```
bench_hmr_to_eval/Turbopack CSR/1000 modules
                        time:   [15.123 ms 15.208 ms 15.343 ms]
                        change: [-0.8471% +0.4882% +1.9719%] (p = 0.55 > 0.05)
                        No change in performance detected.
```

Using https://github.com/bgw/benchmark-scripts/

In practice, it's not really possible to measure changes in wall time <1%, so this is within "noise" territory (as noted in the criterion output).

Closes PACK-3361
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 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