Skip to content

Commit

Permalink
L0 flush: avoid short-lived allocation when checking key_range empty (#…
Browse files Browse the repository at this point in the history
…8154)

We only use `keys` to check if it's empty so we can bail out early. No
need to collect the keys for that.

Found this while doing research for
#7418
  • Loading branch information
problame committed Jun 25, 2024
1 parent 7026dde commit 947f6da
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pageserver/src/tenant/storage_layer/inmemory_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,18 +622,16 @@ impl InMemoryLayer {

let end_lsn = *self.end_lsn.get().unwrap();

let keys: Vec<_> = if let Some(key_range) = key_range {
let key_count = if let Some(key_range) = key_range {
inner
.index
.iter()
.filter(|(k, _)| key_range.contains(k))
.map(|(k, m)| (k.to_i128(), m))
.collect()
.count()
} else {
inner.index.iter().map(|(k, m)| (k.to_i128(), m)).collect()
inner.index.len()
};

if keys.is_empty() {
if key_count == 0 {
return Ok(None);
}

Expand Down

1 comment on commit 947f6da

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3010 tests run: 2884 passed, 0 failed, 126 skipped (full report)


Flaky tests (2)

Postgres 15

  • test_statvfs_pressure_usage: debug

Postgres 14

Code coverage* (full report)

  • functions: 32.5% (6872 of 21133 functions)
  • lines: 50.2% (53649 of 106975 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
947f6da at 2024-06-25T16:32:00.717Z :recycle:

Please sign in to comment.