Skip to content

Commit

Permalink
[Turbopack] improve task aggregation update (#74771)
Browse files Browse the repository at this point in the history
improve performance test case

add mark_as_completed

fix aggregation graph bug

optimize update

make sure to not miss the power_of_two mark

add threshold for leaf uppers

add test case

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to understand the PR)
- When linking to a Slack thread, you might want to share details of the conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
  • Loading branch information
sokra authored Jan 14, 2025
1 parent 15915c3 commit 3256ff8
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 140 deletions.
27 changes: 27 additions & 0 deletions turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
once_task,
done_event,
session_dependent: false,
marked_as_completed: false,
},
});

Expand Down Expand Up @@ -1319,6 +1320,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
once_task: _,
stale,
session_dependent,
marked_as_completed: _,
} = in_progress
else {
panic!("Task execution completed, but task is not in progress: {task:#?}");
Expand Down Expand Up @@ -1669,6 +1671,23 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
}
}

fn mark_own_task_as_finished(
&self,
task: TaskId,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) {
let mut ctx = self.execute_context(turbo_tasks);
let mut task = ctx.task(task, TaskDataCategory::Data);
if let Some(InProgressState::InProgress {
marked_as_completed,
..
}) = get_mut!(task, InProgress)
{
*marked_as_completed = true;
// TODO this should remove the dirty state (also check session_dependent)
}
}

fn connect_task(
&self,
task: TaskId,
Expand Down Expand Up @@ -1952,6 +1971,14 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
self.0.update_task_cell(task_id, cell, content, turbo_tasks);
}

fn mark_own_task_as_finished(
&self,
task_id: TaskId,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) {
self.0.mark_own_task_as_finished(task_id, turbo_tasks);
}

fn mark_own_task_as_session_dependent(
&self,
task: TaskId,
Expand Down
Loading

0 comments on commit 3256ff8

Please sign in to comment.