Skip to content

Add profiling support to unified query API#5268

Merged
dai-chen merged 1 commit intoopensearch-project:mainfrom
dai-chen:feature/unified-query-profiling
Mar 27, 2026
Merged

Add profiling support to unified query API#5268
dai-chen merged 1 commit intoopensearch-project:mainfrom
dai-chen:feature/unified-query-profiling

Conversation

@dai-chen
Copy link
Copy Markdown
Collaborator

@dai-chen dai-chen commented Mar 25, 2026

Description

This PR enables profiling capability in the unified query API so external consumers (OpenSearch, Spark, CLI) can collect per-phase timing metrics without depending on the REST-specific QueryContext layer.

Implementation Notes

  • Reuses existing profiling infrastructure: Profiling output follows the same format and semantics as profile=true in the REST API, but hides the internal profiling abstraction behind UnifiedQueryContext.
  • Auto-profiling inside, measure() API outside: Each unified query component auto-profiles its phase and provide measure API for code outside unified query components, e.g., PreparedStatement.executeQuery(), response formatting.

Related Issues

Part of #5248

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dai-chen dai-chen self-assigned this Mar 25, 2026
@dai-chen dai-chen added the enhancement New feature or request label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from c85370d to a4ea219 Compare March 25, 2026 23:05
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from a4ea219 to 6749914 Compare March 25, 2026 23:09
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from 6749914 to 2f645f3 Compare March 25, 2026 23:27
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from 2f645f3 to 4a1cbef Compare March 26, 2026 02:08
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from 4a1cbef to 5d88254 Compare March 26, 2026 15:28
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from 5d88254 to c8f6055 Compare March 26, 2026 16:52
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

Add query profiling infrastructure that measures time spent in each
query phase (analyze, optimize, execute, format). Profiling is opt-in
via UnifiedQueryContext.builder().profiling(true) and uses thread-local
context to avoid passing profiling state through every method.

Key changes:
- QueryProfiling/ProfileContext for thread-local profiling lifecycle
- UnifiedQueryContext.measure() API for timing arbitrary phases
- Auto-profiling in UnifiedQueryPlanner (analyze) and compiler (optimize)
- UnifiedQueryTestBase shared test fixture for unified query tests
- Comprehensive profiling tests with non-flaky >= 0 timing assertions

Signed-off-by: Chen Dai <daichen@amazon.com>
@dai-chen dai-chen force-pushed the feature/unified-query-profiling branch from c8f6055 to 45b666c Compare March 26, 2026 18:12
@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen enabled auto-merge (squash) March 26, 2026 22:30
@dai-chen dai-chen merged commit f0bcbab into opensearch-project:main Mar 27, 2026
44 checks passed
@dai-chen dai-chen deleted the feature/unified-query-profiling branch March 27, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants