Commit dbced22
committed
turbo-tasks: shard task_cache the same as storage.map
`task_cache: FxDashMap::default()` falls through to dashmap's default shard
amount of `num_cpus * 4` (e.g. 64 shards on a 14-core machine), while
`storage.map` uses our `compute_shard_amount` heuristic which is quadratic
in worker count for a target ~3% collision probability (e.g. 4096 shards
on the same machine).
The 64× mismatch made `task_cache` lookups self-contend on every cache hit
even when `storage.map` accesses were uncontended. Profiles attributed
~10% of overhead samples to `dashmap::lock_exclusive_slow` on
`task_cache`'s shards, which is implausible for a properly sharded map at
this thread count.
Use `with_capacity_and_hasher_and_shard_amount` on `task_cache` with the
same `shard_amount` we already pass to `Storage::new`.1 parent e2e1d4f commit dbced22
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
243 | 251 | | |
244 | 252 | | |
245 | 253 | | |
| |||
0 commit comments