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
7373a852
Commit
7373a852
authored
Feb 21, 2026
by
Benjamin Woodruff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments
parent
fc1ae3fa
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
45 deletions
+42
-45
index.ts
packages/next/src/build/swc/index.ts
+3
-4
loaderWorkerPool.ts
packages/next/src/build/swc/loaderWorkerPool.ts
+4
-7
lib.rs
turbopack/crates/turbo-rcstr/src/lib.rs
+0
-6
evaluate.rs
turbopack/crates/turbopack-node/src/evaluate.rs
+14
-13
pool_stats.rs
turbopack/crates/turbopack-node/src/pool_stats.rs
+3
-6
mod.rs
turbopack/crates/turbopack-node/src/process_pool/mod.rs
+2
-2
mod.rs
turbopack/crates/turbopack-node/src/worker_pool/mod.rs
+15
-5
operation.rs
turbopack/crates/turbopack-node/src/worker_pool/operation.rs
+1
-2
No files found.
packages/next/src/build/swc/index.ts
View file @
7373a852
...
@@ -1468,9 +1468,8 @@ function loadNative(importPath?: string) {
...
@@ -1468,9 +1468,8 @@ function loadNative(importPath?: string) {
const customBindingsPath = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS
const customBindingsPath = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS
? require.resolve(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
? require.resolve(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
: null
: null
const customBindings: RawBindings = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS
const customBindings: RawBindings =
? require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
customBindingsPath != null ? require(customBindingsPath!) : null
: null
let bindings: RawBindings = customBindings
let bindings: RawBindings = customBindings
let bindingsPath = customBindingsPath
let bindingsPath = customBindingsPath
let attempts: any[] = []
let attempts: any[] = []
...
@@ -1481,8 +1480,8 @@ function loadNative(importPath?: string) {
...
@@ -1481,8 +1480,8 @@ function loadNative(importPath?: string) {
try {
try {
const bindingForTest = `
$
{
NEXT_TEST_NATIVE_DIR
}
/next-swc.${triple.platformArchABI}.node
`
const bindingForTest = `
$
{
NEXT_TEST_NATIVE_DIR
}
/next-swc.${triple.platformArchABI}.node
`
// Use the binary directly to skip `pnpm pack` for testing as it's slow because of the large native binary.
// Use the binary directly to skip `pnpm pack` for testing as it's slow because of the large native binary.
bindings
=
require
(
bindingForTest
)
bindingsPath
=
require
.
resolve
(
bindingForTest
)
bindingsPath
=
require
.
resolve
(
bindingForTest
)
bindings
=
require
(
bindingsPath
)
infoLog
(
infoLog
(
'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'
'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'
)
)
...
...
packages/next/src/build/swc/loaderWorkerPool.ts
View file @
7373a852
...
@@ -7,16 +7,16 @@ function getPoolId(cwd: string, filename: string) {
...
@@ -7,16 +7,16 @@ function getPoolId(cwd: string, filename: string) {
}
}
export
async
function
runLoaderWorkerPool
(
export
async
function
runLoaderWorkerPool
(
binding
:
typeof
import
(
'./generated-native'
),
binding
s
:
typeof
import
(
'./generated-native'
),
bindingPath
:
string
bindingPath
:
string
)
{
)
{
binding
.
registerWorkerScheduler
(
binding
s
.
registerWorkerScheduler
(
(
creation
)
=>
{
(
creation
)
=>
{
const
{
const
{
options
:
{
filename
,
cwd
},
options
:
{
filename
,
cwd
},
}
=
creation
}
=
creation
le
t
poolId
=
getPoolId
(
cwd
,
filename
)
cons
t
poolId
=
getPoolId
(
cwd
,
filename
)
const
worker
=
new
Worker
(
/* turbopackIgnore: true*/
filename
,
{
const
worker
=
new
Worker
(
/* turbopackIgnore: true*/
filename
,
{
workerData
:
{
workerData
:
{
...
@@ -39,12 +39,9 @@ export async function runLoaderWorkerPool(
...
@@ -39,12 +39,9 @@ export async function runLoaderWorkerPool(
workerId
,
workerId
,
}
=
termination
}
=
termination
let
poolId
=
getPoolId
(
cwd
,
filename
)
const
poolId
=
getPoolId
(
cwd
,
filename
)
const
workers
=
loaderWorkers
[
poolId
]
const
workers
=
loaderWorkers
[
poolId
]
workers
.
get
(
workerId
)?.
terminate
()
workers
.
get
(
workerId
)?.
terminate
()
workers
.
delete
(
workerId
)
workers
.
delete
(
workerId
)
}
}
)
)
...
...
turbopack/crates/turbo-rcstr/src/lib.rs
View file @
7373a852
...
@@ -240,12 +240,6 @@ impl AsRef<[u8]> for RcStr {
...
@@ -240,12 +240,6 @@ impl AsRef<[u8]> for RcStr {
}
}
}
}
impl
AsRef
<
str
>
for
RcStr
{
fn
as_ref
(
&
self
)
->
&
str
{
self
.as_str
()
}
}
impl
From
<
RcStr
>
for
BytesStr
{
impl
From
<
RcStr
>
for
BytesStr
{
fn
from
(
value
:
RcStr
)
->
Self
{
fn
from
(
value
:
RcStr
)
->
Self
{
Self
::
from_str_slice
(
value
.as_str
())
Self
::
from_str_slice
(
value
.as_str
())
...
...
turbopack/crates/turbopack-node/src/evaluate.rs
View file @
7373a852
...
@@ -419,11 +419,11 @@ pub async fn get_evaluate_entries(
...
@@ -419,11 +419,11 @@ pub async fn get_evaluate_entries(
asset_context
:
ResolvedVc
<
Box
<
dyn
AssetContext
>>
,
asset_context
:
ResolvedVc
<
Box
<
dyn
AssetContext
>>
,
runtime_entries
:
Option
<
ResolvedVc
<
EvaluatableAssets
>>
,
runtime_entries
:
Option
<
ResolvedVc
<
EvaluatableAssets
>>
,
)
->
Result
<
Vc
<
EvaluateEntries
>>
{
)
->
Result
<
Vc
<
EvaluateEntries
>>
{
#[cfg(all(feature
=
"process_pool"
,
not(feature
=
"worker_pool"
)))]
let
runtime_module_path
=
if
cfg!
(
all
(
feature
=
"process_pool"
,
not
(
feature
=
"worker_pool"
)))
{
#[allow(unused_variables)]
rcstr!
(
"child_process/evaluate.ts"
)
let
runtime_module_path
=
rcstr!
(
"child_process/evaluate.ts"
);
}
else
{
#[cfg(feature
=
"worker_pool"
)]
rcstr!
(
"worker_thread/evaluate.ts"
)
let
runtime_module_path
=
rcstr!
(
"worker_thread/evaluate.ts"
)
;
}
;
let
runtime_asset
=
asset_context
let
runtime_asset
=
asset_context
.process
(
.process
(
...
@@ -458,17 +458,18 @@ pub async fn get_evaluate_entries(
...
@@ -458,17 +458,18 @@ pub async fn get_evaluate_entries(
let
runtime_entries
=
{
let
runtime_entries
=
{
let
mut
entries
=
vec!
[];
let
mut
entries
=
vec!
[];
let
global_module_path
=
#[cfg(all(feature
=
"process_pool"
,
not(feature
=
"worker_pool"
)))]
if
cfg!
(
all
(
feature
=
"process_pool"
,
not
(
feature
=
"worker_pool"
)))
{
#[allow(unused_variables)]
rcstr!
(
"child_process/globals.ts"
)
let
global_module_path
=
embed_file_path
(
rcstr!
(
"child_process/globals.ts"
));
}
else
{
rcstr!
(
"worker_thread/globals.ts"
)
#[cfg(feature
=
"worker_pool"
)]
};
let
global_module_path
=
embed_file_path
(
rcstr!
(
"worker_thread/globals.ts"
));
let
globals_module
=
asset_context
let
globals_module
=
asset_context
.process
(
.process
(
Vc
::
upcast
(
FileSource
::
new
(
global_module_path
.owned
()
.await
?
)),
Vc
::
upcast
(
FileSource
::
new
(
embed_file_path
(
global_module_path
)
.owned
()
.await
?
,
)),
ReferenceType
::
Internal
(
InnerAssets
::
empty
()
.to_resolved
()
.await
?
),
ReferenceType
::
Internal
(
InnerAssets
::
empty
()
.to_resolved
()
.await
?
),
)
)
.module
();
.module
();
...
...
turbopack/crates/turbopack-node/src/pool_stats.rs
View file @
7373a852
...
@@ -5,16 +5,13 @@ use tokio::sync::OwnedSemaphorePermit;
...
@@ -5,16 +5,13 @@ use tokio::sync::OwnedSemaphorePermit;
pub
enum
AcquiredPermits
{
pub
enum
AcquiredPermits
{
Idle
{
Idle
{
// This is used for drop
// This is used for drop
#[allow(dead_code)]
_concurrency_permit
:
OwnedSemaphorePermit
,
concurrency_permit
:
OwnedSemaphorePermit
,
},
},
Fresh
{
Fresh
{
// This is used for drop
// This is used for drop
#[allow(dead_code)]
_concurrency_permit
:
OwnedSemaphorePermit
,
concurrency_permit
:
OwnedSemaphorePermit
,
// This is used for drop
// This is used for drop
#[allow(dead_code)]
_bootup_permit
:
OwnedSemaphorePermit
,
bootup_permit
:
OwnedSemaphorePermit
,
},
},
}
}
...
...
turbopack/crates/turbopack-node/src/process_pool/mod.rs
View file @
7373a852
...
@@ -603,7 +603,7 @@ impl ChildProcessPool {
...
@@ -603,7 +603,7 @@ impl ChildProcessPool {
select!
{
select!
{
idle_process_result
=
self
.idle_processes
.pop
(
&
ACTIVE_POOLS
)
=>
{
idle_process_result
=
self
.idle_processes
.pop
(
&
ACTIVE_POOLS
)
=>
{
let
process
=
idle_process_result
.context
(
"acquiring idle process permit"
)
?
;
let
process
=
idle_process_result
.context
(
"acquiring idle process permit"
)
?
;
Ok
((
process
,
AcquiredPermits
::
Idle
{
concurrency_permit
}))
Ok
((
process
,
AcquiredPermits
::
Idle
{
_concurrency_permit
:
concurrency_permit
}))
},
},
bootup_permit
=
bootup
=>
{
bootup_permit
=
bootup
=>
{
let
bootup_permit
=
bootup_permit
.context
(
"acquiring bootup permit"
)
?
;
let
bootup_permit
=
bootup_permit
.context
(
"acquiring bootup permit"
)
?
;
...
@@ -619,7 +619,7 @@ impl ChildProcessPool {
...
@@ -619,7 +619,7 @@ impl ChildProcessPool {
}
}
// Increase the allowed booting up processes
// Increase the allowed booting up processes
self
.bootup_semaphore
.add_permits
(
1
);
self
.bootup_semaphore
.add_permits
(
1
);
Ok
((
process
,
AcquiredPermits
::
Fresh
{
concurrency_permit
,
bootup_permit
}))
Ok
((
process
,
AcquiredPermits
::
Fresh
{
_concurrency_permit
:
concurrency_permit
,
_bootup_permit
:
bootup_permit
}))
}
}
}
}
}
}
...
...
turbopack/crates/turbopack-node/src/worker_pool/mod.rs
View file @
7373a852
...
@@ -93,7 +93,12 @@ impl WorkerThreadPool {
...
@@ -93,7 +93,12 @@ impl WorkerThreadPool {
{
{
let
mut
idle
=
self
.state.idle_workers
.lock
();
let
mut
idle
=
self
.state.idle_workers
.lock
();
if
let
Some
(
worker_id
)
=
idle
.pop
()
{
if
let
Some
(
worker_id
)
=
idle
.pop
()
{
return
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
concurrency_permit
}));
return
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
_concurrency_permit
:
concurrency_permit
,
},
));
}
}
}
}
...
@@ -102,7 +107,12 @@ impl WorkerThreadPool {
...
@@ -102,7 +107,12 @@ impl WorkerThreadPool {
let
mut
waiters
=
self
.state.waiters
.lock
();
let
mut
waiters
=
self
.state.waiters
.lock
();
let
mut
idle
=
self
.state.idle_workers
.lock
();
let
mut
idle
=
self
.state.idle_workers
.lock
();
if
let
Some
(
worker_id
)
=
idle
.pop
()
{
if
let
Some
(
worker_id
)
=
idle
.pop
()
{
return
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
concurrency_permit
}));
return
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
_concurrency_permit
:
concurrency_permit
,
},
));
}
}
waiters
.push
(
tx
);
waiters
.push
(
tx
);
}
}
...
@@ -117,7 +127,7 @@ impl WorkerThreadPool {
...
@@ -117,7 +127,7 @@ impl WorkerThreadPool {
select!
{
select!
{
worker_id
=
rx
=>
{
worker_id
=
rx
=>
{
let
worker_id
=
worker_id
?
;
let
worker_id
=
worker_id
?
;
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
concurrency_permit
}))
Ok
((
worker_id
,
AcquiredPermits
::
Idle
{
_concurrency_permit
:
concurrency_permit
}))
}
}
bootup_permit
=
bootup
=>
{
bootup_permit
=
bootup
=>
{
let
bootup_permit
=
bootup_permit
.context
(
"acquiring bootup permit"
)
?
;
let
bootup_permit
=
bootup_permit
.context
(
"acquiring bootup permit"
)
?
;
...
@@ -132,7 +142,7 @@ impl WorkerThreadPool {
...
@@ -132,7 +142,7 @@ impl WorkerThreadPool {
}
}
self
.bootup_semaphore
.add_permits
(
1
);
self
.bootup_semaphore
.add_permits
(
1
);
Ok
((
worker_id
,
AcquiredPermits
::
Fresh
{
concurrency_permit
,
bootup_permit
}))
Ok
((
worker_id
,
AcquiredPermits
::
Fresh
{
_concurrency_permit
:
concurrency_permit
,
_bootup_permit
:
bootup_permit
}))
}
}
}
}
}
}
...
@@ -185,7 +195,7 @@ impl EvaluateOperation for WorkerThreadPool {
...
@@ -185,7 +195,7 @@ impl EvaluateOperation for WorkerThreadPool {
}
}
}
}
})),
})),
permits
,
_permits
:
permits
,
channels
,
channels
,
}
}
};
};
...
...
turbopack/crates/turbopack-node/src/worker_pool/operation.rs
View file @
7373a852
...
@@ -259,8 +259,7 @@ pub(crate) struct WorkerOperation {
...
@@ -259,8 +259,7 @@ pub(crate) struct WorkerOperation {
pub
(
crate
)
worker_id
:
u32
,
pub
(
crate
)
worker_id
:
u32
,
pub
(
crate
)
state
:
Arc
<
PoolState
>
,
pub
(
crate
)
state
:
Arc
<
PoolState
>
,
pub
(
crate
)
on_drop
:
Option
<
Box
<
dyn
FnOnce
(
u32
)
+
Send
+
Sync
>>
,
pub
(
crate
)
on_drop
:
Option
<
Box
<
dyn
FnOnce
(
u32
)
+
Send
+
Sync
>>
,
#[allow(dead_code)]
pub
(
crate
)
_permits
:
AcquiredPermits
,
pub
(
crate
)
permits
:
AcquiredPermits
,
/// Pre-allocated channels for this task
/// Pre-allocated channels for this task
pub
(
crate
)
channels
:
TaskChannels
,
pub
(
crate
)
channels
:
TaskChannels
,
}
}
...
...
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