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

feat: Add BulkWriter buffer limit #1606

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tom-andersen
Copy link
Contributor

No description provided.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: firestore Issues related to the googleapis/java-firestore API. labels Mar 12, 2024
@tom-andersen tom-andersen changed the title Add BulkWriter buffer limit feat: Add BulkWriter buffer limit Mar 12, 2024
Copy link

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Mar 12, 2024
@tom-andersen tom-andersen added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 12, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 12, 2024
@tom-andersen tom-andersen marked this pull request as ready for review March 12, 2024 20:21
@tom-andersen tom-andersen requested review from a team as code owners March 12, 2024 20:21
@@ -167,24 +168,22 @@ enum OperationType {
private final RateLimiter rateLimiter;

/**
* The number of pending operations enqueued on this BulkWriter instance. An operation is
* The number of in-flight operations enqueued on this BulkWriter instance. An operation is
* considered pending if BulkWriter has sent it via RPC and is awaiting the result.
Copy link
Contributor

Choose a reason for hiding this comment

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

considered pending if BulkWriter should this be changed to "in-flight" as well?

@Nullable
public abstract Integer getMaxPendingOps();

abstract int getMaxInFlightOps();
Copy link
Contributor

@milaGGL milaGGL Mar 13, 2024

Choose a reason for hiding this comment

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

needs a comment here.
BTW, maybe expalin the relationship between pendingOps and InFlightOps

*/
private static final int DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT = 500;
static final int DEFAULT_MAXIMUM_IN_FLIGHT_OPERATIONS = 500;
Copy link
Contributor

Choose a reason for hiding this comment

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

why define it here, while it is only used in the "BulkWriterOptions" file

if (pendingOpsCount < maxPendingOpCount) {
pendingOpsCount++;
// Schedule the operation if the BulkWriter has fewer than the maximum number of allowed
// pending operations, or add the operation to the buffer.
Copy link
Contributor

Choose a reason for hiding this comment

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

"allowed in-flight operations"

// operation now. This overcomes the small chance that an in-flight operation completes
// before another operation has been added to buffer.
if (incrementInFlightCountIfLessThanMax()) {
if (!processNextBufferedOperation()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

looks strange to do the same condition check twice to see if any operation has been completed during the last condition check.

Copy link
Contributor

@milaGGL milaGGL left a comment

Choose a reason for hiding this comment

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

All looks good. Would love to see this change has resolved the 1 million docs OOM issue as a manual testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/java-firestore API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants