Skip to content

Commit bb386a5

Browse files
authored
Turbopack: use unstable sort for better performance (#78764)
### What? Small performance improvement by using unstable sort
1 parent 5d8b19f commit bb386a5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

turbopack/crates/turbo-persistence/src/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<K: StoreKey, const SIZE_SHIFT: usize> Collector<K, SIZE_SHIFT> {
9393
/// Sorts the entries and returns them along with the total key and value sizes. This doesn't
9494
/// clear the entries.
9595
pub fn sorted(&mut self) -> (&[CollectorEntry<K>], usize, usize) {
96-
self.entries.sort_by(|a, b| a.key.cmp(&b.key));
96+
self.entries.sort_unstable_by(|a, b| a.key.cmp(&b.key));
9797
(&self.entries, self.total_key_size, self.total_value_size)
9898
}
9999

turbopack/crates/turbo-persistence/src/write_batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<K: StoreKey + Send + Sync, const FAMILIES: usize> WriteBatch<K, FAMILIES> {
291291

292292
shared_error.into_inner()?;
293293
let seq = self.current_sequence_number.load(Ordering::SeqCst);
294-
new_sst_files.sort_by_key(|(seq, _)| *seq);
294+
new_sst_files.sort_unstable_by_key(|(seq, _)| *seq);
295295
Ok(FinishResult {
296296
sequence_number: seq,
297297
new_sst_files,

0 commit comments

Comments
 (0)