Skip to content

Commit

Permalink
use new backend by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 8, 2024
1 parent 524f9ec commit b1af044
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions crates/napi/src/next_api/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
collections::HashMap, env, future::Future, ops::Deref, path::PathBuf, sync::Arc, time::Duration,
collections::HashMap, future::Future, ops::Deref, path::PathBuf, sync::Arc, time::Duration,
};

use anyhow::{anyhow, Context, Result};
Expand All @@ -12,7 +12,9 @@ use serde::Serialize;
use turbo_tasks::{
trace::TraceRawVcs, ReadRef, TaskId, TryJoinIterExt, TurboTasks, UpdateInfo, Vc,
};
use turbo_tasks_backend::{default_backing_storage, DefaultBackingStorage};
use turbo_tasks_backend::{
default_backing_storage, noop_backing_storage, DefaultBackingStorage, NoopBackingStorage,
};
use turbo_tasks_fs::FileContent;
use turbopack_core::{
diagnostics::{Diagnostic, DiagnosticContextExt, PlainDiagnostic},
Expand All @@ -25,7 +27,7 @@ use crate::util::log_internal_error_and_inform;

#[derive(Clone)]
pub enum NextTurboTasks {
Memory(Arc<TurboTasks<turbo_tasks_memory::MemoryBackend>>),
Memory(Arc<TurboTasks<turbo_tasks_backend::TurboTasksBackend<NoopBackingStorage>>>),
PersistentCaching(
Arc<TurboTasks<turbo_tasks_backend::TurboTasksBackend<DefaultBackingStorage>>>,
),
Expand Down Expand Up @@ -108,7 +110,7 @@ impl NextTurboTasks {

pub fn memory_backend(&self) -> Option<&turbo_tasks_memory::MemoryBackend> {
match self {
NextTurboTasks::Memory(turbo_tasks) => Some(turbo_tasks.backend()),
NextTurboTasks::Memory(_) => None,
NextTurboTasks::PersistentCaching(_) => None,
}
}
Expand All @@ -124,7 +126,7 @@ impl NextTurboTasks {
pub fn create_turbo_tasks(
output_path: PathBuf,
persistent_caching: bool,
memory_limit: usize,
_memory_limit: usize,
) -> Result<NextTurboTasks> {
Ok(if persistent_caching {
NextTurboTasks::PersistentCaching(TurboTasks::new(
Expand All @@ -134,11 +136,15 @@ pub fn create_turbo_tasks(
),
))
} else {
let mut backend = turbo_tasks_memory::MemoryBackend::new(memory_limit);
if env::var_os("NEXT_TURBOPACK_PRINT_TASK_INVALIDATION").is_some() {
backend.print_task_invalidation(true);
}
NextTurboTasks::Memory(TurboTasks::new(backend))
NextTurboTasks::Memory(TurboTasks::new(
turbo_tasks_backend::TurboTasksBackend::new(
turbo_tasks_backend::BackendOptions {
storage_mode: None,
..Default::default()
},
noop_backing_storage(),
),
))
})
}

Expand Down
4 changes: 2 additions & 2 deletions turbopack/crates/turbo-tasks-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub fn lmdb_backing_storage(path: &Path) -> Result<LmdbBackingStorage> {

pub type NoopBackingStorage = KeyValueDatabaseBackingStorage<NoopKvDb>;

pub fn noop_backing_storage(_path: &Path) -> Result<NoopBackingStorage> {
Ok(KeyValueDatabaseBackingStorage::new(NoopKvDb))
pub fn noop_backing_storage() -> NoopBackingStorage {
KeyValueDatabaseBackingStorage::new(NoopKvDb)
}

pub type DefaultBackingStorage = LmdbBackingStorage;
Expand Down

0 comments on commit b1af044

Please sign in to comment.