Skip to content

Commit 4144a3e

Browse files
authored
perf: remove two redundant object-store calls in datasets metadata fetch (#1760)
get_manifest_list fetched the base stream.json unconditionally, but on Query/Prism-mode nodes that result was never read since those modes merge every ingestor's stream.json instead. Move the fetch into the branch that actually needs it (Mode::All). get_first_and_latest_event_from_storage awaited its two independent extract_timestamp_for_date calls sequentially. Run them concurrently with try_join! instead. Both are part of the object-store I/O behind POST /api/prism/v1/datasets, which has been observed taking 50s+ on multi-TB, multi-day deployments.
1 parent ee024e5 commit 4144a3e

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

‎src/query/mod.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -798,14 +798,6 @@ pub async fn get_manifest_list(
798798
time_range: &TimeRange,
799799
tenant_id: &Option<String>,
800800
) -> Result<Vec<Manifest>, QueryError> {
801-
// get object store
802-
let object_store_format: ObjectStoreFormat = serde_json::from_slice(
803-
&PARSEABLE
804-
.metastore
805-
.get_stream_json(stream_name, false, tenant_id, false)
806-
.await?,
807-
)?;
808-
809801
// all the manifests will go here
810802
let mut merged_snapshot: Snapshot = Snapshot::default();
811803

@@ -826,6 +818,14 @@ pub async fn get_manifest_list(
826818
}
827819
}
828820
} else {
821+
// Only needed here: Query/Prism mode merges every ingestor's stream.json
822+
// above instead and never reads the base file.
823+
let object_store_format: ObjectStoreFormat = serde_json::from_slice(
824+
&PARSEABLE
825+
.metastore
826+
.get_stream_json(stream_name, false, tenant_id, false)
827+
.await?,
828+
)?;
829829
merged_snapshot = object_store_format.snapshot;
830830
}
831831

‎src/storage/object_storage.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,11 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
931931
let min_date = &parsed_dates[0].1;
932932
let max_date = &parsed_dates[parsed_dates.len() - 1].1;
933933

934-
// Extract timestamps for min and max dates
935-
let first_timestamp = self
936-
.extract_timestamp_for_date(stream_name, min_date, true, tenant_id)
937-
.await?;
938-
let latest_timestamp = self
939-
.extract_timestamp_for_date(stream_name, max_date, false, tenant_id)
940-
.await?;
934+
// Extract timestamps for min and max dates concurrently; independent reads, no shared state
935+
let (first_timestamp, latest_timestamp) = tokio::try_join!(
936+
self.extract_timestamp_for_date(stream_name, min_date, true, tenant_id),
937+
self.extract_timestamp_for_date(stream_name, max_date, false, tenant_id)
938+
)?;
941939

942940
let first_event_at = first_timestamp.map(|ts| ts.to_rfc3339());
943941
let latest_event_at = latest_timestamp.map(|ts| ts.to_rfc3339());

0 commit comments

Comments
 (0)