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

Do not serialize metrics in each Operator #10473

Merged
merged 11 commits into from Apr 1, 2023

Conversation

KKcorps
Copy link
Contributor

@KKcorps KKcorps commented Mar 24, 2023

There's no need to serialize the metrics unless they are sent or received. We can simply use the OperatorStats objects for rest of the operators.

@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2023

Codecov Report

Merging #10473 (68c496b) into master (641ec60) will increase coverage by 0.20%.
The diff coverage is 97.77%.

@@             Coverage Diff              @@
##             master   #10473      +/-   ##
============================================
+ Coverage     69.97%   70.17%   +0.20%     
- Complexity     6118     6254     +136     
============================================
  Files          2092     2112      +20     
  Lines        112712   113050     +338     
  Branches      17143    17007     -136     
============================================
+ Hits          78874    79338     +464     
+ Misses        28260    28167      -93     
+ Partials       5578     5545      -33     
Flag Coverage Δ
integration1 24.31% <0.00%> (-0.22%) ⬇️
integration2 24.08% <0.00%> (-0.22%) ⬇️
unittests1 67.85% <97.77%> (+0.30%) ⬆️
unittests2 13.87% <0.00%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
...uery/runtime/executor/OpChainSchedulerService.java 96.77% <ø> (-0.06%) ⬇️
...ot/query/runtime/operator/utils/OperatorUtils.java 83.05% <ø> (-0.56%) ⬇️
...query/runtime/operator/MailboxReceiveOperator.java 91.81% <75.00%> (-2.63%) ⬇️
...va/org/apache/pinot/query/runtime/QueryRunner.java 80.86% <100.00%> (+0.16%) ⬆️
...e/operator/LeafStageTransferableBlockOperator.java 78.09% <100.00%> (+0.21%) ⬆️
...ot/query/runtime/operator/MailboxSendOperator.java 77.94% <100.00%> (+2.13%) ⬆️
...not/query/runtime/operator/MultiStageOperator.java 78.12% <100.00%> (-1.43%) ⬇️
...g/apache/pinot/query/runtime/operator/OpChain.java 100.00% <100.00%> (ø)
...che/pinot/query/runtime/operator/OpChainStats.java 91.17% <100.00%> (+4.07%) ⬆️
...he/pinot/query/runtime/operator/OperatorStats.java 97.72% <100.00%> (+4.24%) ⬆️
... and 2 more

... and 210 files with indirect coverage changes

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

@KKcorps KKcorps changed the title WIP: Do not serialize metrics Do not serialize metrics Mar 27, 2023
@KKcorps KKcorps requested a review from walterddr March 27, 2023 18:15
@KKcorps KKcorps changed the title Do not serialize metrics Do not serialize metrics in each Operator Mar 28, 2023
@KKcorps
Copy link
Contributor Author

KKcorps commented Mar 28, 2023

@walterddr one query: Are you fine if I simply create OpChainStats inside OpChainExecutionContext and then use it everywhere instead of using .attach function introduced here.

The only downside I see is context should be immutable while stats are mutable.

@KKcorps KKcorps force-pushed the zero_serialisation_query_metrics branch from 1351cd8 to 3f16d70 Compare March 29, 2023 08:07
TransferableBlock eosBlockWithStats = TransferableBlockUtils.getEndOfStreamTransferableBlock(
OperatorUtils.getMetadataFromOperatorStats(_opChainStats.getOperatorStatsMap()));
_exchange.send(eosBlockWithStats);
return eosBlockWithStats;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to return this instead of just transferableBlock? we don't have any further processing of the stats right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that it gets serialized and sent to next OpChain.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • _exchange.send(eosBlockWithStats) sends to the next opChain
  • return eosBlockWithStats is returning to the opChainScheduler.

do we process anything related to stats on opChainScheduler? if not returning the original transferableBlock seems more reasonable

@@ -39,21 +35,18 @@ public abstract class MultiStageOperator implements Operator<TransferableBlock>,

// TODO: Move to OperatorContext class.
protected final OperatorStats _operatorStats;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need this as final reference? can we also put this in OpChainStats and access via OpChainStats?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we still need it as OperatorStats contains stats only for a single operator.

Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, there will be 0 or 1 OperatorStats object corresponding to this operator in the OpChainStats map. if so why do we keep strong reference to both objects in 2 classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. So now I have made the change to use directly via the map in OpChainStats rather than creating and storing a strong reference in the base class.

Comment on lines +219 to +221
if (_opChainStats != null && !block.getResultMetadata().isEmpty()) {
for (Map.Entry<String, OperatorStats> entry : block.getResultMetadata().entrySet()) {
_opChainStats.getOperatorStatsMap().compute(entry.getKey(), (_key, _value) -> entry.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. this is deserializing the metadata from received metadata from the previous stage and putting them into the current ones. if this is true. when there's no trace enabled, skip this step
  2. where is the opChain stats being encoded? or it is also in the map but when trace is enabled there will be more keys in the map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracing thing is being taken care of in the next PR. Need to rebase that PR with the changes in this one.

@KKcorps KKcorps force-pushed the zero_serialisation_query_metrics branch from 8b26fcd to 68a3787 Compare March 30, 2023 09:03
Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

following up my previous comments. also could you fix conflict and CI failures? thank you

TransferableBlock eosBlockWithStats = TransferableBlockUtils.getEndOfStreamTransferableBlock(
OperatorUtils.getMetadataFromOperatorStats(_opChainStats.getOperatorStatsMap()));
_exchange.send(eosBlockWithStats);
return eosBlockWithStats;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • _exchange.send(eosBlockWithStats) sends to the next opChain
  • return eosBlockWithStats is returning to the opChainScheduler.

do we process anything related to stats on opChainScheduler? if not returning the original transferableBlock seems more reasonable

@@ -39,21 +35,18 @@ public abstract class MultiStageOperator implements Operator<TransferableBlock>,

// TODO: Move to OperatorContext class.
protected final OperatorStats _operatorStats;
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, there will be 0 or 1 OperatorStats object corresponding to this operator in the OpChainStats map. if so why do we keep strong reference to both objects in 2 classes?

@KKcorps KKcorps force-pushed the zero_serialisation_query_metrics branch from 1838382 to 919eafe Compare March 31, 2023 08:47
Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

lgtm

@walterddr walterddr mentioned this pull request Apr 1, 2023
6 tasks
@KKcorps KKcorps merged commit 941cbf8 into apache:master Apr 1, 2023
14 checks passed
abhioncbr pushed a commit to abhioncbr/pinot that referenced this pull request Apr 14, 2023
* WIP: Do not serialize metrics

* No need to pass stats between operator. Only collected in the end at the send operator

* Use opchain stats to record operatorStats

* No need to serialie metrics in receive operator

* Remove attachStats method and create stats object inside context itself

* Make stats thread safe

* Add test for opchain stats

* Ensure SendOperator stats are populated before serializing stats

* Fix variable scope

* Use operator stats map directly from opchain stats

* unify return statements outside inner for loop in MailboxSendOperator

---------

Co-authored-by: Kartik Khare <kharekartik@Kartiks-MacBook-Pro.local>
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.

None yet

3 participants