Unverified Commit 4d21afa8 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: less tasks in `with_modules` (#75700)

Way less turbo tasks

Less CPU time, 300mb less memory.

```
testing against 0293c96cf32

uncell AstPath 77d7015554 (PR below in this stack)
13,65 GB 
TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD=  505.04s user 83.92s system 853% cpu 1:09.00 total
TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD=  509.03s user 84.26s system 829% cpu 1:11.53 total

snapshot in with_modules c2c661b1e9
13,3 GB
TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD=  491.50s user 79.78s system 856% cpu 1:06.69 total
TURBO_ENGINE_READ_ONLY=1 NEXT_TURBOPACK_TRACING= TURBOPACK=1 TURBOPACK_BUILD=  495.62s user 78.61s system 852% cpu 1:07.36 total
```
parent bfa4bca9
......@@ -2,7 +2,7 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};
use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, FxIndexMap, NonLocalValue, ReadRef, ResolvedVc,
TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
TryJoinIterExt, ValueToString, Vc,
};
use turbo_tasks_hash::Xxh3Hash64Hasher;
......@@ -59,17 +59,22 @@ impl AvailableModules {
self: ResolvedVc<Self>,
modules: ResolvedVc<AvailableModuleInfoMap>,
) -> Result<Vc<Self>> {
let self_snapshot = self.snapshot().await?;
let modules = modules
.await?
.into_iter()
.map(|(&module, &info)| async move {
Ok(self.get(*module).await?.is_none().then_some((module, info)))
.flat_map(|(&module, &info)| {
self_snapshot
.get(module)
.is_none()
.then_some((module, info))
})
.try_flat_join()
.await?;
.collect();
Ok(AvailableModules {
parent: Some(self),
modules: ResolvedVc::cell(modules.into_iter().collect()),
modules: ResolvedVc::cell(modules),
}
.cell())
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment