Skip to content
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

Reduce cpu usage by avoiding throwing an exception during query execution #11715

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

vvivekiyer
Copy link
Contributor

@vvivekiyer vvivekiyer commented Sep 29, 2023

In #9092, we added query execution stats to fetch setNumConsumingSegmentsProcessed and setNumConsumingSegmentsMatched

In one of our production clusters, we observed that Operator.getIndexSegment -> UnsupportedOperationException() was consuming > 8% of CPU. Analyzing it, the RCA is as follows:

  • Stats collection calls getIndexSegment() which is not implemented by all operators.
  • The default implementation throws an exception.
  • We simply catch the exception and do nothing
    The process of throwing an exception (needlessly in this case) is expensive CPU-wise because it collects a stack-trace (which is expensive and slow) amongst other things. Some benchmarking here.

Attaching flamegraph that shows CPU usage

image

cc: @dinoocch @siddharthteotia

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

Merging #11715 (2a3bed2) into master (54a1ca0) will decrease coverage by 0.08%.
Report is 11 commits behind head on master.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master   #11715      +/-   ##
============================================
- Coverage     63.05%   62.97%   -0.08%     
+ Complexity     1118     1117       -1     
============================================
  Files          2342     2342              
  Lines        125787   125881      +94     
  Branches      19335    19357      +22     
============================================
- Hits          79314    79273      -41     
- Misses        40813    40948     +135     
  Partials       5660     5660              
Flag Coverage Δ
integration <0.01% <0.00%> (-0.01%) ⬇️
integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration2 0.00% <0.00%> (ø)
java-11 14.42% <0.00%> (-48.59%) ⬇️
java-17 62.95% <100.00%> (+0.04%) ⬆️
java-20 62.95% <100.00%> (+0.03%) ⬆️
temurin 62.97% <100.00%> (-0.08%) ⬇️
unittests 62.96% <100.00%> (-0.08%) ⬇️
unittests1 67.07% <100.00%> (-0.14%) ⬇️
unittests2 14.43% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...in/java/org/apache/pinot/core/common/Operator.java 80.00% <100.00%> (ø)
...ot/core/operator/combine/CombineOperatorUtils.java 100.00% <100.00%> (ø)

... and 67 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@vvivekiyer vvivekiyer marked this pull request as ready for review October 2, 2023 01:13
Co-authored-by: Xiaotian (Jackie) Jiang <17555551+Jackie-Jiang@users.noreply.github.com>
Copy link
Contributor

@jasperjiaguo jasperjiaguo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@siddharthteotia siddharthteotia merged commit 1d0303c into apache:master Oct 3, 2023
19 checks passed
@vvivekiyer vvivekiyer deleted the easy_perf_win_exception branch October 3, 2023 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants