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

Add request deduplication to image optimizer #24000

Merged
merged 3 commits into from
Apr 12, 2021

Conversation

shuding
Copy link
Member

@shuding shuding commented Apr 12, 2021

This PR adds the deduplication logic to image optimizer so the cache will be reused as much as possible if there're multiple concurrent requests.

Fixes #23436.

Bug

  • Related issues linked using fixes #number
  • Integration tests added

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.

Documentation / Examples

  • Make sure the linting passes

@ijjk
Copy link
Member

ijjk commented Apr 12, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 11.5s 11.2s -307ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.3 kB
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.358 2.293 -0.06
/ avg req/sec 1060.32 1090.39 +30.07
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.283 1.182 -0.1
/error-in-render avg req/sec 1948.4 2114.6 +166.2
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
677f882d2ed8..e6c6.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.12 kB 7.12 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.2 kB 60.2 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-8fbabfc..6440.js gzip 1.28 kB 1.28 kB
_error-d07ca..ef4d.js gzip 3.71 kB 3.71 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-c31053f..c329.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.89 kB 8.89 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 371 B 371 B
Overall change 371 B 371 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 613 B 613 B
link.html gzip 620 B 620 B
withRouter.html gzip 607 B 607 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 13s 13.2s ⚠️ +243ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.3 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
677f882d2ed8..e6c6.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.12 kB 7.12 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.2 kB 60.2 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-8fbabfc..6440.js gzip 1.28 kB 1.28 kB
_error-d07ca..ef4d.js gzip 3.71 kB 3.71 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-c31053f..c329.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.89 kB 8.89 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 371 B 371 B
Overall change 371 B 371 B
Serverless bundles
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_error.js 1.37 MB 1.37 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.7 kB 10.7 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.37 MB 1.37 MB
link.js 1.42 MB 1.42 MB
routerDirect.js 1.42 MB 1.42 MB
withRouter.js 1.42 MB 1.42 MB
Overall change 7.01 MB 7.01 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 13.6s 13.3s -248ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.3 kB
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.374 2.325 -0.05
/ avg req/sec 1052.86 1075.27 +22.41
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.181 1.19 ⚠️ +0.01
/error-in-render avg req/sec 2115.97 2101.38 ⚠️ -14.59
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-f693fbd0..44d5.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 611 B 611 B
link.html gzip 616 B 616 B
withRouter.html gzip 605 B 605 B
Overall change 1.83 kB 1.83 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "frQouTukJ5xG3VkaGXeIj",
+        "buildId": "Ka2_c4tSkac4G-Heor6ju",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_buildManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_ssgManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "frQouTukJ5xG3VkaGXeIj",
+        "buildId": "Ka2_c4tSkac4G-Heor6ju",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_buildManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_ssgManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "frQouTukJ5xG3VkaGXeIj",
+        "buildId": "Ka2_c4tSkac4G-Heor6ju",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_buildManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/frQouTukJ5xG3VkaGXeIj/_ssgManifest.js"
+      src="/_next/static/Ka2_c4tSkac4G-Heor6ju/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 17bb196

@shuding shuding marked this pull request as ready for review April 12, 2021 18:02
expect(res2.headers.get('Content-Type')).toBe('image/webp')
await expectWidth(res1, w)
await expectWidth(res2, w)
})
Copy link
Member

Choose a reason for hiding this comment

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

Should we also check the cache folder to ensure only one entry was created here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed a change. Since we have many return statements in the optimizer (and itself can potentially throw), I wrapped it with try-finally. You can review with "Hide whitespace changes". 🙏

@ijjk
Copy link
Member

ijjk commented Apr 12, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 11.8s 12s ⚠️ +293ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.085 2.159 ⚠️ +0.07
/ avg req/sec 1199.2 1157.79 ⚠️ -41.41
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.099 1.089 -0.01
/error-in-render avg req/sec 2274.64 2296.44 +21.8
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 610 B 610 B
link.html gzip 617 B 617 B
withRouter.html gzip 605 B 605 B
Overall change 1.83 kB 1.83 kB

Serverless Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 15.1s 15.1s ⚠️ +3ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Serverless bundles Overall decrease ✓
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_error.js 1.35 MB 1.35 MB
404.html 2.76 kB 2.76 kB
500.html 2.75 kB 2.75 kB
amp.amp.html 10.7 kB 10.7 kB
amp.html 1.96 kB 1.96 kB
hooks.html 2.01 kB 2.01 kB
index.js 1.35 MB 1.35 MB
link.js 1.4 MB 1.4 MB
routerDirect.js 1.4 MB 1.4 MB -2 B
withRouter.js 1.4 MB 1.4 MB
Overall change 6.91 MB 6.91 MB -2 B

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 12s 11.9s -90ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.085 2.104 ⚠️ +0.02
/ avg req/sec 1199.15 1188.12 ⚠️ -11.03
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.082 1.058 -0.02
/error-in-render avg req/sec 2309.71 2362.67 +52.96
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 610 B 610 B
link.html gzip 617 B 617 B
withRouter.html gzip 605 B 605 B
Overall change 1.83 kB 1.83 kB

Diffs

Diff for index.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "Zpx7qdTp4UdrEh4D5WUL-",
+        "buildId": "_B-MxgHBNRuJ4mEk7oYxG",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_buildManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_ssgManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -53,7 +53,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "Zpx7qdTp4UdrEh4D5WUL-",
+        "buildId": "_B-MxgHBNRuJ4mEk7oYxG",
         "isFallback": false,
         "gip": true
       }
@@ -91,11 +91,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_buildManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_ssgManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "Zpx7qdTp4UdrEh4D5WUL-",
+        "buildId": "_B-MxgHBNRuJ4mEk7oYxG",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_buildManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/Zpx7qdTp4UdrEh4D5WUL-/_ssgManifest.js"
+      src="/_next/static/_B-MxgHBNRuJ4mEk7oYxG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 8f33102

@ijjk
Copy link
Member

ijjk commented Apr 12, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 14.4s 14.3s -75ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.489 2.457 -0.03
/ avg req/sec 1004.39 1017.5 +13.11
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.328 1.271 -0.06
/error-in-render avg req/sec 1883.16 1967.28 +84.12
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 610 B 610 B
link.html gzip 617 B 617 B
withRouter.html gzip 605 B 605 B
Overall change 1.83 kB 1.83 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 18.5s 18.8s ⚠️ +217ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Serverless bundles
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_error.js 1.35 MB 1.35 MB
404.html 2.76 kB 2.76 kB
500.html 2.75 kB 2.75 kB
amp.amp.html 10.7 kB 10.7 kB
amp.html 1.96 kB 1.96 kB
hooks.html 2.01 kB 2.01 kB
index.js 1.35 MB 1.35 MB
link.js 1.4 MB 1.4 MB
routerDirect.js 1.4 MB 1.4 MB
withRouter.js 1.4 MB 1.4 MB
Overall change 6.91 MB 6.91 MB

Webpack 5 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
buildDuration 14.7s 14.5s -196ms
nodeModulesSize 46.7 MB 46.7 MB ⚠️ +1.83 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
/ failed reqs 0 0
/ total time (seconds) 2.59 2.5 -0.09
/ avg req/sec 965.43 999.88 +34.45
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.309 1.341 ⚠️ +0.03
/error-in-render avg req/sec 1910.2 1864.18 ⚠️ -46.02
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
597-3f457946..288d.js gzip 13.3 kB 13.3 kB
778-6834d41c..48a9.js gzip 7.05 kB 7.05 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 151 B 151 B
webpack-HASH.js gzip 993 B 993 B
Overall change 60.8 kB 60.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_app-5cc66b2..6f03.js gzip 1.3 kB 1.3 kB
_error-55112..054d.js gzip 3.68 kB 3.68 kB
amp-89a5460c..567f.js gzip 558 B 558 B
hooks-8c2e74..be37.js gzip 924 B 924 B
index-fec729..83b2.js gzip 243 B 243 B
link-dd34d9b..0ade.js gzip 1.66 kB 1.66 kB
routerDirect..5759.js gzip 336 B 336 B
withRouter-1..98bf.js gzip 334 B 334 B
Overall change 9.03 kB 9.03 kB
Client Build Manifests
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
_buildManifest.js gzip 349 B 349 B
Overall change 349 B 349 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js fix-dedupe-next-image-requests Change
index.html gzip 610 B 610 B
link.html gzip 617 B 617 B
withRouter.html gzip 605 B 605 B
Overall change 1.83 kB 1.83 kB

Diffs

Diff for index.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "3vZ7AlWAGzNXp3UwlxKwl",
+        "buildId": "aVKgK6-MZjmylA4xVUUm1",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_buildManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_ssgManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -53,7 +53,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "3vZ7AlWAGzNXp3UwlxKwl",
+        "buildId": "aVKgK6-MZjmylA4xVUUm1",
         "isFallback": false,
         "gip": true
       }
@@ -91,11 +91,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_buildManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_ssgManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "3vZ7AlWAGzNXp3UwlxKwl",
+        "buildId": "aVKgK6-MZjmylA4xVUUm1",
         "isFallback": false,
         "gip": true
       }
@@ -86,11 +86,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_buildManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/3vZ7AlWAGzNXp3UwlxKwl/_ssgManifest.js"
+      src="/_next/static/aVKgK6-MZjmylA4xVUUm1/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: dce241b

@kodiakhq kodiakhq bot merged commit b610db8 into vercel:canary Apr 12, 2021
@shuding shuding deleted the fix-dedupe-next-image-requests branch April 13, 2021 06:20
@kmdev1
Copy link

kmdev1 commented Apr 13, 2021

Awesome work @shuding! Thank you very much for looking into this for us 🥳

@karlhorky
Copy link
Contributor

Thanks @shuding ! Will this be in 10.1.4?

@shuding
Copy link
Member Author

shuding commented Apr 13, 2021

This will be included in the next canary version (we will do a release today), as well as 10.1.4 eventually!

SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request Apr 20, 2021
This PR adds the deduplication logic to image optimizer so the cache will be reused as much as possible if there're multiple concurrent requests.

Fixes vercel#23436.

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition with Image Loader makes it unusable in a production environment
4 participants