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
c40ff2e8
Commit
c40ff2e8
authored
Mar 04, 2026
by
Luke Sandberg
Committed by
Luke Sandberg
Mar 11, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make compression conditional based on key length
parent
7640d0bd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
static_sorted_file_builder.rs
...rates/turbo-persistence/src/static_sorted_file_builder.rs
+9
-1
No files found.
turbopack/crates/turbo-persistence/src/static_sorted_file_builder.rs
View file @
c40ff2e8
...
@@ -53,6 +53,13 @@ const AVG_SMALL_VALUE_SIZE: usize = 64;
...
@@ -53,6 +53,13 @@ const AVG_SMALL_VALUE_SIZE: usize = 64;
/// byte-size based estimates of pending key blocks.
/// byte-size based estimates of pending key blocks.
const
BLOCK_INDEX_CAPACITY_BUFFER
:
usize
=
16
;
const
BLOCK_INDEX_CAPACITY_BUFFER
:
usize
=
16
;
/// Minimum key size (in bytes) for attempting LZ4 compression on key blocks.
///
/// Keys are sorted by hash, so we should not expect correlation in the data between nearby keys in
/// a block. For small keys (below this threshold), compression is unlikely to be able to exploit
/// patterns and only wastes CPU time. We skip the compression attempt entirely in this case.
const
MIN_KEY_SIZE_FOR_COMPRESSION
:
usize
=
8
;
/// Maximum key length that can use fixed-size key block layout.
/// Maximum key length that can use fixed-size key block layout.
///
///
/// The on-disk fixed-key header stores the key size as a single byte, so keys longer than this
/// The on-disk fixed-key header stores the key size as a single byte, so keys longer than this
...
@@ -838,6 +845,7 @@ impl<E: Entry> StreamingSstWriter<E> {
...
@@ -838,6 +845,7 @@ impl<E: Entry> StreamingSstWriter<E> {
fn
flush_key_block
(
&
mut
self
,
start
:
usize
,
end
:
usize
,
info
:
KeyBlockFlushInfo
)
->
Result
<
()
>
{
fn
flush_key_block
(
&
mut
self
,
start
:
usize
,
end
:
usize
,
info
:
KeyBlockFlushInfo
)
->
Result
<
()
>
{
let
entry_count
=
end
-
start
;
let
entry_count
=
end
-
start
;
let
has_hash
=
use_hash
(
info
.max_key_len
);
let
has_hash
=
use_hash
(
info
.max_key_len
);
let
try_compress
=
info
.max_key_len
>=
MIN_KEY_SIZE_FOR_COMPRESSION
;
self
.key_buffer
.clear
();
self
.key_buffer
.clear
();
...
@@ -877,7 +885,7 @@ impl<E: Entry> StreamingSstWriter<E> {
...
@@ -877,7 +885,7 @@ impl<E: Entry> StreamingSstWriter<E> {
&
mut
self
.compress_buffer
,
&
mut
self
.compress_buffer
,
&
mut
self
.block_offsets
,
&
mut
self
.block_offsets
,
&
self
.key_buffer
,
&
self
.key_buffer
,
tr
ue
,
tr
y_compress
,
)
)
.context
(
"Failed to write key block"
)
?
;
.context
(
"Failed to write key block"
)
?
;
self
.key_block_boundaries
.push
((
first_hash
,
block_index
));
self
.key_block_boundaries
.push
((
first_hash
,
block_index
));
...
...
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