Skip to content

Commit

Permalink
buffer is 4x needed size (openzfs#486)
Browse files Browse the repository at this point in the history
I noticed that these Vec's default to Vec<u32>, so their size in bytes is 4x their .len(). We only need "len" bytes, so this is allocating and zeroing out 4x the data that we need. Change it to be Vec<u8>
  • Loading branch information
ahrens authored Oct 5, 2021
1 parent 0d5e669 commit 3eeeaad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/zfs_object_agent/zettacache/src/block_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl BlockAccess {
let begin = Instant::now();
let _permit = self.outstanding_reads.acquire().await.unwrap();
let vec = tokio::task::spawn_blocking(move || {
let mut v = Vec::new();
let mut v: Vec<u8> = Vec::new();
// XXX use unsafe code to avoid double initializing it?
// XXX directio requires the pointer to be sector-aligned, requiring this grossness
v.resize(usize::from64(extent.size) + sector_size, 0);
Expand Down Expand Up @@ -184,7 +184,7 @@ impl BlockAccess {
let begin = Instant::now();
let _permit = self.outstanding_writes.acquire().await.unwrap();
tokio::task::spawn_blocking(move || {
let mut v = Vec::new();
let mut v: Vec<u8> = Vec::new();
// XXX directio requires the pointer to be sector-aligned, requiring this grossness
v.resize(length + sector_size, 0);
let aligned = unsafe {
Expand Down

0 comments on commit 3eeeaad

Please sign in to comment.