morningman opened a new pull request, #61603: URL: https://github.com/apache/doris/pull/61603
## Proposed changes ### What problem does this PR solve? Issue Number: close #xxx Problem Summary: The current `SummaryProfile` implementation in Doris FE has several issues: - **Hard-coded metric keys**: All timing metrics are defined as static final Strings with corresponding timestamp fields, making it difficult to add new metrics. - **Fragile timestamp pairs**: Durations are computed from start/finish timestamp pairs (e.g., `nereidsAnalysisFinishTime - nereidsLockTableFinishTime`), where incorrect ordering of setter calls leads to negative durations. - **Non-composable**: Timing logic is scattered across `NereidsPlanner`, `StmtExecutor`, `ConnectProcessor`, `FileQueryScanNode`, `HMSTransaction`, etc., all directly calling `SummaryProfile` setters. This PR introduces a new **QueryTrace/ProfileSpan** system that replaces the legacy approach: - `ProfileSpan` implements `AutoCloseable` for safe, scoped timing via try-with-resources. - `QueryTrace` provides dynamic metric registration via `startSpan()`, `recordDuration()`, `addCounter()`, and `setText()`. - A ThreadLocal span stack enables automatic parent-child relationship detection. - Metrics are registered on-the-fly, eliminating the need for pre-declared fields. ### Changes **Phase 1 - Core Infrastructure + NereidsPlanner** (`c1121e3`) - New classes: `ProfileSpan`, `QueryTrace` - Enhanced `RuntimeProfile` to support indented `addInfoString` - Migrated all NereidsPlanner timing to ProfileSpan/QueryTrace - Migrated MV rewrite, partition pruning, fold-constant, and TVF init timing **Phase 2 - Data Source + Getter Bridge** (`00939aa`) - Migrated `FileQueryScanNode`, `HiveScanNode`, `HiveTableSink` timing - Added `getTraceDurationMs()` bridge in SummaryProfile getters **Phase 3 - StmtExecutor + HMSTransaction** (`6ea75e4`) - Migrated StmtExecutor outer container timings (plan, parse, schedule, fetch, write) - Migrated ConnectProcessor parse timing - Replaced `Optional<SummaryProfile>` with `Optional<QueryTrace>` in HMSTransaction - Migrated all HMS filesystem/partition timing and counters **Phase 4 - Cleanup** (`bc0af91`, `d92c6ab`) - Removed ~280 lines of dead setter methods and backing fields - Removed dead legacy fallback block in `updateExecutionSummaryProfile()` - Simplified getters to QueryTrace-only (no fallback) - Rewrote `SummaryProfileTest` to use QueryTrace API - Fixed all checkstyle issues (import order, indentation, unused imports) ### Release note None ### Check List (For Author) - Test: Unit Test (SummaryProfileTest rewritten for QueryTrace API) - Behavior changed: No (profile output format is preserved) - Does this need documentation: No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
