Skip to content

Commit ffbc4e9

Browse files
committed
remove session id concept
1 parent 999002d commit ffbc4e9

File tree

6 files changed

+8
-58
lines changed

6 files changed

+8
-58
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use tokio::time::{Duration, Instant};
2727
use tracing::{Span, field::Empty, info_span, trace_span};
2828
use turbo_tasks::{
2929
CellId, FxDashMap, FxIndexMap, KeyValuePair, RawVc, ReadCellOptions, ReadConsistency,
30-
ReadOutputOptions, ReadTracking, SessionId, TRANSIENT_TASK_BIT, TaskExecutionReason, TaskId,
31-
TraitTypeId, TurboTasksBackendApi, ValueTypeId,
30+
ReadOutputOptions, ReadTracking, TRANSIENT_TASK_BIT, TaskExecutionReason, TaskId, TraitTypeId,
31+
TurboTasksBackendApi, ValueTypeId,
3232
backend::{
3333
Backend, CachedTaskType, CellContent, TaskExecutionSpec, TransientTaskRoot,
3434
TransientTaskType, TurboTasksExecutionError, TypedCellContent, VerificationMode,
@@ -170,7 +170,6 @@ struct TurboTasksBackendInner<B: BackingStorage> {
170170
options: BackendOptions,
171171

172172
start_time: Instant,
173-
session_id: SessionId,
174173

175174
persisted_task_id_factory: IdFactoryWithReuse<TaskId>,
176175
transient_task_id_factory: IdFactoryWithReuse<TaskId>,
@@ -244,9 +243,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
244243
Self {
245244
options,
246245
start_time: Instant::now(),
247-
session_id: backing_storage
248-
.next_session_id()
249-
.expect("Failed get session id"),
250246
persisted_task_id_factory: IdFactoryWithReuse::new(
251247
next_task_id,
252248
TaskId::try_from(TRANSIENT_TASK_BIT - 1).unwrap(),
@@ -285,10 +281,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
285281
ExecuteContextImpl::new(self, turbo_tasks)
286282
}
287283

288-
fn session_id(&self) -> SessionId {
289-
self.session_id
290-
}
291-
292284
/// # Safety
293285
///
294286
/// `tx` must be a transaction from this TurboTasksBackendInner instance.
@@ -1164,7 +1156,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
11641156
if !persisted_task_cache_log.is_empty() || !task_snapshots.is_empty() {
11651157
new_items = true;
11661158
if let Err(err) = self.backing_storage.save_snapshot(
1167-
self.session_id,
11681159
suspended_operations,
11691160
persisted_task_cache_log,
11701161
task_snapshots,

turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
};
1515

1616
use serde::{Deserialize, Serialize};
17-
use turbo_tasks::{FxIndexMap, KeyValuePair, SessionId, TaskId, TurboTasksBackendApi};
17+
use turbo_tasks::{FxIndexMap, KeyValuePair, TaskId, TurboTasksBackendApi};
1818

1919
use crate::{
2020
backend::{
@@ -51,7 +51,6 @@ pub trait ExecuteContext<'e>: Sized {
5151
fn child_context<'l, 'r>(&'r self) -> impl ChildExecuteContext<'l> + use<'e, 'l, Self>
5252
where
5353
'e: 'l;
54-
fn session_id(&self) -> SessionId;
5554
fn task(&mut self, task_id: TaskId, category: TaskDataCategory) -> Self::TaskGuardImpl;
5655
fn is_once_task(&self, task_id: TaskId) -> bool;
5756
fn task_pair(
@@ -181,10 +180,6 @@ where
181180
}
182181
}
183182

184-
fn session_id(&self) -> SessionId {
185-
self.backend.session_id()
186-
}
187-
188183
fn task(&mut self, task_id: TaskId, category: TaskDataCategory) -> Self::TaskGuardImpl {
189184
#[cfg(debug_assertions)]
190185
if self.active_task_locks.fetch_add(1, Ordering::AcqRel) != 0 {

turbopack/crates/turbo-tasks-backend/src/backing_storage.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{any::type_name, sync::Arc};
33
use anyhow::Result;
44
use either::Either;
55
use smallvec::SmallVec;
6-
use turbo_tasks::{SessionId, TaskId, backend::CachedTaskType};
6+
use turbo_tasks::{TaskId, backend::CachedTaskType};
77

88
use crate::{
99
backend::{AnyOperation, TaskDataCategory},
@@ -43,13 +43,11 @@ pub trait BackingStorage: BackingStorageSealed {
4343
pub trait BackingStorageSealed: 'static + Send + Sync {
4444
type ReadTransaction<'l>;
4545
fn next_free_task_id(&self) -> Result<TaskId>;
46-
fn next_session_id(&self) -> Result<SessionId>;
4746
fn uncompleted_operations(&self) -> Result<Vec<AnyOperation>>;
4847
#[allow(clippy::ptr_arg)]
4948
fn serialize(&self, task: TaskId, data: &Vec<CachedDataItem>) -> Result<SmallVec<[u8; 16]>>;
5049
fn save_snapshot<I>(
5150
&self,
52-
session_id: SessionId,
5351
operations: Vec<Arc<AnyOperation>>,
5452
task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
5553
snapshots: Vec<I>,
@@ -116,10 +114,6 @@ where
116114
either::for_both!(self, this => this.next_free_task_id())
117115
}
118116

119-
fn next_session_id(&self) -> Result<SessionId> {
120-
either::for_both!(self, this => this.next_session_id())
121-
}
122-
123117
fn uncompleted_operations(&self) -> Result<Vec<AnyOperation>> {
124118
either::for_both!(self, this => this.uncompleted_operations())
125119
}
@@ -130,7 +124,6 @@ where
130124

131125
fn save_snapshot<I>(
132126
&self,
133-
session_id: SessionId,
134127
operations: Vec<Arc<AnyOperation>>,
135128
task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
136129
snapshots: Vec<I>,
@@ -146,7 +139,6 @@ where
146139
+ Sync,
147140
{
148141
either::for_both!(self, this => this.save_snapshot(
149-
session_id,
150142
operations,
151143
task_cache_updates,
152144
snapshots,

turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::{Context, Result, anyhow};
99
use serde::{Deserialize, Serialize};
1010
use smallvec::SmallVec;
1111
use turbo_tasks::{
12-
SessionId, TaskId,
12+
TaskId,
1313
backend::CachedTaskType,
1414
panic_hooks::{PanicHookGuard, register_panic_hook},
1515
parallel,
@@ -71,7 +71,6 @@ fn pot_de_symbol_list<'l>() -> pot::de::SymbolList<'l> {
7171

7272
const META_KEY_OPERATIONS: u32 = 0;
7373
const META_KEY_NEXT_FREE_TASK_ID: u32 = 1;
74-
const META_KEY_SESSION_ID: u32 = 2;
7574

7675
struct IntKey([u8; 4]);
7776

@@ -238,7 +237,7 @@ impl<T: KeyValueDatabase> KeyValueDatabaseBackingStorageInner<T> {
238237
Ok(())
239238
}
240239

241-
/// Used to read the previous session id and the next free task ID from the database.
240+
/// Used to read the next free task ID from the database.
242241
fn get_infra_u32(&self, key: u32) -> Result<Option<u32>> {
243242
let tx = self.database.begin_read_transaction()?;
244243
self.database
@@ -269,16 +268,6 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
269268
.map_or(Ok(TaskId::MIN), TaskId::try_from)?)
270269
}
271270

272-
fn next_session_id(&self) -> Result<SessionId> {
273-
Ok(SessionId::try_from(
274-
self.inner
275-
.get_infra_u32(META_KEY_SESSION_ID)
276-
.context("Unable to read session id from database")?
277-
.unwrap_or(0)
278-
+ 1,
279-
)?)
280-
}
281-
282271
fn uncompleted_operations(&self) -> Result<Vec<AnyOperation>> {
283272
fn get(database: &impl KeyValueDatabase) -> Result<Vec<AnyOperation>> {
284273
let tx = database.begin_read_transaction()?;
@@ -302,7 +291,6 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
302291

303292
fn save_snapshot<I>(
304293
&self,
305-
session_id: SessionId,
306294
operations: Vec<Arc<AnyOperation>>,
307295
task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
308296
snapshots: Vec<I>,
@@ -317,7 +305,7 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
317305
> + Send
318306
+ Sync,
319307
{
320-
let _span = tracing::trace_span!("save snapshot", session_id = ?session_id, operations = operations.len());
308+
let _span = tracing::trace_span!("save snapshot", operations = operations.len());
321309
let mut batch = self.inner.database.write_batch()?;
322310

323311
// Start organizing the updates in parallel
@@ -401,7 +389,6 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
401389
save_infra::<T::SerialWriteBatch<'_>, T::ConcurrentWriteBatch<'_>>(
402390
&mut WriteBatchRef::concurrent(batch),
403391
next_task_id,
404-
session_id,
405392
operations,
406393
)?;
407394
}
@@ -473,7 +460,6 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
473460
save_infra::<T::SerialWriteBatch<'_>, T::ConcurrentWriteBatch<'_>>(
474461
&mut WriteBatchRef::serial(batch),
475462
next_task_id,
476-
session_id,
477463
operations,
478464
)?;
479465
}
@@ -608,7 +594,6 @@ where
608594
fn save_infra<'a, S, C>(
609595
batch: &mut WriteBatchRef<'_, 'a, S, C>,
610596
next_task_id: u32,
611-
session_id: SessionId,
612597
operations: Vec<Arc<AnyOperation>>,
613598
) -> Result<(), anyhow::Error>
614599
where
@@ -624,16 +609,6 @@ where
624609
)
625610
.with_context(|| anyhow!("Unable to write next free task id"))?;
626611
}
627-
{
628-
let _span = tracing::trace_span!("update session id", session_id = ?session_id).entered();
629-
batch
630-
.put(
631-
KeySpace::Infra,
632-
WriteBuffer::Borrowed(IntKey::new(META_KEY_SESSION_ID).as_ref()),
633-
WriteBuffer::Borrowed(&session_id.to_le_bytes()),
634-
)
635-
.with_context(|| anyhow!("Unable to write next session id"))?;
636-
}
637612
{
638613
let _span =
639614
tracing::trace_span!("update operations", operations = operations.len()).entered();

turbopack/crates/turbo-tasks/src/id.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ define_id!(TaskId: u32, derive(Serialize, Deserialize), serde(transparent));
122122
define_id!(FunctionId: u16);
123123
define_id!(ValueTypeId: u16);
124124
define_id!(TraitTypeId: u16);
125-
define_id!(SessionId: u32, derive(Debug, Serialize, Deserialize), serde(transparent));
126125
define_id!(
127126
LocalTaskId: u32,
128127
derive(Debug, Serialize, Deserialize),

turbopack/crates/turbo-tasks/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ pub use collectibles::CollectiblesSource;
9797
pub use completion::{Completion, Completions};
9898
pub use display::ValueToString;
9999
pub use effect::{ApplyEffectsContext, Effects, apply_effects, effect, get_effects};
100-
pub use id::{
101-
ExecutionId, LocalTaskId, SessionId, TRANSIENT_TASK_BIT, TaskId, TraitTypeId, ValueTypeId,
102-
};
100+
pub use id::{ExecutionId, LocalTaskId, TRANSIENT_TASK_BIT, TaskId, TraitTypeId, ValueTypeId};
103101
pub use invalidation::{
104102
InvalidationReason, InvalidationReasonKind, InvalidationReasonSet, Invalidator, get_invalidator,
105103
};

0 commit comments

Comments
 (0)