Skip to content

turbopack-240626.1

@bgw bgw tagged this 26 Jun 07:44
### Description

This might hurt us more than it helps. Hashbrown is based on the "swiss
table" data structure:
<https://abseil.io/about/design/swisstables#lookup-optimizations>

> For performance reasons, it is important that you use a hash function
that distributes entropy across the entire bit space well (producing an
avalanche effect).

In our case, ids are assigned sequentially, so the upper 7 bits (used by
[the secondary hash function called "H2"][H2]) are always zero.

[H2]:
https://github.com/rust-lang/hashbrown/blob/4c824c548e85d75f95e0dfcee09c62c5203f9a75/src/raw/mod.rs#L150-L157

### Testing Instructions

Benchmarks show this change to be performance neutral (and possibly an
improvement, but within noise thresholds).

```
cargo bench -p turbopack-cli
```

Using the low-noise physical benchmark host described here:
https://github.com/bgw/benchmark-scripts

**Before:**

```
bench_startup/Turbopack CSR/1000 modules
                        time:   [2.1116 s 2.1220 s 2.1333 s]

bench_hmr_to_eval/Turbopack CSR/1000 modules
                        time:   [16.797 ms 16.879 ms 17.009 ms]

bench_hmr_to_commit/Turbopack CSR/1000 modules
                        time:   [17.789 ms 17.844 ms 17.918 ms]
```

**After:**

```
bench_startup/Turbopack CSR/1000 modules
                        time:   [2.1070 s 2.1155 s 2.1243 s]
                        change: [-0.9610% -0.3059% +0.2959%] (p = 0.39 > 0.05)
                        No change in performance detected.

bench_hmr_to_eval/Turbopack CSR/1000 modules
                        time:   [16.459 ms 16.671 ms 16.924 ms]
                        change: [-3.3267% -1.3256% +0.4074%] (p = 0.21 > 0.05)
                        No change in performance detected.

bench_hmr_to_commit/Turbopack CSR/1000 modules
                        time:   [17.634 ms 17.794 ms 17.972 ms]
                        change: [-1.3115% -0.4446% +0.4699%] (p = 0.39 > 0.05)
                        No change in performance detected.
```
Assets 2
Loading