Skip to content
Draft
Show file tree
Hide file tree
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
88 changes: 65 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ version = "0.1.0"
[workspace.dependencies]
# The backend depends on two Planner crates, at one immutable revision:
# `asap-planner` to plan and `asap-executor` to execute. Planner IR types
# are reached through `asap_executor::planner`.
asap-planner = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "b9c7fdfa09f8854d4ae201183637038ee0f6bd36" }
asap-executor = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "b9c7fdfa09f8854d4ae201183637038ee0f6bd36" }
# are reached through `asap_executor::planner`. Draft pin: the Planner's
# `feat/parallel-query-exec` head (stacked on #1553), for query runs split
# by group key over worker threads.
asap-planner = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "74621ba2afb820f576a26c37c067e93b057e3716" }
asap-executor = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "74621ba2afb820f576a26c37c067e93b057e3716" }
# The sketch library the Planner's executor pins, for the byte encodings of
# the sketch states the data plane persists; keep it at the Planner's rev
# (draft: ASAPPlanner#1553 head, for SIL intents).
Expand Down
4 changes: 3 additions & 1 deletion data_plane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ prost = "0.13"
rmp-serde = "1"
snap = "1.1"
futures = "0.3"
# Query runs split over worker threads (`--query-parallelism`).
rayon = "1.10"
form_urlencoded = "1"

[dev-dependencies]
# Parses SIL intents for the intent round loop's end-to-end test.
asap-frontend-sil = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "b9c7fdfa09f8854d4ae201183637038ee0f6bd36" }
asap-frontend-sil = { git = "https://github.com/ProjectASAP/ASAPPlanner", rev = "74621ba2afb820f576a26c37c067e93b057e3716" }
# Paused time for the intent loop's latency and overrun tests.
tokio = { workspace = true, features = ["test-util"] }
control_plane.workspace = true
Expand Down
40 changes: 40 additions & 0 deletions data_plane/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ pub struct EngineOptions {
/// hold `run_memory_limit_bytes`, so queries may hold up to this many
/// times that.
pub query_threads: usize,
/// Parts one query run splits each grouped build and merge into (by
/// group key, on the query worker pool), turning on parallel raw shard
/// reads too; 1: every run on its query worker alone. The answers are
/// the same for any value.
pub query_parallelism: usize,
/// Threads of the query worker pool (rayon's global pool, sized once per
/// process) that runs those parts. Ingest, precompute and persist
/// threads share the same cores; leave them room on a busy server.
pub query_pool_threads: usize,
/// For tests: split query runs' grouped builds and merges over inputs
/// this small (`RunContext::with_min_split_rows`); `None`: the
/// executor's default.
#[doc(hidden)]
pub query_min_split_rows: Option<usize>,
/// Compute each query-time `OneEvaluation` node several queries read
/// once per evaluation time, as the plan says; `false` computes it in
/// every query's run (for comparison).
Expand Down Expand Up @@ -219,6 +233,9 @@ impl Default for EngineOptions {
no_forward: false,
run_memory_limit_bytes: 4 << 30,
query_threads: std::thread::available_parallelism().map_or(1, usize::from),
query_parallelism: std::thread::available_parallelism().map_or(1, usize::from),
query_pool_threads: std::thread::available_parallelism().map_or(1, usize::from),
query_min_split_rows: None,
share_one_evaluation_results: true,
label_pushdown: true,
query_time_results_retention_ms: 60_000,
Expand Down Expand Up @@ -480,6 +497,29 @@ impl EngineHandle {
let mut metrics = Metrics::new(&groups, &query_texts);
let query = query.with_raw_reads(options.label_pushdown, metrics.query_raw_reads.clone());
metrics.ingestion_raw_reads = ingestion_raw_reads;
let query_parallelism = options.query_parallelism.max(1);
if query_parallelism > 1 {
let threads = options.query_pool_threads.max(1);
// Sized once per process: a second engine in the process (tests)
// keeps the first one's pool.
if let Err(error) = rayon::ThreadPoolBuilder::new()
.num_threads(threads)
.thread_name(|index| format!("query-part-{index}"))
.build_global()
{
tracing::warn!(%error, threads, pool = rayon::current_num_threads(),
"the query worker pool already exists; keeping its size");
}
metrics
.query_pool_threads
.store(rayon::current_num_threads() as u64, Ordering::Relaxed);
}
let query = query.with_parallelism(
query_parallelism,
options.query_min_split_rows,
metrics.query_parallel_tasks.clone(),
metrics.query_parallel_cpu_ns.clone(),
);
if let Some(tier) = &tier {
let _ = metrics.view_tier.set(tier.clone());
}
Expand Down
Loading