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
fa327485
Commit
fa327485
authored
Feb 11, 2026
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update bench
parent
1b05c557
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
311 deletions
+173
-311
bench-rsc-reviver.js
bench-rsc-reviver.js
+40
-32
bench-rsc-walk.js
bench-rsc-walk.js
+111
-256
bench-table-1000.js
bench-table-1000.js
+22
-23
No files found.
bench-rsc-reviver.js
View file @
fa327485
...
@@ -134,8 +134,8 @@ function createFromJSONCallback_A(response) {
...
@@ -134,8 +134,8 @@ function createFromJSONCallback_A(response) {
(
initializingHandler_A
=
value
.
parent
),
(
initializingHandler_A
=
value
.
parent
),
value
.
errored
)
value
.
errored
)
)
)
(
key
=
new
ReactPromise
(
'rejected'
,
null
,
value
.
reason
)),
(
(
key
=
new
ReactPromise
(
'rejected'
,
null
,
value
.
reason
)),
(
key
=
createLazyChunkWrapper
(
key
))
(
key
=
createLazyChunkWrapper
(
key
))
)
else
if
(
0
<
value
.
deps
)
{
else
if
(
0
<
value
.
deps
)
{
var
blockedChunk
=
new
ReactPromise
(
'blocked'
,
null
,
null
)
var
blockedChunk
=
new
ReactPromise
(
'blocked'
,
null
,
null
)
value
.
value
=
key
value
.
value
=
key
...
@@ -279,10 +279,7 @@ function createFromJSONCallback_C(response) {
...
@@ -279,10 +279,7 @@ function createFromJSONCallback_C(response) {
createLazyChunkWrapper
(
response
)
createLazyChunkWrapper
(
response
)
)
)
case
64
:
case
64
:
return
(
return
((
key
=
parseInt
(
value
.
slice
(
2
),
16
)),
getChunk
(
response
,
key
))
(
key
=
parseInt
(
value
.
slice
(
2
),
16
)),
getChunk
(
response
,
key
)
)
case
83
:
case
83
:
return
Symbol
.
for
(
value
.
slice
(
2
))
return
Symbol
.
for
(
value
.
slice
(
2
))
case
73
:
case
73
:
...
@@ -375,13 +372,7 @@ function postProcessWalk(response, obj) {
...
@@ -375,13 +372,7 @@ function postProcessWalk(response, obj) {
case
110
:
case
110
:
return
BigInt
(
obj
.
slice
(
2
))
return
BigInt
(
obj
.
slice
(
2
))
default
:
default
:
return
getOutlinedModel
(
return
getOutlinedModel
(
response
,
obj
.
slice
(
1
),
null
,
''
,
createModel
)
response
,
obj
.
slice
(
1
),
null
,
''
,
createModel
)
}
}
}
}
if
(
typeof
obj
!==
'object'
||
obj
===
null
)
return
obj
if
(
typeof
obj
!==
'object'
||
obj
===
null
)
return
obj
...
@@ -469,13 +460,7 @@ function reviverFn_F(key, value) {
...
@@ -469,13 +460,7 @@ function reviverFn_F(key, value) {
default
:
default
:
return
(
return
(
(
value
=
value
.
slice
(
1
)),
(
value
=
value
.
slice
(
1
)),
getOutlinedModel
(
getOutlinedModel
(
currentResponse_F
,
value
,
this
,
key
,
createModel
)
currentResponse_F
,
value
,
this
,
key
,
createModel
)
)
)
}
}
}
}
...
@@ -752,21 +737,30 @@ function runSuite(payloadName, payload, iterations) {
...
@@ -752,21 +737,30 @@ function runSuite(payloadName, payload, iterations) {
name
:
'A: Original (prod)'
,
name
:
'A: Original (prod)'
,
fn
:
()
=>
{
fn
:
()
=>
{
initializingHandler_A
=
null
initializingHandler_A
=
null
return
JSON
.
parse
(
payload
,
createFromJSONCallback_A
(
createMockResponse
()))
return
JSON
.
parse
(
payload
,
createFromJSONCallback_A
(
createMockResponse
())
)
},
},
},
},
{
{
name
:
'B: charCodeAt+earlyRet'
,
name
:
'B: charCodeAt+earlyRet'
,
fn
:
()
=>
{
fn
:
()
=>
{
initializingHandler_B
=
null
initializingHandler_B
=
null
return
JSON
.
parse
(
payload
,
createFromJSONCallback_B
(
createMockResponse
()))
return
JSON
.
parse
(
payload
,
createFromJSONCallback_B
(
createMockResponse
())
)
},
},
},
},
{
{
name
:
'C: Fully inlined'
,
name
:
'C: Fully inlined'
,
fn
:
()
=>
{
fn
:
()
=>
{
initializingHandler_C
=
null
initializingHandler_C
=
null
return
JSON
.
parse
(
payload
,
createFromJSONCallback_C
(
createMockResponse
()))
return
JSON
.
parse
(
payload
,
createFromJSONCallback_C
(
createMockResponse
())
)
},
},
},
},
{
{
...
@@ -818,8 +812,7 @@ function runSuite(payloadName, payload, iterations) {
...
@@ -818,8 +812,7 @@ function runSuite(payloadName, payload, iterations) {
// Show reviver overhead vs bare JSON.parse
// Show reviver overhead vs bare JSON.parse
const
baseline
=
results
[
results
.
length
-
1
]
const
baseline
=
results
[
results
.
length
-
1
]
const
origOverhead
=
const
origOverhead
=
((
results
[
0
].
avg
-
baseline
.
avg
)
/
baseline
.
avg
)
*
100
((
results
[
0
].
avg
-
baseline
.
avg
)
/
baseline
.
avg
)
*
100
console
.
log
(
console
.
log
(
`\n Reviver overhead vs bare JSON.parse: +
${
origOverhead
.
toFixed
(
1
)}
%`
`\n Reviver overhead vs bare JSON.parse: +
${
origOverhead
.
toFixed
(
1
)}
%`
)
)
...
@@ -837,13 +830,22 @@ function runParseModelStringMicro() {
...
@@ -837,13 +830,22 @@ function runParseModelStringMicro() {
const
parentObj
=
{}
const
parentObj
=
{}
const
plainStrings
=
[
const
plainStrings
=
[
'div'
,
'span'
,
'p'
,
'h1'
,
'h2'
,
'a'
,
'button'
,
'div'
,
'span'
,
'p'
,
'h1'
,
'h2'
,
'a'
,
'button'
,
'text-sm font-medium leading-6 text-gray-900'
,
'text-sm font-medium leading-6 text-gray-900'
,
'flex items-center justify-between gap-x-6 py-5'
,
'flex items-center justify-between gap-x-6 py-5'
,
'mx-auto max-w-2xl text-center'
,
'mx-auto max-w-2xl text-center'
,
'Hello World'
,
'Hello World'
,
'Some longer text content that appears in a paragraph'
,
'Some longer text content that appears in a paragraph'
,
'/api/data'
,
'/getting-started'
,
'container'
,
'main-content'
,
'/api/data'
,
'/getting-started'
,
'container'
,
'main-content'
,
'inline-flex items-center rounded-md bg-green-50 px-2 py-1'
,
'inline-flex items-center rounded-md bg-green-50 px-2 py-1'
,
'border-b border-gray-200 py-4'
,
'border-b border-gray-200 py-4'
,
'text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl'
,
'text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl'
,
...
@@ -851,7 +853,8 @@ function runParseModelStringMicro() {
...
@@ -851,7 +853,8 @@ function runParseModelStringMicro() {
]
]
const
testValues
=
[]
const
testValues
=
[]
for
(
let
i
=
0
;
i
<
600
;
i
++
)
testValues
.
push
(
plainStrings
[
i
%
plainStrings
.
length
])
for
(
let
i
=
0
;
i
<
600
;
i
++
)
testValues
.
push
(
plainStrings
[
i
%
plainStrings
.
length
])
for
(
let
i
=
0
;
i
<
150
;
i
++
)
testValues
.
push
(
'$'
)
for
(
let
i
=
0
;
i
<
150
;
i
++
)
testValues
.
push
(
'$'
)
for
(
let
i
=
0
;
i
<
200
;
i
++
)
testValues
.
push
(
'$'
+
(
i
%
64
).
toString
(
16
))
for
(
let
i
=
0
;
i
<
200
;
i
++
)
testValues
.
push
(
'$'
+
(
i
%
64
).
toString
(
16
))
for
(
let
i
=
0
;
i
<
50
;
i
++
)
for
(
let
i
=
0
;
i
<
50
;
i
++
)
...
@@ -876,14 +879,16 @@ function runParseModelStringMicro() {
...
@@ -876,14 +879,16 @@ function runParseModelStringMicro() {
for
(
const
{
name
,
fn
}
of
parsers
)
{
for
(
const
{
name
,
fn
}
of
parsers
)
{
// Warmup
// Warmup
for
(
let
w
=
0
;
w
<
500
;
w
++
)
{
for
(
let
w
=
0
;
w
<
500
;
w
++
)
{
for
(
let
i
=
0
;
i
<
testValues
.
length
;
i
++
)
fn
(
response
,
parentObj
,
'0'
,
testValues
[
i
])
for
(
let
i
=
0
;
i
<
testValues
.
length
;
i
++
)
fn
(
response
,
parentObj
,
'0'
,
testValues
[
i
])
}
}
if
(
global
.
gc
)
global
.
gc
()
if
(
global
.
gc
)
global
.
gc
()
const
times
=
[]
const
times
=
[]
for
(
let
b
=
0
;
b
<
iterations
;
b
++
)
{
for
(
let
b
=
0
;
b
<
iterations
;
b
++
)
{
const
start
=
performance
.
now
()
const
start
=
performance
.
now
()
for
(
let
i
=
0
;
i
<
testValues
.
length
;
i
++
)
fn
(
response
,
parentObj
,
'0'
,
testValues
[
i
])
for
(
let
i
=
0
;
i
<
testValues
.
length
;
i
++
)
fn
(
response
,
parentObj
,
'0'
,
testValues
[
i
])
times
.
push
(
performance
.
now
()
-
start
)
times
.
push
(
performance
.
now
()
-
start
)
}
}
times
.
sort
((
a
,
b
)
=>
a
-
b
)
times
.
sort
((
a
,
b
)
=>
a
-
b
)
...
@@ -895,14 +900,17 @@ function runParseModelStringMicro() {
...
@@ -895,14 +900,17 @@ function runParseModelStringMicro() {
})
})
}
}
console
.
log
(
`
${
testValues
.
length
}
calls per iteration,
${
iterations
}
iterations\n`
)
console
.
log
(
`
${
testValues
.
length
}
calls per iteration,
${
iterations
}
iterations\n`
)
console
.
log
(
console
.
log
(
`
${
'Variant'
.
padEnd
(
20
)}
${
'Avg (ms)'
.
padStart
(
10
)}
${
'P50 (ms)'
.
padStart
(
10
)}
${
'Min (ms)'
.
padStart
(
10
)}
${
'vs Orig'
.
padStart
(
9
)}
`
`
${
'Variant'
.
padEnd
(
20
)}
${
'Avg (ms)'
.
padStart
(
10
)}
${
'P50 (ms)'
.
padStart
(
10
)}
${
'Min (ms)'
.
padStart
(
10
)}
${
'vs Orig'
.
padStart
(
9
)}
`
)
)
console
.
log
(
`
${
'-'
.
repeat
(
59
)}
`
)
console
.
log
(
`
${
'-'
.
repeat
(
59
)}
`
)
for
(
const
r
of
allResults
)
{
for
(
const
r
of
allResults
)
{
const
sp
=
((
allResults
[
0
].
avg
-
r
.
avg
)
/
allResults
[
0
].
avg
)
*
100
const
sp
=
((
allResults
[
0
].
avg
-
r
.
avg
)
/
allResults
[
0
].
avg
)
*
100
const
spStr
=
r
===
allResults
[
0
]
?
' -'
:
`
${
sp
>
0
?
'+'
:
''
}${
sp
.
toFixed
(
1
)}
%`
const
spStr
=
r
===
allResults
[
0
]
?
' -'
:
`
${
sp
>
0
?
'+'
:
''
}${
sp
.
toFixed
(
1
)}
%`
console
.
log
(
console
.
log
(
`
${
r
.
name
.
padEnd
(
20
)}
${
r
.
avg
.
toFixed
(
4
).
padStart
(
10
)}
${
r
.
p50
.
toFixed
(
4
).
padStart
(
10
)}
${
r
.
min
.
toFixed
(
4
).
padStart
(
10
)}
${
spStr
.
padStart
(
9
)}
`
`
${
r
.
name
.
padEnd
(
20
)}
${
r
.
avg
.
toFixed
(
4
).
padStart
(
10
)}
${
r
.
p50
.
toFixed
(
4
).
padStart
(
10
)}
${
r
.
min
.
toFixed
(
4
).
padStart
(
10
)}
${
spStr
.
padStart
(
9
)}
`
)
)
...
...
bench-rsc-walk.js
View file @
fa327485
This diff is collapsed.
Click to expand it.
bench-table-1000.js
View file @
fa327485
...
@@ -186,7 +186,13 @@ function runBench(label, internals, jsonPayload, iterations) {
...
@@ -186,7 +186,13 @@ function runBench(label, internals, jsonPayload, iterations) {
function
makeResponse
()
{
function
makeResponse
()
{
return
new
ResponseInstance
(
return
new
ResponseInstance
(
null
,
null
,
null
,
undefined
,
undefined
,
undefined
,
undefined
null
,
null
,
null
,
undefined
,
undefined
,
undefined
,
undefined
)
)
}
}
...
@@ -265,7 +271,9 @@ function printResults(suite, results) {
...
@@ -265,7 +271,9 @@ function printResults(suite, results) {
console
.
log
(
'<Table> RSC payload benchmark — reviver vs walk'
)
console
.
log
(
'<Table> RSC payload benchmark — reviver vs walk'
)
console
.
log
(
`Node.js
${
process
.
version
}
`
)
console
.
log
(
`Node.js
${
process
.
version
}
`
)
console
.
log
(
`GC:
${
typeof
global
.
gc
===
'function'
?
'yes'
:
'no (use --expose-gc)'
}
`
)
console
.
log
(
`GC:
${
typeof
global
.
gc
===
'function'
?
'yes'
:
'no (use --expose-gc)'
}
`
)
console
.
log
()
console
.
log
()
console
.
log
(
'Loading variants...'
)
console
.
log
(
'Loading variants...'
)
...
@@ -280,31 +288,22 @@ console.log(` 1000 rows: ${(payload1000.length / 1024).toFixed(1)} KB`)
...
@@ -280,31 +288,22 @@ console.log(` 1000 rows: ${(payload1000.length / 1024).toFixed(1)} KB`)
console
.
log
(
` 5000 rows:
${(
payload5000
.
length
/
1024
).
toFixed
(
1
)}
KB`
)
console
.
log
(
` 5000 rows:
${(
payload5000
.
length
/
1024
).
toFixed
(
1
)}
KB`
)
// --- 100 rows ---
// --- 100 rows ---
printResults
(
printResults
(
'Table with 100 rows (baseline)'
,
[
'Table with 100 rows (baseline)'
,
runBench
(
'Original (reviver)'
,
origInternals
,
payload100
,
10000
),
[
runBench
(
'Walk'
,
walkInternals
,
payload100
,
10000
),
runBench
(
'Original (reviver)'
,
origInternals
,
payload100
,
10000
),
])
runBench
(
'Walk'
,
walkInternals
,
payload100
,
10000
),
]
)
// --- 1000 rows ---
// --- 1000 rows ---
printResults
(
printResults
(
'Table with 1,000 rows'
,
[
'Table with 1,000 rows'
,
runBench
(
'Original (reviver)'
,
origInternals
,
payload1000
,
2000
),
[
runBench
(
'Walk'
,
walkInternals
,
payload1000
,
2000
),
runBench
(
'Original (reviver)'
,
origInternals
,
payload1000
,
2000
),
])
runBench
(
'Walk'
,
walkInternals
,
payload1000
,
2000
),
]
)
// --- 5000 rows ---
// --- 5000 rows ---
printResults
(
printResults
(
'Table with 5,000 rows'
,
[
'Table with 5,000 rows'
,
runBench
(
'Original (reviver)'
,
origInternals
,
payload5000
,
500
),
[
runBench
(
'Walk'
,
walkInternals
,
payload5000
,
500
),
runBench
(
'Original (reviver)'
,
origInternals
,
payload5000
,
500
),
])
runBench
(
'Walk'
,
walkInternals
,
payload5000
,
500
),
]
)
// Cleanup temp file
// Cleanup temp file
try
{
try
{
...
...
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