-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cubestore): skip WAL, partition data directly during ingestion (#…
…2002) On my machine, this produces 1.8x improvement in ingestion speed. Wins in prod environment should be higher, since WAL uploads are more expensive.
- Loading branch information
1 parent
90f2365
commit 5442fad
Showing
8 changed files
with
266 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::CubeError; | ||
use std::sync::Arc; | ||
use tokio::sync::{OwnedSemaphorePermit, Semaphore}; | ||
|
||
/// Use to limit memory usage on parallel operations. The object has reference semantics, i.e. | ||
/// cloning will share the same underlying limits. | ||
/// | ||
/// Example: | ||
/// ```ignore | ||
/// use cubestore::import::limits::ConcurrencyLimits; | ||
/// async fn do_work(limits: &ConcurrencyLimits) { | ||
/// loop // run processing in parallel, but limit the number of active data frames. | ||
/// { | ||
/// let permit = limits.acquire_data_frame().await?; | ||
/// // ... read data frame | ||
/// tokio::spawn(async move || { | ||
/// // ... process data frame | ||
/// std::mem::drop(permit) | ||
/// }) | ||
/// } | ||
/// } | ||
/// ``` | ||
#[derive(Clone)] | ||
pub struct ConcurrencyLimits { | ||
active_data_frames: Arc<Semaphore>, | ||
} | ||
|
||
impl ConcurrencyLimits { | ||
pub fn new(max_data_frames: usize) -> ConcurrencyLimits { | ||
assert!(1 <= max_data_frames, "no data frames can be processed"); | ||
ConcurrencyLimits { | ||
active_data_frames: Arc::new(Semaphore::new(max_data_frames)), | ||
} | ||
} | ||
|
||
pub async fn acquire_data_frame(&self) -> Result<OwnedSemaphorePermit, CubeError> { | ||
Ok(self.active_data_frames.clone().acquire_owned().await?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.