Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct multiplier for parquet cache size #25416

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions influxdb3/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub struct Config {
default_value = "1000",
action
)]
pub parquet_mem_cache_size: usize,
pub parquet_mem_cache_size: ParquetCacheSizeMb,

/// The percentage of entries to prune during a prune operation on the in-memory Parquet cache.
///
Expand All @@ -236,7 +236,7 @@ pub struct Config {
default_value = "0.1",
action
)]
pub parquet_mem_cache_prune_percentage: PrunePercent,
pub parquet_mem_cache_prune_percentage: ParquetCachePrunePercent,

/// The interval on which to check if the in-memory Parquet cache needs to be pruned.
///
Expand All @@ -259,16 +259,37 @@ pub struct Config {
pub disable_parquet_mem_cache: bool,
}

/// Specified size of the Parquet cache in megabytes (MB)
#[derive(Debug, Clone, Copy)]
pub struct PrunePercent(f64);
pub struct ParquetCacheSizeMb(usize);

impl From<PrunePercent> for f64 {
fn from(value: PrunePercent) -> Self {
impl ParquetCacheSizeMb {
/// Express this cache size in terms of bytes (B)
fn as_num_bytes(&self) -> usize {
self.0 * 1_000 * 1_000
}
}

impl FromStr for ParquetCacheSizeMb {
type Err = anyhow::Error;

fn from_str(s: &str) -> std::prelude::v1::Result<Self, Self::Err> {
s.parse()
.context("failed to parse parquet cache size value as an unsigned integer")
.map(Self)
}
}

#[derive(Debug, Clone, Copy)]
pub struct ParquetCachePrunePercent(f64);

impl From<ParquetCachePrunePercent> for f64 {
fn from(value: ParquetCachePrunePercent) -> Self {
value.0
}
}

impl FromStr for PrunePercent {
impl FromStr for ParquetCachePrunePercent {
type Err = anyhow::Error;

fn from_str(s: &str) -> std::prelude::v1::Result<Self, Self::Err> {
Expand Down Expand Up @@ -330,7 +351,7 @@ pub async fn command(config: Config) -> Result<()> {
let (object_store, parquet_cache) = create_cached_obj_store_and_oracle(
object_store,
Arc::clone(&time_provider) as _,
config.parquet_mem_cache_size * 1_000,
config.parquet_mem_cache_size.as_num_bytes(),
config.parquet_mem_cache_prune_percentage.into(),
config.parquet_mem_cache_prune_interval.into(),
);
Expand Down