This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[Research] Possible performance improvements in Lens expressions #182151
Labels
research
Team:Visualizations
Visualization editors, elastic-charts and infrastructure
technical debt
Improvement of the software architecture and operational architecture
I will add here some of the findings related to performance bottlenecks I've found in the current Lens/SearchStrategy architecture and possible improvements to these solutions.
Unnecessary multiple requests with the same esagg query
When a search is sent to ES and a response is received, the search service is looking if the request needs a post-flight request.
kibana/src/plugins/data/common/search/search_source/search_source.ts
Lines 539 to 548 in 74fdd1b
If needed, it transforms the response to a
partial
response and update the body with the postflight request.This works correctly if the postflight is actually necessary, but due to the current implementation the postflight request is always "applied" even if not needed, causing a subsequent request to be sent to ES.
This results to an increase of:
Analysis
The current method that checks if a request needs a subsequent post-flight request relies on a loose check from the function
hasPostFlightRequests
. This function checks if the agg propertytype.postFlightRequest
is a function.kibana/src/plugins/data/common/search/search_source/search_source.ts
Lines 474 to 483 in 74fdd1b
This function is there even if is not required. For example in a
terms
aggregation without theother
bucket the function is still there but just return its identitykibana/src/plugins/data/common/search/aggs/buckets/terms.ts
Line 93 in 74fdd1b
All the other cases this is defaulted to an
identity
function, so thehasPostFlightRequests
function will always return true.kibana/src/plugins/data/common/search/aggs/agg_type.ts
Line 311 in 74fdd1b
wait_for_completion_timeout
value is too low and can't process, without delays, a full responseThis parameter, used in async search, describes the timeout before returning asynch search with a partial result..
This parameter is currently set to
200ms
.kibana/src/plugins/data/config.ts
Line 58 in b8d8c73
After this
200ms
interval the polling mechanism kicks in and the results then are just delayed everytime by at least ~300mskibana/src/plugins/data/common/search/poll_search.ts
Lines 20 to 35 in b8d8c73
Probably I don't have enough knowledge in that, but I don't see any major drawback to increase this value to at least 1s as proposed here #157837 (comment) or even more.
The main drawback with that is an open connection between ES and Kibana that last for ~1 second, instead of opening and closing a new one 5 times in the same time interval.
getXDomain
can be speeded upWhen using cartesian charts, we compute the x domain. If that domain is big, the time to compute is pretty relevant. For example for a 50k data point dataset it tooks ~40ms. This can probably reduced by half if we adopt a better strategy on data processing, avoiding multiple array scans to sort, filter, map values and we just loop once with a reduce.
The text was updated successfully, but these errors were encountered: