feat(turbo-tasks): Add `local_cells` argument to `turbo_tasks::function` macro, read it in `Vc::cell` (#68644)
Bigger picture:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff
## What this PR does
- Adds a `local_cells` argument to the `#[turbo_tasks::function(...)]`
macro, which also implies `resolved` (#68422)
- Stores that `local_cells` option in a `FunctionMeta` object on
`CurrentTaskState`.
- Reads that option when `Vc::cell` is called, and changes the behavior
to construct a local cell instead of a normal, global one.
## What this PR does not do
- Functions annotated with `local_cells` still create full tasks.
Instead, they should inherit parts of `CurrentTaskState`, including
their parent task's `TaskId` value, so that values resolved in a local
task are resolved on their parent task.
- Return values are not yet automatically resolved. This is shown in the
tests, which must manually call `.resolve().await.unwrap()`.
## Naming: Why is it called "local_cells" and not just "local"?
Right now, every turbo task is `tokio::spawn`ed. In the future, we'll
probably want a way to run some tasks "locally" without the overhead of
`tokio::spawn`.
If I just called this flag `local` and not `local_cells`, it would then
be hard later to name the concept of "local execution":
- **Local Cells** *(what this PR is about)*: Will reduce long-term
memory usage by avoiding caching functions that would otherwise have low
hit rates. These tasks may still be `tokio::spawn`ed to take advantage
of threads and the work-stealing executor.
- **Local Execution** *(does not exist yet, lacks a formal proposal)*:
Would improve CPU cache locality and would slightly decrease transient
memory usage for short-running tasks by avoiding `tokio::spawn`. These
tasks may still be cached.
## Test Plan
```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```