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

Delay the request size calculation until required by the indexing pressure framework #1592

Merged
merged 2 commits into from
Jan 26, 2022

Conversation

getsaurabh02
Copy link
Member

@getsaurabh02 getsaurabh02 commented Nov 19, 2021

Description

Delay the ramBytesUsed computation for Indexing requests on the coordinator until reached a point, where absolutely necessary for IndexingPressure or ShardIndexingPressure.

Issues Resolved

This optimises the additional request size calculation, which otherwise would have been no-op. See (#1560)

The ramBytesUsed computations are done repeatedly at multiple places (replica, primary and coordinator), and are present even in the older version of IndexingPressure. Here in OS1.2 for every request overhead would be the request size computations for the number of documents in the batch. Given that this call has neither showed up in any CPU profiling data and was neither was called out as regression when first added in the indexing path during 7.9 release, this might not be the smoking gun, however this definitely optimises it down further.

…ssure framework. (opensearch-project#1560)

Signed-off-by: Saurabh Singh <sisurab@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success 14cbd72

@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success 14cbd72

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 14cbd72
Log 1148

Reports 1148

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

Love the change! I have a few questions based on the minimal usage of this method. We may consider refactoring to make this a bit more straightforward.

I think we should also take this opportunity to add javadocs for future contributors and debugging.

@@ -25,16 +27,18 @@ public IndexingPressureService(Settings settings, ClusterService clusterService)
shardIndexingPressure = new ShardIndexingPressure(settings, clusterService);
}

public Releasable markCoordinatingOperationStarted(long bytes, boolean forceExecution) {
public Releasable markCoordinatingOperationStarted(BulkRequest bulkRequest, boolean forceExecution) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see this is only used by TransportBulkAction. Is that the only place this is ever intended to be used? Shouldn't we just move this method out of the service if that's the case? If not then lets refactor the method to take the interface?

Suggested change
public Releasable markCoordinatingOperationStarted(BulkRequest bulkRequest, boolean forceExecution) {
public Releasable markCoordinatingOperationStarted(Accountable accountable, boolean forceExecution) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it makes perfect sense to use an Interface instead and keep the contract clean. Refactored to use a Supplier.

return shardIndexingPressure.markCoordinatingOperationStarted(bytes, forceExecution);
} else {
return () -> {};
}
}

public Releasable markCoordinatingOperationStarted(ShardId shardId, long bytes, boolean forceExecution) {
public Releasable markCoordinatingOperationStarted(ShardId shardId, BulkShardRequest bulkShardRequest, boolean forceExecution) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here:

Suggested change
public Releasable markCoordinatingOperationStarted(ShardId shardId, BulkShardRequest bulkShardRequest, boolean forceExecution) {
public Releasable markCoordinatingOperationStarted(ShardId shardId, Accountable accountable, boolean forceExecution) {

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above.

@@ -631,7 +630,7 @@ protected void doRun() {
final boolean isOnlySystem = isOnlySystem(bulkRequest, clusterService.state().metadata().getIndicesLookup(), systemIndices);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we delay this isOnlySystem call as well? Like the ramBytesUsed() it's not needed for anything other than the releasable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping this consistent with the other interface for Node level accounting markCoordinatingOperationStarted(LongSupplier bytes, boolean forceExecution) as it is supplied with a precomputed boolean, being used elsewhere too.

Also given isOnlySystem streams over a precomputed collection (unmodifiable set) of different indices being updated in that bulk request, we don’t expect this number (indices in a single request) to grow too high to be an overhead.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success 365b20af630fb040863ae2e80e6c9f3bd27db723

…es calculation.

Signed-off-by: Saurabh Singh <sisurab@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success 365b20af630fb040863ae2e80e6c9f3bd27db723

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success 0accbbb

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success 0accbbb

@getsaurabh02
Copy link
Member Author

Thank you @nknize for taking the look. I have updated the PR and added some java doc too.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 365b20af630fb040863ae2e80e6c9f3bd27db723
Log 1173

Reports 1173

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 0accbbb
Log 1174

Reports 1174

@nknize
Copy link
Collaborator

nknize commented Jan 14, 2022

stale PR. Reinvoking gradle check

@nknize
Copy link
Collaborator

nknize commented Jan 14, 2022

start gradle check

@nknize nknize mentioned this pull request Jan 14, 2022
37 tasks
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 0accbbb
Log 1924

Reports 1924

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

@nknize you're ok with this?

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

Yes! Sorry, I missed this notification. LGTM!

@nknize nknize merged commit 447b20c into opensearch-project:main Jan 26, 2022
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