airborne12 opened a new pull request, #62121:
URL: https://github.com/apache/doris/pull/62121
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
SEARCH() function uses the query_v2 engine, which bypasses
`InvertedIndexReader::query()`. This causes all inverted index profile metrics
to report zero, making it impossible to diagnose SEARCH() performance issues
from query profiles.
Three independent problems were identified and fixed:
**1. Query-level timers not populated (function_search.cpp)**
The MATCH path populates `inverted_index_query_timer`,
`searcher_open_timer`, `searcher_search_timer`, etc. via `SCOPED_RAW_TIMER` in
`inverted_index_reader.cpp`. The SEARCH path bypasses this entirely —
`FieldReaderResolver::resolve()` opens the index and
`evaluate_inverted_index_with_search_param()` executes the query without any
timer instrumentation.
Fix: Add `SCOPED_RAW_TIMER` at corresponding points in `function_search.cpp`:
- `inverted_index_query_timer` around the entire evaluation
- `inverted_index_searcher_open_timer` around searcher cache miss (directory
open)
- `inverted_index_searcher_search_timer` around query build + execution
- `inverted_index_searcher_search_init_timer` around
`build_query_recursive()`
- `inverted_index_searcher_search_exec_timer` around
`collect_multi_segment_doc_set/top_k()`
- `inverted_index_searcher_cache_hit/miss` counters in `resolve()`
**2. FileCache IO not attributed to inverted index
(inverted_index_compound_reader)**
`CSIndexInput` clone constructor did not copy `_io_ctx`, causing cloned
inputs to read without `file_cache_stats` — so
`InvertedIndexBytesScannedFromRemote/Cache` etc. stayed zero. Additionally,
`DorisCompoundReader::openInput()` created new `CSIndexInput` without setting
`_io_ctx`, so query_v2 scorer reads lacked proper IO context.
Fix:
- Copy `_io_ctx` in `CSIndexInput` clone constructor
- Store `_io_ctx` in `DorisCompoundReader` and propagate it to new
`CSIndexInput` in `openInput()`
**3. Profile counters pruned by level (olap_scan_operator.cpp)**
All inverted index counters were registered with default `level=2` via
`ADD_TIMER`/`ADD_COUNTER`. The profile display system prunes level-2 leaf
counters when `profile_level < 2`, making them invisible in query profiles. The
FileCache counters used `ADD_CHILD_TIMER_WITH_LEVEL(..., 1)` and were visible.
Fix: Register inverted index counters with `level=1` via
`ADD_TIMER_WITH_LEVEL`/`ADD_COUNTER_WITH_LEVEL`.
### Release note
None
### Check List (For Author)
- Test
- [x] Manual test (add detailed scripts or steps below)
- Deployed on cloud_sim cluster with S3 storage
- Cold query (file cache cleared): verified
`InvertedIndexBytesScannedFromRemote: 1.15 KB`, `InvertedIndexNumRemoteIOTotal:
1`, `InvertedIndexRemoteIOUseTimer: 46.919ms`
- Warm query (file cache populated): verified
`InvertedIndexBytesScannedFromCache: 1.15 KB`, `InvertedIndexNumLocalIOTotal: 1`
- Query-level timers: verified `InvertedIndexQueryTime: 51.155ms`,
`InvertedIndexSearcherOpenTime: 49.196ms`, `InvertedIndexSearcherSearchTime:
51.60ms`, `InvertedIndexSearcherCacheMiss: 1`
- Behavior changed:
- [x] Yes. Inverted index profile counters now visible at default
profile level and populated for SEARCH() queries.
- Does this need documentation?
- [x] No.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]