Skip to content

Commit 1600ee4

Browse files
committed
dynamic chunksize
1 parent e1509ad commit 1600ee4

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

iris-mpc-store/src/s3_importer.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ const SINGLE_ELEMENT_SIZE: usize = IRIS_CODE_LENGTH * mem::size_of::<u16>() * 2
1010
+ MASK_CODE_LENGTH * mem::size_of::<u16>() * 2
1111
+ mem::size_of::<u32>(); // 75 KB
1212

13-
// Size of each exported chunk. This is only used to allocate the vec for
14-
// storing all records in a chunk. If the chunk is larger than this specified
15-
// size, it will only lead to more allocations.
16-
const CHUNK_SIZE: usize = 1 << 30; // 1 GB
17-
1813
#[async_trait]
1914
pub trait ObjectStore: Send + Sync + 'static {
2015
async fn get_object(&self, key: &str) -> eyre::Result<ByteStream>;
@@ -140,7 +135,7 @@ pub async fn fetch_and_parse_chunks(
140135
let result_stream = stream::iter(chunks)
141136
.map(move |chunk| async move {
142137
let mut object_stream = store.get_object(&chunk).await?.into_async_read();
143-
let mut records = Vec::with_capacity(CHUNK_SIZE / SINGLE_ELEMENT_SIZE);
138+
let mut records = Vec::with_capacity(last_snapshot_details.chunk_size as usize);
144139
let mut buf = vec![0u8; SINGLE_ELEMENT_SIZE];
145140
loop {
146141
match object_stream.read_exact(&mut buf).await {

0 commit comments

Comments
 (0)