Skip to content

Commit d1601a1

Browse files
authored
Turbopack: use xxhash3_128 for content hashes (vercel#90583)
Move to 128 bit hashes, so that we can include the untruncated hashes in the manifest in vercel#88607 If anything, this is faster, surprisingly: ``` upgrade twox-hash 448a36b pnpm next build --experimental-build-mode=compile 430.13s user, 73.72s system, 724% cpu, 1:09.53 total pnpm next build --experimental-build-mode=compile 430.05s user, 82.51s system, 736% cpu, 1:09.56 total pnpm next build --experimental-build-mode=compile 419.95s user, 89.50s system, 697% cpu, 1:13.03 total pnpm next build --experimental-build-mode=compile 425.95s user, 75.87s system, 748% cpu, 1:07.00 total use Xxh3Hash128Hex for content hashes ffd6a87 pnpm next build --experimental-build-mode=compile 397.42s user, 53.18s system, 670% cpu, 1:07.25 total pnpm next build --experimental-build-mode=compile 416.68s user, 66.32s system, 762% cpu, 1:03.32 total pnpm next build --experimental-build-mode=compile 412.63s user, 68.30s system, 774% cpu, 1:02.12 total pnpm next build --experimental-build-mode=compile 419.09s user, 68.57s system, 756% cpu, 1:04.50 total ``` https://github.com/Cyan4973/xxHash says: | Hash Name | Width | Bandwidth (GB/s) | Small Data Velocity | Quality | Comment | | --------- | ----- | ---------------- | ----- | --- | --- | | __XXH3__ (SSE2) | 64 | 31.5 GB/s | 133.1 | 10 | __XXH128__ (SSE2) | 128 | 29.6 GB/s | 118.1 | 10 | __XXH64__ | 64 | 19.4 GB/s | 71.0 | 10 | __XXH32__ | 32 | 9.7 GB/s | 71.9 | 10
1 parent 17033ca commit d1601a1

20 files changed

+37
-37
lines changed

test/e2e/app-dir/next-image/next-image-proxy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('next-image-proxy', () => {
8080

8181
if (process.env.IS_TURBOPACK_TEST) {
8282
expect(local).toMatchInlineSnapshot(
83-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=90"`
83+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=90"`
8484
)
8585
} else {
8686
expect(local).toMatchInlineSnapshot(

test/e2e/app-dir/next-image/next-image.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('app dir - next-image', () => {
5050

5151
if (process.env.IS_TURBOPACK_TEST) {
5252
expect(layout.attr('src')).toMatchInlineSnapshot(
53-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=85"`
53+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=85"`
5454
)
5555
} else {
5656
expect(layout.attr('src')).toMatchInlineSnapshot(
@@ -60,7 +60,7 @@ describe('app dir - next-image', () => {
6060

6161
if (process.env.IS_TURBOPACK_TEST) {
6262
expect(layout.attr('srcset')).toMatchInlineSnapshot(
63-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=85 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=85 2x"`
63+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=85 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=85 2x"`
6464
)
6565
} else {
6666
expect(layout.attr('srcset')).toMatchInlineSnapshot(
@@ -72,7 +72,7 @@ describe('app dir - next-image', () => {
7272

7373
if (process.env.IS_TURBOPACK_TEST) {
7474
expect(page.attr('src')).toMatchInlineSnapshot(
75-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=90"`
75+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=90"`
7676
)
7777
} else {
7878
expect(page.attr('src')).toMatchInlineSnapshot(
@@ -82,7 +82,7 @@ describe('app dir - next-image', () => {
8282

8383
if (process.env.IS_TURBOPACK_TEST) {
8484
expect(page.attr('srcset')).toMatchInlineSnapshot(
85-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=90 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=90 2x"`
85+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=90 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=90 2x"`
8686
)
8787
} else {
8888
expect(page.attr('srcset')).toMatchInlineSnapshot(
@@ -94,7 +94,7 @@ describe('app dir - next-image', () => {
9494

9595
if (process.env.IS_TURBOPACK_TEST) {
9696
expect(comp.attr('src')).toMatchInlineSnapshot(
97-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=80"`
97+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=80"`
9898
)
9999
} else {
100100
expect(comp.attr('src')).toMatchInlineSnapshot(
@@ -104,7 +104,7 @@ describe('app dir - next-image', () => {
104104

105105
if (process.env.IS_TURBOPACK_TEST) {
106106
expect(comp.attr('srcset')).toMatchInlineSnapshot(
107-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=80 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=80 2x"`
107+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=80 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=80 2x"`
108108
)
109109
} else {
110110
expect(comp.attr('srcset')).toMatchInlineSnapshot(
@@ -194,7 +194,7 @@ describe('app dir - next-image', () => {
194194

195195
if (process.env.IS_TURBOPACK_TEST) {
196196
expect(await layout.getAttribute('src')).toMatchInlineSnapshot(
197-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=85"`
197+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=85"`
198198
)
199199
} else {
200200
expect(await layout.getAttribute('src')).toMatchInlineSnapshot(
@@ -204,7 +204,7 @@ describe('app dir - next-image', () => {
204204

205205
if (process.env.IS_TURBOPACK_TEST) {
206206
expect(await layout.getAttribute('srcset')).toMatchInlineSnapshot(
207-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=85 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=85 2x"`
207+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=85 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=85 2x"`
208208
)
209209
} else {
210210
expect(await layout.getAttribute('srcset')).toMatchInlineSnapshot(
@@ -216,7 +216,7 @@ describe('app dir - next-image', () => {
216216

217217
if (process.env.IS_TURBOPACK_TEST) {
218218
expect(await page.getAttribute('src')).toMatchInlineSnapshot(
219-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=90"`
219+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=90"`
220220
)
221221
} else {
222222
expect(await page.getAttribute('src')).toMatchInlineSnapshot(
@@ -226,7 +226,7 @@ describe('app dir - next-image', () => {
226226

227227
if (process.env.IS_TURBOPACK_TEST) {
228228
expect(await page.getAttribute('srcset')).toMatchInlineSnapshot(
229-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=90 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=90 2x"`
229+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=90 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=90 2x"`
230230
)
231231
} else {
232232
expect(await page.getAttribute('srcset')).toMatchInlineSnapshot(
@@ -238,7 +238,7 @@ describe('app dir - next-image', () => {
238238

239239
if (process.env.IS_TURBOPACK_TEST) {
240240
expect(await comp.getAttribute('src')).toMatchInlineSnapshot(
241-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=80"`
241+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=80"`
242242
)
243243
} else {
244244
expect(await comp.getAttribute('src')).toMatchInlineSnapshot(
@@ -248,7 +248,7 @@ describe('app dir - next-image', () => {
248248

249249
if (process.env.IS_TURBOPACK_TEST) {
250250
expect(await comp.getAttribute('srcset')).toMatchInlineSnapshot(
251-
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=640&q=80 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.55df2443.png&w=828&q=80 2x"`
251+
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=640&q=80 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.c5ae911e.png&w=828&q=80 2x"`
252252
)
253253
} else {
254254
expect(await comp.getAttribute('srcset')).toMatchInlineSnapshot(

test/integration/css/test/basic-global-support.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,17 +564,17 @@ module.exports = {
564564
expect(cssContent).toMatchInlineSnapshot(`
565565
[
566566
"/_next/static/chunks/HASH.css:
567-
.red-text{color:red;background-image:url(../media/dark.656fe8ee.svg),url(../media/dark2.656fe8ee.svg)}
568-
.blue-text{color:orange;background-image:url(../media/light.750c956a.svg);font-weight:bolder}
567+
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg),url(../media/dark2.3ca0d560.svg)}
568+
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder}
569569
.blue-text{color:#00f}",
570570
]
571571
`)
572572
} else if (process.env.IS_TURBOPACK_TEST && !useLightningcss) {
573573
expect(cssContent).toMatchInlineSnapshot(`
574574
[
575575
"/_next/static/chunks/HASH.css:
576-
.red-text{color:red;background-image:url(../media/dark.656fe8ee.svg),url(../media/dark2.656fe8ee.svg)}
577-
.blue-text{color:orange;background-image:url(../media/light.750c956a.svg);font-weight:bolder}
576+
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg),url(../media/dark2.3ca0d560.svg)}
577+
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder}
578578
.blue-text{color:#00f}",
579579
]
580580
`)
@@ -640,8 +640,8 @@ describe('CSS URL via `file-loader` and asset prefix (1)', () => {
640640
expect(cssContent).toMatchInlineSnapshot(`
641641
[
642642
"/_next/static/chunks/HASH.css:
643-
.red-text{color:red;background-image:url(../media/dark.656fe8ee.svg) url(../media/dark2.656fe8ee.svg)}
644-
.blue-text{color:orange;background-image:url(../media/light.750c956a.svg);font-weight:bolder}
643+
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg) url(../media/dark2.3ca0d560.svg)}
644+
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder}
645645
.blue-text{color:#00f}",
646646
]
647647
`)
@@ -692,8 +692,8 @@ describe('CSS URL via `file-loader` and asset prefix (2)', () => {
692692
expect(cssContent).toMatchInlineSnapshot(`
693693
[
694694
"/_next/static/chunks/HASH.css:
695-
.red-text{color:red;background-image:url(../media/dark.656fe8ee.svg) url(../media/dark2.656fe8ee.svg)}
696-
.blue-text{color:orange;background-image:url(../media/light.750c956a.svg);font-weight:bolder}
695+
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg) url(../media/dark2.3ca0d560.svg)}
696+
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder}
697697
.blue-text{color:#00f}",
698698
]
699699
`)

turbopack/crates/turbopack-browser/src/chunking_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl ChunkingContext for BrowserChunkingContext {
579579
};
580580
let hash = asset
581581
.content()
582-
.content_hash(HashAlgorithm::default())
582+
.content_hash(HashAlgorithm::Xxh3Hash128Hex)
583583
.await?;
584584
let hash = hash.as_ref().context(
585585
"chunk_path requires an asset with file content when content hashing is \

turbopack/crates/turbopack-core/src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl FileHashVersion {
234234
match asset_content {
235235
AssetContent::File(file_vc) => {
236236
let hash = file_vc
237-
.content_hash(HashAlgorithm::default())
237+
.content_hash(HashAlgorithm::Xxh3Hash128Hex)
238238
.owned()
239239
.await?
240240
.context("file not found")?;

turbopack/crates/turbopack-static/src/output_asset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl OutputAsset for StaticOutputAsset {
4141
async fn path(&self) -> Result<Vc<FileSystemPath>> {
4242
let content = self.source.content();
4343
let content_hash = content
44-
.content_hash(HashAlgorithm::default())
44+
.content_hash(HashAlgorithm::Xxh3Hash128Hex)
4545
.owned()
4646
.await?
4747
.context(

turbopack/crates/turbopack-tests/tests/snapshot/css/embed-url/output/turbopack_crates_turbopack-tests_tests_snapshot_css_embed-url_input_6213f966._.css

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbopack/crates/turbopack-tests/tests/snapshot/css/embed-url/static/image.7bbaf41b.png renamed to turbopack/crates/turbopack-tests/tests/snapshot/css/embed-url/static/image.de249277.png

File renamed without changes.

turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_url_input_3fece31c._.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/static/asset.6fdf3006.txt renamed to turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/static/asset.76d5cf5c.txt

File renamed without changes.

0 commit comments

Comments
 (0)