Files
next.js/turbopack/crates/turbo-tasks-testing/Cargo.toml
Tobias KoppersandGitHub 7ec952836d Turbopack: add support for selective reads of keyed cell values (#88303)
### What?

Previously cells could either be unchanged or changed. This falls short when updating Maps or Sets.
We can't have a dependency on a single key of a map or set.
The workaround for this was to create an "selector" turbo-tasks which picks the value and copies it into a new cell.
This allows more granular invalidation.

But it also creates a lot of extra tasks. And changing the map/set does invalidate all these selector tasks, which causes a lot of invalidation work.

This change adds support for dependencies on certain keys of cells.

On write side a turbo-tasks value need to opt-in into that behavior via `cell = "keyed"`.
This changes the `cell` method to compare the new value key-by-key and report the changed keys to the backend.

On read side the Vc need to be read via `.get(key).await?` or `.contains_key(key).await?`, which returns only the value resp. existance of the key and adds a dependency only to that key.

With this approach the "selector" tasks can be avoided, while maintaining the same level of invalidation.

### How?

On implementation side we only track the hash of the key for size reasons.
A dependency has an additional field `key: Option<u64>` which represents the key depending on.

When updating a cell we have a new optional argument `updated_key_hashes: Option<SmallVec<[u64; 2]>>` where the updates keys can be provided. The new `CellMode` (cell = "keyed") fills that.
2026-01-13 18:47:33 +01:00

23 lines
455 B
TOML

[package]
name = "turbo-tasks-testing"
version = "0.1.0"
description = "TBD"
license = "MIT"
edition = "2024"
autobenches = false
autotests = false
[lib]
bench = false
[lints]
workspace = true
[dependencies]
anyhow = { workspace = true }
futures = { workspace = true }
rustc-hash = { workspace = true }
smallvec = { workspace = true }
tokio = { workspace = true }
turbo-tasks = { workspace = true, features = ["non_operation_vc_strongly_consistent"] }