Skip to content

Conversation

@dnhatn
Copy link
Member

@dnhatn dnhatn commented May 22, 2025

When reading dimension fields in the TS command, we can skip reading values while the tsid remains unchanged to improve performance. I benchmarked this change with the following query:

POST /_query
{
    "query": "TS metrics-hostmetricsreceiver.otel-default | WHERE @timestamp >= \"2025-05-08T18:00:08.001Z\" | STATS cpu = avg(rate(`metrics.process.cpu.time`)) BY host.name, BUCKET(@timestamp, 5 minute)"
}

The total query time was reduced from 51ms to 39ms, with processing time in the time-series source operator reduced from 26ms to 17ms.

@dnhatn dnhatn force-pushed the read-dimensions branch from 0f1330d to 41b08c9 Compare May 22, 2025 05:04
@dnhatn dnhatn added >non-issue :StorageEngine/TSDB You know, for Metrics labels May 22, 2025
@dnhatn dnhatn requested review from kkrik-es and martijnvg May 22, 2025 05:26
@dnhatn dnhatn mentioned this pull request May 22, 2025
28 tasks
@dnhatn dnhatn marked this pull request as ready for review May 22, 2025 05:27
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice optimization!


void readValues(int segment, int docID) throws IOException {
segments[segment].read(docID, builders);
void readValues(int segment, int docID, boolean nonDimensionFieldsOnly) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: consider adding a comment here to highlight the optimizatino, i.e. dimensions need to be fetched only once per tsid, as opposed to metrics.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added in e8d2a87

@dnhatn
Copy link
Member Author

dnhatn commented May 22, 2025

Thanks friends!

@dnhatn dnhatn merged commit 3af0568 into elastic:main May 22, 2025
18 checks passed
@dnhatn dnhatn deleted the read-dimensions branch May 22, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants