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

PHOENIX-6052 Include syscat time in mutation time #1546

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

mnpoonia
Copy link
Contributor

No description provided.

@mnpoonia
Copy link
Contributor Author

@virajjasani @tkhurana a draft PR for the fix.

@tkhurana
Copy link
Contributor

@mnpoonia would it make sense to introduce a separate metric to track the syscat time ? By clubbing the two metrics in one we will not know where we are spending time.

@mnpoonia
Copy link
Contributor Author

@tkhurana i think it is upto us. Ultimately we care about how much time one mutation took. Now if we want to divide it in syscat and then htable.batch it is perfectly fine but not sure if we want to introduce a new metric.
As per the discussion in JIRA https://issues.apache.org/jira/browse/PHOENIX-6052 It looked like we are not in favor of new metric so i went ahead with this approach.
@virajjasani and @shahrs87 what do you guys think?

@mnpoonia
Copy link
Contributor Author

mnpoonia commented Jan 2, 2023

@tkhurana do you mind if we include syscat time in the mutation commit time in this jira and create a seperate jira to track syscat time seperately as well.

@virajjasani
Copy link
Contributor

create a seperate jira to track syscat time seperately as well

I think this should be good. Thoughts @gjacoby126 @tkhurana?

@tkhurana
Copy link
Contributor

tkhurana commented Jan 4, 2023

@mnpoonia You have changed the scope of this metric. Let us say you are batching 1000 upserts. Phoenix internally in the sendMutations function groups them into sub batches of by default 100 and then calls htable.batch() on that sub batch. Earlier the metric was capturing the time taken by each individual sub-batch. Now the metric is capturing the time across all sub-batches. I am not sure if this is intended.

@mnpoonia
Copy link
Contributor Author

mnpoonia commented Jan 9, 2023

@tkhurana Thanks for pointing that out. I completely missed that part. Have reverted to old behaviour of mini batch mutation time. Also created a new metric for syscat time. Open for all suggestions to get it to closure.
Will need your and @virajjasani help in getting it to closure. Thanks in advance

Copy link

@gourabtaparia gourabtaparia left a comment

Choose a reason for hiding this comment

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

Few comments. @mnpoonia

@@ -1198,6 +1199,7 @@ private void sendBatch(Map<TableRef, MultiRowMutationState> commitBatch, long[]
Map<TableInfo, List<Mutation>> physicalTableMutationMap = Maps.newLinkedHashMap();

// add tracing for this operation
long startTime = EnvironmentEdgeManager.currentTimeMillis();

Choose a reason for hiding this comment

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

nitpick : the above L 1201 "add tracing" comment was for line L 1203 - maybe we can add your change just above that comment - to make the comment and code nearby as last time.

@@ -208,23 +209,23 @@ private MetricType(String shortName, String description, LogLevel logLevel, PDat
public String description() {
return description;
}

Choose a reason for hiding this comment

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

nitpick : there are various changes fixing the extra spaces not part of the change - should we skip this as part of this change ?

Copy link
Contributor

@virajjasani virajjasani Jan 23, 2023

Choose a reason for hiding this comment

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

Agree, good to keep only addition of MUTATION_SYSCAT_TIME for this file and remove all other formatting changes.

@@ -1214,6 +1216,8 @@ private void sendBatch(Map<TableRef, MultiRowMutationState> commitBatch, long[]
serverTimeStamps == null ?
validateAndGetServerTimestamp(tableRef, multiRowMutationState) :
serverTimeStamps[i++];
long syscatTime = EnvironmentEdgeManager.currentTimeMillis() - startTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mnpoonia This is not the only place where we call validateAndGetServerTimestamp. It is also called from here https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java#L895

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this is being called in a loop so you need to reset the value of startTime for every iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. instead of keeping the time here i pushed it down to the method validateAndGetServerTimestamp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tkhurana Let me know if it looks good now.

}
throw e;
} finally {
long endTime = EnvironmentEdgeManager.currentTimeMillis();
GLOBAL_MUTATION_SYSCAT_TIME.update(endTime - startTime);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good

@mnpoonia
Copy link
Contributor Author

@virajjasani @tkhurana I have addressed most of the review comments. Please have a look now.

@virajjasani
Copy link
Contributor

virajjasani commented Jan 23, 2023

I think we should remove formatting changes from this PR, to have smooth backports (including internal forks)

@@ -208,23 +209,23 @@ private MetricType(String shortName, String description, LogLevel logLevel, PDat
public String description() {
return description;
}

Copy link
Contributor

@virajjasani virajjasani Jan 23, 2023

Choose a reason for hiding this comment

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

Agree, good to keep only addition of MUTATION_SYSCAT_TIME for this file and remove all other formatting changes.

@mnpoonia mnpoonia force-pushed the include_syscat_time branch 3 times, most recently from 8761296 to 80063c4 Compare February 6, 2023 08:08
@mnpoonia
Copy link
Contributor Author

mnpoonia commented Feb 6, 2023

@virajjasani I have removed all the whitespace and indentation changes. Please review now.
@tkhurana FYI

@mnpoonia
Copy link
Contributor Author

mnpoonia commented Feb 6, 2023

PR for 5.1 branch
#1557

@virajjasani virajjasani merged commit 0e1996d into apache:master Feb 6, 2023
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.

4 participants