Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ owo-colors = "4.2.2"
parcel_selectors = "0.28.2"
parking_lot = "0.12.1"
pathdiff = "0.2.1"
petgraph = "0.6.3"
petgraph = "0.8.3"
pin-project-lite = "0.2.9"
postcard = "1.0.4"
proc-macro2 = "1.0.79"
Expand Down
6 changes: 3 additions & 3 deletions packages/next-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
"build-native": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features plugin,image-extended --js false native",
"build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features plugin,image-extended,tracing/release_max_level_info --js false native",
"build-native-release-with-assertions": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --profile release-with-assertions --features plugin,image-extended,tracing/release_max_level_info --js false native",
"build-native-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features plugin,image-extended --js false native",
"build-native-release-with-assertions": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --profile release-with-assertions --features plugin,image-extended --js false native",
"build-native-no-plugin": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --features image-webp --js false native",
"build-native-no-plugin-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features image-webp,tracing/release_max_level_info --js false native",
"build-native-no-plugin-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --features image-webp --js false native",
"build-native-wasi": "npx --package=@napi-rs/[email protected] napi build --platform --target wasm32-wasip1-threads -p next-swc-napi --cwd ../../ --output-dir packages/next-swc/native --no-default-features",
"build-wasm": "wasm-pack build ../../crates/wasm --scope=next",
"cache-build-native": "[ -d native ] && echo $(ls native)",
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bench = false
workspace = true

[features]
default = []
default = ["trace_task_dirty", "verify_immutable", "verify_serialization"]
print_cache_item_size = []
no_fast_stale = []
verify_serialization = []
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,12 +958,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
.map(|op| op.arc().clone())
.collect::<Vec<_>>();
drop(snapshot_request);
self.storage.start_snapshot();
let mut persisted_task_cache_log = self
.persisted_task_cache_log
.as_ref()
.map(|l| l.take(|i| i))
.unwrap_or_default();
self.storage.start_snapshot();
let mut snapshot_request = self.snapshot_request.lock();
snapshot_request.snapshot_requested = false;
self.in_progress_operations
Expand Down
30 changes: 27 additions & 3 deletions turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
for (task_type, task_id) in updates {
let task_id: u32 = *task_id;
serialize_task_type(&task_type, &mut task_type_bytes, task_id)?;
if task_type.get_name().contains("with_modules") {
println!("Stored task type: {task_type:?} => {task_id}");
}

batch
.put(
Expand Down Expand Up @@ -499,12 +502,20 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
tx: &D::ReadTransaction<'_>,
task_type: &CachedTaskType,
) -> Result<Option<TaskId>> {
let span = tracing::trace_span!(
"forward_lookup_task_cache",
task_type = debug(task_type),
success = tracing::field::Empty
)
.entered();
let task_type = POT_CONFIG.serialize(task_type)?;
let Some(bytes) = database.get(tx, KeySpace::ForwardTaskCache, &task_type)? else {
span.record("success", false);
return Ok(None);
};
let bytes = bytes.borrow().try_into()?;
let id = TaskId::try_from(u32::from_le_bytes(bytes)).unwrap();
span.record("success", *id);
Ok(Some(id))
}
if inner.database.is_empty() {
Expand Down Expand Up @@ -659,9 +670,22 @@ fn serialize_task_type(
let deserialize: Result<CachedTaskType, _> = serde_path_to_error::deserialize(
&mut pot_de_symbol_list().deserializer_for_slice(&*task_type_bytes)?,
);
if let Err(err) = deserialize {
println!("Task type would not be deserializable {task_id}: {err:?}\n{task_type:#?}");
panic!("Task type would not be deserializable {task_id}: {err:?}");
match deserialize {
Ok(value) => {
if value != **task_type {
println!(
"Task type would not round-trip {task_id}:\nOriginal: \
{task_type:#?}\nRound-tripped: {value:#?}"
);
panic!("Task type would not round-trip {task_id}");
}
}
Err(err) => {
println!(
"Task type would not be deserializable {task_id}: {err:?}\n{task_type:#?}"
);
panic!("Task type would not be deserializable {task_id}: {err:?}");
}
}
}
Ok(())
Expand Down
27 changes: 26 additions & 1 deletion turbopack/crates/turbo-tasks-backend/src/utils/chunked_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<T> ChunkedVec<T> {
}
}

pub fn iter(&self) -> impl Iterator<Item = &T> {
pub fn iter(&self) -> impl ExactSizeIterator<Item = &T> {
ExactSizeIter {
iter: self.chunks.iter().flat_map(|chunk| chunk.iter()),
len: self.len(),
Expand Down Expand Up @@ -104,3 +104,28 @@ impl<I: Iterator> ExactSizeIterator for ExactSizeIter<I> {
self.len
}
}

#[cfg(test)]
mod tests {
use super::ChunkedVec;

#[test]
fn test_chunked_vec() {
for i in 0..1000 {
let mut vec = ChunkedVec::new();
for j in 0..i {
vec.push(j);
}
assert_eq!(vec.len(), i);
assert_eq!(
vec.iter().copied().collect::<Vec<_>>(),
(0..i).collect::<Vec<_>>()
);
assert_eq!(vec.iter().len(), i);
assert_eq!(vec.is_empty(), i == 0);
let iter = vec.into_iter();
assert_eq!(iter.len(), i);
assert_eq!(iter.collect::<Vec<_>>(), (0..i).collect::<Vec<_>>());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ impl AvailableModules {
self: ResolvedVc<Self>,
modules: ResolvedVc<AvailableModulesSet>,
) -> Result<Vc<Self>> {
let _span = tracing::trace_span!(
"AvailabilityInfo::with_modules",
this = debug(self),
modules = debug(&modules)
)
.entered();
Ok(AvailableModules {
parent: Some(self),
modules,
Expand Down
Loading