@@ -89,6 +89,12 @@ pub struct Options {
8989 /// Has no effect if the `fallocate` feature is not enabled.
9090 #[ cfg_attr( feature = "serde" , serde( default = "Options::default_preallocate_segments" ) ) ]
9191 pub preallocate_segments : bool ,
92+ /// Size in bytes of the memory buffer holding commit data before flushing
93+ /// to storage.
94+ ///
95+ /// Default: 4KiB
96+ #[ cfg_attr( feature = "serde" , serde( default = "Options::default_write_buffer_size" ) ) ]
97+ pub write_buffer_size : usize ,
9298}
9399
94100impl Default for Options {
@@ -102,13 +108,15 @@ impl Options {
102108 pub const DEFAULT_OFFSET_INDEX_INTERVAL_BYTES : NonZeroU64 = NonZeroU64 :: new ( 4096 ) . expect ( "4096 > 0, qed" ) ;
103109 pub const DEFAULT_OFFSET_INDEX_REQUIRE_SEGMENT_FSYNC : bool = false ;
104110 pub const DEFAULT_PREALLOCATE_SEGMENTS : bool = false ;
111+ pub const DEFAULT_WRITE_BUFFER_SIZE : usize = 4 * 1024 ;
105112
106113 pub const DEFAULT : Self = Self {
107114 log_format_version : DEFAULT_LOG_FORMAT_VERSION ,
108115 max_segment_size : Self :: default_max_segment_size ( ) ,
109116 offset_index_interval_bytes : Self :: default_offset_index_interval_bytes ( ) ,
110117 offset_index_require_segment_fsync : Self :: default_offset_index_require_segment_fsync ( ) ,
111118 preallocate_segments : Self :: default_preallocate_segments ( ) ,
119+ write_buffer_size : Self :: default_write_buffer_size ( ) ,
112120 } ;
113121
114122 pub const fn default_log_format_version ( ) -> u8 {
@@ -131,6 +139,10 @@ impl Options {
131139 Self :: DEFAULT_PREALLOCATE_SEGMENTS
132140 }
133141
142+ pub const fn default_write_buffer_size ( ) -> usize {
143+ Self :: DEFAULT_WRITE_BUFFER_SIZE
144+ }
145+
134146 /// Compute the length in bytes of an offset index based on the settings in
135147 /// `self`.
136148 pub fn offset_index_len ( & self ) -> u64 {
0 commit comments