Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
94948b0b
Commit
94948b0b
authored
Nov 26, 2025
by
Tobias Koppers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Per function stats
parent
2f7873f8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
605 additions
and
16 deletions
+605
-16
Cargo.lock
Cargo.lock
+1
-0
Cargo.toml
Cargo.toml
+1
-0
Cargo.toml
crates/next-persistence-tools/Cargo.toml
+1
-0
main.rs
crates/next-persistence-tools/src/main.rs
+557
-1
db.rs
turbopack/crates/turbo-persistence/src/db.rs
+12
-13
mod.rs
...pack/crates/turbo-tasks-backend/src/database/turbo/mod.rs
+17
-1
lib.rs
turbopack/crates/turbo-tasks-backend/src/lib.rs
+1
-1
native_function.rs
turbopack/crates/turbo-tasks/src/native_function.rs
+4
-0
registry.rs
turbopack/crates/turbo-tasks/src/registry.rs
+11
-0
No files found.
Cargo.lock
View file @
94948b0b
...
...
@@ -4418,6 +4418,7 @@ dependencies = [
"anyhow",
"clap",
"next-api",
"pot",
"rustc-hash 2.1.1",
"turbo-persistence",
"twox-hash 2.1.0",
...
...
Cargo.toml
View file @
94948b0b
...
...
@@ -286,6 +286,7 @@ debug = true
[workspace.dependencies]
# Workspace crates
next-swc-napi
=
{
path
=
"crates/napi"
}
next-api
=
{
path
=
"crates/next-api"
}
next-build
=
{
path
=
"crates/next-build"
}
next-core
=
{
path
=
"crates/next-core"
}
...
...
crates/next-persistence-tools/Cargo.toml
View file @
94948b0b
...
...
@@ -18,6 +18,7 @@ workspace = true
anyhow
=
{
workspace
=
true
}
clap
=
{
workspace
=
true
,
features
=
["derive"]
}
next-api
=
{
workspace
=
true
}
pot
=
"3.0.0"
rustc-hash
=
{
workspace
=
true
}
turbo-persistence
=
{
workspace
=
true
}
twox-hash
=
{
workspace
=
true
}
crates/next-persistence-tools/src/main.rs
View file @
94948b0b
This diff is collapsed.
Click to expand it.
turbopack/crates/turbo-persistence/src/db.rs
View file @
94948b0b
...
...
@@ -285,6 +285,10 @@ impl<S: ParallelScheduler> TurboPersistence<S> {
for
entry
in
entries
{
let
entry
=
entry
?
;
let
path
=
entry
.path
();
let
file_name
=
path
.file_name
();
if
file_name
.is_some_and
(|
s
|
s
.as_encoded_bytes
()
.starts_with
(
b
"."
))
{
continue
;
}
if
let
Some
(
ext
)
=
path
.extension
()
.and_then
(|
s
|
s
.to_str
())
{
let
seq
:
u32
=
path
.file_stem
()
...
...
@@ -331,17 +335,12 @@ impl<S: ParallelScheduler> TurboPersistence<S> {
// ignore blobs and sst, they are read when needed
}
_
=>
{
if
!
path
.file_name
()
.is_some_and
(|
s
|
s
.as_encoded_bytes
()
.starts_with
(
b
"."
))
{
bail!
(
"Unexpected file in persistence directory: {:?}"
,
path
);
}
bail!
(
"Unexpected file in persistence directory: {:?}"
,
path
);
}
}
}
}
else
{
match
path
.file_stem
()
.and_then
(|
s
|
s
.to_str
())
{
match
file_name
.and_then
(|
s
|
s
.to_str
())
{
Some
(
"CURRENT"
)
=>
{
// Already read
}
...
...
@@ -349,12 +348,7 @@ impl<S: ParallelScheduler> TurboPersistence<S> {
// Ignored, write-only
}
_
=>
{
if
!
path
.file_name
()
.is_some_and
(|
s
|
s
.as_encoded_bytes
()
.starts_with
(
b
"."
))
{
bail!
(
"Unexpected file in persistence directory: {:?}"
,
path
);
}
bail!
(
"Unexpected file in persistence directory: {:?}"
,
path
);
}
}
}
...
...
@@ -405,6 +399,11 @@ impl<S: ParallelScheduler> TurboPersistence<S> {
self
.inner
.read
()
.meta_files
.is_empty
()
}
/// Returns true if the database is opened in read-only mode.
pub
fn
is_read_only
(
&
self
)
->
bool
{
self
.read_only
}
/// Starts a new WriteBatch for the database. Only a single write operation is allowed at a
/// time. The WriteBatch need to be committed with [`TurboPersistence::commit_write_batch`].
/// Note that the WriteBatch might start writing data to disk while it's filled up with data.
...
...
turbopack/crates/turbo-tasks-backend/src/database/turbo/mod.rs
View file @
94948b0b
use
std
::{
cmp
::
max
,
fs
::
OpenOptions
,
io
::
BufWriter
,
path
::
PathBuf
,
sync
::
Arc
,
thread
::
available_parallelism
,
...
...
@@ -11,7 +13,9 @@ use parking_lot::Mutex;
use
turbo_persistence
::{
ArcSlice
,
CompactConfig
,
KeyBase
,
StoreKey
,
TurboPersistence
,
ValueBuffer
,
};
use
turbo_tasks
::{
JoinHandle
,
message_queue
::
TimingEvent
,
spawn
,
turbo_tasks
};
use
turbo_tasks
::{
JoinHandle
,
message_queue
::
TimingEvent
,
registry
::
iter_functions
,
spawn
,
turbo_tasks
,
};
use
crate
::
database
::{
key_value_database
::{
KeySpace
,
KeyValueDatabase
},
...
...
@@ -41,7 +45,19 @@ pub struct TurboKeyValueDatabase {
impl
TurboKeyValueDatabase
{
pub
fn
new
(
versioned_path
:
PathBuf
,
is_ci
:
bool
,
is_short_session
:
bool
)
->
Result
<
Self
>
{
let
mappings_path
=
versioned_path
.join
(
".functions.map"
);
let
db
=
Arc
::
new
(
TurboPersistence
::
open
(
versioned_path
)
?
);
if
db
.is_empty
()
&&
!
db
.is_read_only
()
{
let
mappings_file
=
OpenOptions
::
new
()
.create
(
true
)
.append
(
true
)
.open
(
mappings_path
)
?
;
let
mut
mappings_file
=
BufWriter
::
new
(
mappings_file
);
for
(
id
,
func
)
in
iter_functions
()
{
use
std
::
io
::
Write
;
writeln!
(
mappings_file
,
"{} {}"
,
*
id
as
u32
,
func
.global_name
())
?
;
}
}
Ok
(
Self
{
db
:
db
.clone
(),
compact_join_handle
:
Mutex
::
new
(
None
),
...
...
turbopack/crates/turbo-tasks-backend/src/lib.rs
View file @
94948b0b
...
...
@@ -5,7 +5,7 @@
mod
backend
;
mod
backing_storage
;
mod
data
;
pub
mod
data
;
mod
data_storage
;
mod
database
;
mod
kv_backing_storage
;
...
...
turbopack/crates/turbo-tasks/src/native_function.rs
View file @
94948b0b
...
...
@@ -237,6 +237,10 @@ impl NativeFunction {
}
}
pub
fn
global_name
(
&
self
)
->
&
'static
str
{
self
.global_name
}
pub
fn
span
(
&
'static
self
,
persistence
:
TaskPersistence
,
reason
:
TaskExecutionReason
)
->
Span
{
let
flags
=
match
persistence
{
TaskPersistence
::
Persistent
=>
""
,
...
...
turbopack/crates/turbo-tasks/src/registry.rs
View file @
94948b0b
...
...
@@ -117,6 +117,13 @@ impl<T: RegistryItem> Registry<T> {
))
}
}
pub
fn
iter
(
&
self
)
->
impl
Iterator
<
Item
=
(
T
::
Id
,
&
'static
T
)
>
+
'_
{
self
.id_to_item
.iter
()
.enumerate
()
.map
(|(
i
,
&
item
)|
(
T
::
Id
::
from
(
NonZeroU16
::
new
((
i
+
1
)
as
u16
)
.unwrap
()),
item
))
}
}
static
FUNCTIONS
:
Lazy
<
Registry
<
NativeFunction
>>
=
Lazy
::
new
(||
{
...
...
@@ -139,6 +146,10 @@ pub fn validate_function_id(id: FunctionId) -> Option<Error> {
FUNCTIONS
.validate_id
(
id
)
}
pub
fn
iter_functions
()
->
impl
Iterator
<
Item
=
(
FunctionId
,
&
'static
NativeFunction
)
>
{
FUNCTIONS
.iter
()
}
static
VALUES
:
Lazy
<
Registry
<
ValueType
>>
=
Lazy
::
new
(||
{
// Inventory does not guarantee an order. So we sort by the global name to get a stable order
// This ensures that assigned ids are also stable which is important since they are serialized.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment