-
Couldn't load subscription status.
- Fork 2.3k
Add Fetch Phase to Search Profile #18664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jainankitk
merged 97 commits into
opensearch-project:main
from
andrevandeven:time-fetch
Jul 31, 2025
+2,345
−36
Merged
Changes from all commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
2302f3c
added timing for entire fetch phase
2466119
added more granular fetch profiling
629ba22
added tests
e3f8f44
ran spotless
andrevandeven fc67e31
retrigger jenkins
andrevandeven d854fa5
commented out failing test to see code coverage
andrevandeven 25ea542
Increased profiling granularity. Each sub-phase now is represented as…
andrevandeven 9478b19
updated FetchProfilerTests to work with last commit
andrevandeven 49d7660
commented out failing test to get code coverage and ran spotless
andrevandeven e42df7e
Empty commit
andrevandeven 2156572
Empty commit
andrevandeven f60647a
Added a version check when reading and writing the fetch profiling re…
andrevandeven 34a5b27
retrigger jenkins
andrevandeven f6cb54f
Empty commit
andrevandeven 5113343
Empty commit
andrevandeven 0991d8d
empty commit
andrevandeven 93242c7
empty commit
andrevandeven 9a6a87c
Empty commit
andrevandeven c0f277d
Empty commit
andrevandeven 8fd6751
retrigger jenkins
andrevandeven 740a4ff
Empty commit
andrevandeven 3b6f960
Empty commit
andrevandeven 9e63acc
empty commit
andrevandeven afff5bf
empty commit
andrevandeven 698c12a
empty commit
andrevandeven e1ec883
retrigger jenkins
andrevandeven 4571fe8
Empty commit
andrevandeven 57ded3f
Empty commit
andrevandeven 72bc0b9
retrigger jenkins
andrevandeven 7d87b31
Empty commit
andrevandeven 00fd28e
Empty commit
andrevandeven 99c3040
empty commit
andrevandeven 6eef959
empty commit
andrevandeven 0615d0e
Empty commit
andrevandeven d61b9c1
Empty commit
andrevandeven b582789
retrigger jenkins
andrevandeven 2f81f5a
Empty commit
andrevandeven ae528f6
Empty commit
andrevandeven f789240
empty commit
andrevandeven 1961b54
empty commit
andrevandeven 8bfdf7b
empty commit
andrevandeven c42f3ed
empty commit
andrevandeven 6dd0fe5
empty commit
andrevandeven f32fe26
empty commit
andrevandeven 164bbb7
removed fetch from CSSDuelIT to prevent flaky test
andrevandeven 6c25f91
empty commit
andrevandeven 0afe3cb
empty commit
andrevandeven befa53e
fixed compilation errors after rebase
andrevandeven a01cab8
ran spotless
andrevandeven c3b71dd
defensive null check for when final JSON response doesn't have fetch …
andrevandeven 8e6bb26
ran spottless
andrevandeven a9ce395
empty commit
andrevandeven e42fdc6
add missing javadocs
andrevandeven 5ed4087
empty commit
andrevandeven b27ddbc
fixed version control to 3.2.0
andrevandeven 417cd46
added tests to cover root level profiling, cancellation during fetch,…
andrevandeven d492ad3
spotless
andrevandeven 338ca96
fixed using getBytes without character encoding
andrevandeven 55c7a28
fixed backwards compatibility problem in ProfileShardResult API and u…
andrevandeven 0a42da2
Merge branch 'main' into time-fetch
andrevandeven 3f9448c
created helper to profile and wrapped timed operations in helper
andrevandeven 4673438
spotless
andrevandeven a88b413
Resolve merge conflicts with upstream/main
andrevandeven 1af6f89
fetch profile ignores InnerHits and ScriptFieldsPhase when not includ…
andrevandeven 851f150
added some YML rest tests
andrevandeven e09df95
fixed issue where innerhitsphase was leading to deeply nested profile
andrevandeven 5477420
fixed some matched phase rest test and moved script fields rest test …
andrevandeven 71134e4
added profiling for fetch phase called by top hits aggregation
andrevandeven 655d97c
fetch phase rest tests now skip if version is before 3.2.0, as fetch …
andrevandeven 5c9e0e3
fixed missing version skip in fetch phase profiling with aggregations…
andrevandeven 83c8164
spotless
andrevandeven 4169a95
added unit tests for profiling subphases
andrevandeven 232f66a
added fetch profiling integration tests and added inner hits profile …
andrevandeven 00068e2
empty commit
andrevandeven e817d81
empty commit
andrevandeven 3af4f72
added support for deeper profiling of inner hits phase
andrevandeven ead3b94
removed unecessary try fetch logic
andrevandeven f66c37c
Remove accidentally committed RunnerSettings block
andrevandeven 3836d9f
expanded unit test to cover changes in inner hits phase profiling
andrevandeven 8d86f6c
spotless
andrevandeven a7a7c42
empty commit
andrevandeven 898b1d4
removed unecessary timings
andrevandeven 2eeb0be
consolidated rest tests to 3 cases
andrevandeven bb912e8
fixed FetchProfilerTests after removing Build Search Hits timing
andrevandeven 43157de
refactored fetch profiler to be more intuitive, removed nesting of in…
andrevandeven 96b3a54
added missing license header
andrevandeven 26dc3c4
fixed missing not null check in fetchPhase.execute()
andrevandeven a274bea
empty commit
andrevandeven 25f9d99
empty commit
andrevandeven 6671402
changed FlatFetchProfileTree to take in parent node rather than using…
andrevandeven bdc5fc9
spotless
andrevandeven d03e2e7
fixed script fields test yml test after change in timing type name fo…
andrevandeven 418e7f8
fixed issue where profile node time wasn't inclusive of child timings
andrevandeven da82a68
removed profiling of inner hits fetch and aggregation fetch
andrevandeven 6683ccc
removed profiling of inner hits subphase
andrevandeven cf75be8
empty commit
andrevandeven f6d05d4
throw error if no parent specified for start subphase
andrevandeven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...less/src/yamlRestTest/resources/rest-api-spec/test/painless/130_script_fields_profile.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| setup: | ||
| - do: | ||
| indices.create: | ||
| index: test_fetch_profile | ||
| body: | ||
| settings: | ||
| number_of_replicas: 0 | ||
| number_of_shards: 1 | ||
| mappings: | ||
| properties: | ||
| text_field: | ||
| type: text | ||
| fields: | ||
| keyword: | ||
| type: keyword | ||
| numeric_field: | ||
| type: integer | ||
| date_field: | ||
| type: date | ||
| object_field: | ||
| type: nested | ||
| properties: | ||
| nested_field: | ||
| type: keyword | ||
| stored_field: | ||
| type: keyword | ||
| store: true | ||
|
|
||
| - do: | ||
| bulk: | ||
| refresh: true | ||
| index: test_fetch_profile | ||
| body: | | ||
| { "index": {} } | ||
| { "text_field": "Hello world", "numeric_field": 42, "date_field": "2023-01-01", "object_field": { "nested_field": "nested value" }, "stored_field": "stored value" } | ||
| { "index": {} } | ||
| { "text_field": "Another document", "numeric_field": 100, "date_field": "2023-02-01", "object_field": { "nested_field": "another nested" }, "stored_field": "another stored" } | ||
| { "index": {} } | ||
| { "text_field": "Third document with more text", "numeric_field": 200, "date_field": "2023-03-01", "object_field": { "nested_field": "third nested" }, "stored_field": "third stored" } | ||
|
|
||
|
|
||
| --- | ||
| "Script fields phase profiling": | ||
| - skip: | ||
| features: "contains" | ||
|
|
||
| - do: | ||
| search: | ||
| index: test_fetch_profile | ||
| body: | ||
| profile: true | ||
| query: | ||
| match_all: {} | ||
| script_fields: | ||
| my_field: | ||
| script: | ||
| lang: painless | ||
| source: "doc['numeric_field'].value * 2" | ||
|
|
||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "ScriptFieldsPhase" | ||
| description: "ScriptFieldsPhase" | ||
| - length: { profile.shards.0.fetch.0.children: 1 } | ||
|
|
||
| - is_true: profile.shards.0.fetch.0.children.0.breakdown.process | ||
| - match: { profile.shards.0.fetch.0.children.0.breakdown.process_count: 3 } | ||
| - is_true: profile.shards.0.fetch.0.children.0.breakdown.set_next_reader | ||
| - match: { profile.shards.0.fetch.0.children.0.breakdown.set_next_reader_count: 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 193 additions & 0 deletions
193
rest-api-spec/src/main/resources/rest-api-spec/test/search.profile/10_fetch_phase.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| # Setup remains the same | ||
| setup: | ||
| - do: | ||
| indices.create: | ||
| index: test_fetch_profile | ||
| body: | ||
| settings: | ||
| number_of_replicas: 0 | ||
| number_of_shards: 1 | ||
| mappings: | ||
| properties: | ||
| text_field: | ||
| type: text | ||
| fields: | ||
| keyword: | ||
| type: keyword | ||
| numeric_field: | ||
| type: integer | ||
| date_field: | ||
| type: date | ||
| object_field: | ||
| type: nested | ||
| properties: | ||
| nested_field: | ||
| type: keyword | ||
| stored_field: | ||
| type: keyword | ||
| store: true | ||
|
|
||
| - do: | ||
| bulk: | ||
| refresh: true | ||
| index: test_fetch_profile | ||
| body: | | ||
| { "index": {} } | ||
| { "text_field": "Hello world", "numeric_field": 42, "date_field": "2023-01-01", "object_field": { "nested_field": "nested value" }, "stored_field": "stored value" } | ||
| { "index": {} } | ||
| { "text_field": "Another document", "numeric_field": 100, "date_field": "2023-02-01", "object_field": { "nested_field": "another nested" }, "stored_field": "another stored" } | ||
| { "index": {} } | ||
| { "text_field": "Third document with more text", "numeric_field": 200, "date_field": "2023-03-01", "object_field": { "nested_field": "third nested" }, "stored_field": "third stored" } | ||
|
|
||
| --- | ||
| "Combined fetch sub-phases profiling": | ||
| - skip: | ||
| version: " - 3.1.99" | ||
| reason: "Fetch phase profiling was introduced in 3.2.0" | ||
| features: "contains" | ||
|
|
||
| - do: | ||
| search: | ||
| index: test_fetch_profile | ||
| body: | ||
| profile: true | ||
| explain: true | ||
| version: true | ||
| seq_no_primary_term: true | ||
| track_scores: true | ||
| sort: | ||
| - numeric_field: { order: asc } | ||
| query: | ||
| bool: | ||
| must: | ||
| - match_all: {} | ||
| should: | ||
| - nested: | ||
| path: "object_field" | ||
| query: | ||
| wildcard: | ||
| "object_field.nested_field": "nested*" | ||
| inner_hits: {} | ||
| - match: | ||
| text_field: | ||
| query: "document" | ||
| _name: "my_query" | ||
| docvalue_fields: | ||
| - "numeric_field" | ||
| fields: | ||
| - "stored_field" | ||
| highlight: | ||
| fields: | ||
| "object_field.nested_field": {} | ||
|
|
||
| # 1. Verify basic fetch profile structure | ||
| - is_true: profile.shards.0.fetch.0 | ||
| - match: { profile.shards.0.fetch.0.type: "fetch" } | ||
| - match: { profile.shards.0.fetch.0.description: "fetch" } | ||
| - is_true: profile.shards.0.fetch.0.time_in_nanos | ||
|
|
||
| # 2. Verify detailed breakdown of the main fetch operation | ||
| - is_true: profile.shards.0.fetch.0.breakdown | ||
| - is_true: profile.shards.0.fetch.0.breakdown.load_stored_fields | ||
| - match: { profile.shards.0.fetch.0.breakdown.load_stored_fields_count: 3 } | ||
| - is_true: profile.shards.0.fetch.0.breakdown.load_source | ||
| - match: { profile.shards.0.fetch.0.breakdown.load_source_count: 3 } | ||
| - is_true: profile.shards.0.fetch.0.breakdown.get_next_reader | ||
| - match: { profile.shards.0.fetch.0.breakdown.get_next_reader_count: 1} | ||
| - is_true: profile.shards.0.fetch.0.breakdown.build_sub_phase_processors | ||
| - match: { profile.shards.0.fetch.0.breakdown.build_sub_phase_processors_count: 1} | ||
| - is_true: profile.shards.0.fetch.0.breakdown.create_stored_fields_visitor | ||
| - match: { profile.shards.0.fetch.0.breakdown.create_stored_fields_visitor_count: 1} | ||
|
|
||
| # 3. Verify all expected fetch sub-phases are present as children | ||
| - length: { profile.shards.0.fetch.0.children: 9 } | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "FetchSourcePhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "ExplainPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "FetchDocValuesPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "FetchFieldsPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "FetchVersionPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "SeqNoPrimaryTermPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "MatchedQueriesPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "HighlightPhase" | ||
| - contains: | ||
| profile.shards.0.fetch.0.children: | ||
| type: "FetchScorePhase" | ||
|
|
||
| --- | ||
| "No source or empty fetch profiling": | ||
| - skip: | ||
| version: " - 3.1.99" | ||
| reason: "Fetch phase profiling was introduced in 3.2.0" | ||
|
|
||
| # Case 1: Test with _source: false, which removes FetchSourcePhase | ||
| - do: | ||
| search: | ||
| index: test_fetch_profile | ||
| body: | ||
| profile: true | ||
| query: | ||
| match_all: {} | ||
| _source: false | ||
| docvalue_fields: | ||
| - "numeric_field" | ||
|
|
||
| - is_true: profile.shards.0.fetch.0 | ||
| - length: { profile.shards.0.fetch.0.children: 1 } | ||
| - match: { profile.shards.0.fetch.0.children.0.type: "FetchDocValuesPhase" } | ||
| - match: { profile.shards.0.fetch.0.children.0.breakdown.process_count: 3 } | ||
|
|
||
| # Case 2: Test with size: 0, which results in an empty fetch profile | ||
| - do: | ||
| search: | ||
| index: test_fetch_profile | ||
| body: | ||
| profile: true | ||
| size: 0 | ||
| aggs: | ||
| group_by_nested: | ||
| terms: | ||
| field: "object_field.nested_field" | ||
|
|
||
| - match: { profile.shards.0.fetch: [ ] } | ||
|
|
||
| --- | ||
| "Top-hits aggregation profiling": | ||
| - skip: | ||
| version: " - 3.1.99" | ||
| reason: "Fetch phase profiling was introduced in 3.2.0" | ||
|
|
||
| - do: | ||
| search: | ||
| index: test_fetch_profile | ||
| body: | ||
| profile: true | ||
| query: | ||
| match: | ||
| text_field: "document" | ||
| aggs: | ||
| top_hits_agg: | ||
| top_hits: | ||
| size: 1 | ||
|
|
||
| # Verify that the profile contains a single fetch operation for the query | ||
| - length: { profile.shards.0.fetch: 1 } | ||
| - match: { profile.shards.0.fetch.0.type: "fetch" } | ||
| - match: { profile.shards.0.fetch.0.description: "fetch" } | ||
| - length: { profile.shards.0.fetch.0.children: 1 } | ||
| - match: { profile.shards.0.fetch.0.children.0.type: "FetchSourcePhase" } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.