mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
Fix performance problem on Android Sparse images
This was adding ~11 minutes to the boot time with sparse images. BUG=b:151981838 TEST=launch cuttlefish with sparse images. Change-Id: I707258566aee338f742a3a5fe94d0bad8302c447 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2111117 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
This commit is contained in:
parent
0bf8a5590f
commit
f3081b120e
1 changed files with 24 additions and 1 deletions
|
@ -307,11 +307,12 @@ impl FileReadWriteAtVolatile for AndroidSparse {
|
|||
.file
|
||||
.read_at_volatile(subslice, *file_offset + chunk_offset),
|
||||
Chunk::Fill(fill_bytes) => {
|
||||
let chunk_offset_mod = chunk_offset % fill_bytes.len() as u64;
|
||||
let filled_memory: Vec<u8> = fill_bytes
|
||||
.iter()
|
||||
.cloned()
|
||||
.cycle()
|
||||
.skip(chunk_offset as usize)
|
||||
.skip(chunk_offset_mod as usize)
|
||||
.take(subslice.size() as usize)
|
||||
.collect();
|
||||
subslice.copy_from(&filled_memory);
|
||||
|
@ -474,6 +475,28 @@ mod tests {
|
|||
assert_eq!(input_vec, vec![20, 30, 10, 20, 30, 10]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_fill_offset_edges() {
|
||||
let chunks = vec![
|
||||
ChunkWithSize {
|
||||
chunk: Chunk::DontCare,
|
||||
expanded_size: 20,
|
||||
},
|
||||
ChunkWithSize {
|
||||
chunk: Chunk::Fill(vec![10, 20, 30]),
|
||||
expanded_size: 100,
|
||||
},
|
||||
];
|
||||
let mut image = test_image(chunks);
|
||||
let mut input_memory = [55u8; 7];
|
||||
let input_volatile_memory = &mut input_memory[..];
|
||||
image
|
||||
.read_exact_at_volatile(input_volatile_memory.get_slice(0, 7).unwrap(), 39)
|
||||
.expect("Could not read");
|
||||
let input_vec: Vec<u8> = input_memory.into_iter().cloned().collect();
|
||||
assert_eq!(input_vec, vec![20, 30, 10, 20, 30, 10, 20]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_raw() {
|
||||
let chunks = vec![ChunkWithSize {
|
||||
|
|
Loading…
Reference in a new issue