mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-27 08:29:59 +00:00
fix(mito): revert initial builder capacity for TimeSeriesMemtable (#6231)
* fix/initial-builder-cap: ### Enhance Series Initialization and Capacity Management - **`simple_bulk_memtable.rs`**: Updated the `Series` initialization to use `with_capacity` with a specified capacity of 8192, improving memory management. - **`time_series.rs`**: Introduced `with_capacity` method in `Series` to allow custom initial capacity for `ValueBuilder`. Adjusted `INITIAL_BUILDER_CAPACITY` to 16 for more efficient memory usage. Added a new `new` method to maintain backward compatibility. * fix/initial-builder-cap: ### Adjust Memory Allocation in Memtable - **`simple_bulk_memtable.rs`**: Reduced the initial capacity of `Series` from 8192 to 1024 to optimize memory usage. - **`time_series.rs`**: Decreased `INITIAL_BUILDER_CAPACITY` from 16 to 4 to improve efficiency in vector building.
This commit is contained in:
@@ -65,7 +65,7 @@ impl SimpleBulkMemtable {
|
||||
} else {
|
||||
dedup
|
||||
};
|
||||
let series = RwLock::new(Series::new(®ion_metadata));
|
||||
let series = RwLock::new(Series::with_capacity(®ion_metadata, 1024));
|
||||
|
||||
Self {
|
||||
id,
|
||||
|
||||
@@ -60,7 +60,7 @@ use crate::region::options::MergeMode;
|
||||
use crate::row_converter::{DensePrimaryKeyCodec, PrimaryKeyCodecExt};
|
||||
|
||||
/// Initial vector builder capacity.
|
||||
const INITIAL_BUILDER_CAPACITY: usize = 1024 * 8;
|
||||
const INITIAL_BUILDER_CAPACITY: usize = 4;
|
||||
|
||||
/// Vector builder capacity.
|
||||
const BUILDER_CAPACITY: usize = 512;
|
||||
@@ -663,15 +663,19 @@ pub(crate) struct Series {
|
||||
}
|
||||
|
||||
impl Series {
|
||||
pub(crate) fn new(region_metadata: &RegionMetadataRef) -> Self {
|
||||
pub(crate) fn with_capacity(region_metadata: &RegionMetadataRef, builder_cap: usize) -> Self {
|
||||
Self {
|
||||
pk_cache: None,
|
||||
active: ValueBuilder::new(region_metadata, INITIAL_BUILDER_CAPACITY),
|
||||
active: ValueBuilder::new(region_metadata, builder_cap),
|
||||
frozen: vec![],
|
||||
region_metadata: region_metadata.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(region_metadata: &RegionMetadataRef) -> Self {
|
||||
Self::with_capacity(region_metadata, INITIAL_BUILDER_CAPACITY)
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.active.len() == 0 && self.frozen.is_empty()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user