Unverified Commit bb386a5c authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: use unstable sort for better performance (#78764)

### What?

Small performance improvement by using unstable sort
parent 5d8b19f0
...@@ -93,7 +93,7 @@ impl<K: StoreKey, const SIZE_SHIFT: usize> Collector<K, SIZE_SHIFT> { ...@@ -93,7 +93,7 @@ impl<K: StoreKey, const SIZE_SHIFT: usize> Collector<K, SIZE_SHIFT> {
/// Sorts the entries and returns them along with the total key and value sizes. This doesn't /// Sorts the entries and returns them along with the total key and value sizes. This doesn't
/// clear the entries. /// clear the entries.
pub fn sorted(&mut self) -> (&[CollectorEntry<K>], usize, usize) { pub fn sorted(&mut self) -> (&[CollectorEntry<K>], usize, usize) {
self.entries.sort_by(|a, b| a.key.cmp(&b.key)); self.entries.sort_unstable_by(|a, b| a.key.cmp(&b.key));
(&self.entries, self.total_key_size, self.total_value_size) (&self.entries, self.total_key_size, self.total_value_size)
} }
......
...@@ -291,7 +291,7 @@ impl<K: StoreKey + Send + Sync, const FAMILIES: usize> WriteBatch<K, FAMILIES> { ...@@ -291,7 +291,7 @@ impl<K: StoreKey + Send + Sync, const FAMILIES: usize> WriteBatch<K, FAMILIES> {
shared_error.into_inner()?; shared_error.into_inner()?;
let seq = self.current_sequence_number.load(Ordering::SeqCst); let seq = self.current_sequence_number.load(Ordering::SeqCst);
new_sst_files.sort_by_key(|(seq, _)| *seq); new_sst_files.sort_unstable_by_key(|(seq, _)| *seq);
Ok(FinishResult { Ok(FinishResult {
sequence_number: seq, sequence_number: seq,
new_sst_files, new_sst_files,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment