Skip to content

Commit 8f89c1c

Browse files
authored
feat: Use buf write to reduce system call on index write (#2579)
1 parent b5e375a commit 8f89c1c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

native/core/src/execution/shuffle/shuffle_writer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,23 +983,24 @@ impl ShufflePartitioner for SinglePartitionShufflePartitioner {
983983
self.output_data_writer.flush(&self.metrics.write_time)?;
984984

985985
// Write index file. It should only contain 2 entries: 0 and the total number of bytes written
986-
let mut index_file = OpenOptions::new()
986+
let index_file = OpenOptions::new()
987987
.write(true)
988988
.create(true)
989989
.truncate(true)
990990
.open(self.output_index_path.clone())
991991
.map_err(|e| DataFusionError::Execution(format!("shuffle write error: {e:?}")))?;
992+
let mut index_buf_writer = BufWriter::new(index_file);
992993
let data_file_length = self
993994
.output_data_writer
994995
.writer
995996
.stream_position()
996997
.map_err(to_df_err)?;
997998
for offset in [0, data_file_length] {
998-
index_file
999+
index_buf_writer
9991000
.write_all(&(offset as i64).to_le_bytes()[..])
10001001
.map_err(to_df_err)?;
10011002
}
1002-
index_file.flush()?;
1003+
index_buf_writer.flush()?;
10031004

10041005
self.metrics
10051006
.baseline

0 commit comments

Comments
 (0)