Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

BREAKING: bundling: optimize partion key#241

Merged
garrettjonesgoogle merged 7 commits intogoogleapis:masterfrom
pongad:partition-key
Mar 31, 2017
Merged

BREAKING: bundling: optimize partion key#241
garrettjonesgoogle merged 7 commits intogoogleapis:masterfrom
pongad:partition-key

Conversation

@pongad
Copy link
Copy Markdown
Contributor

@pongad pongad commented Mar 17, 2017

Partition key is used in bundling methods to determine
whether two method calls can be merged into one RPC request.
Previously this key is a string.
This is inefficient, as a new string needs to be created
every time a bundling method is called.

This commit replaces the string with the PartitionKey type.
Since protobuf objects have value-equality,
PartitionKey instances simply compare equal if their
constituents are equal and in the same order.

In a simple load-test, this decreases the time required to
write 100,000 log messages to Stackdriver from
9.6s to 5.4s and reduces CPU consumption from 136% to 117%.

I have not compared this with Pubsub's implementation,
so it is possible that we might need to change bundling
at a more fundamental level.
Posting this PR for early feedback and to safeguard against
my machine dying.

Partition key is used in bundling methods to determine
whether two method calls can be merged into one RPC request.
Previously this key is a string.
This is inefficient, as a new string needs to be created
every time a bundling method is called.

This commit replaces the string with the PartitionKey type.
Since protobuf objects have value-equality,
PartitionKey instances simply compare equal if their
constituents are equal and in the same order.

In a simple load-test, this decreases the time required to
write 100,000 log messages to Stackdriver from
9.6s to 5.4s and reduces CPU consumption from 136% to 117%.

I have not compared this with Pubsub's implementation,
so it is possible that we might need to change bundling
at a more fundamental level.
Posting this PR for early feedback and to safeguard against
my machine dying.
@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 17, 2017

Codecov Report

Merging #241 into master will decrease coverage by 0.01%.
The diff coverage is 73.91%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #241      +/-   ##
============================================
- Coverage     70.89%   70.87%   -0.02%     
- Complexity      541      547       +6     
============================================
  Files            78       79       +1     
  Lines          2680     2699      +19     
  Branches        268      273       +5     
============================================
+ Hits           1900     1913      +13     
- Misses          676      679       +3     
- Partials        104      107       +3
Impacted Files Coverage Δ Complexity Δ
...in/java/com/google/api/gax/grpc/BatchExecutor.java 100% <100%> (ø) 4 <3> (ø) ⬇️
...java/com/google/api/gax/grpc/BatchingCallable.java 88.88% <100%> (ø) 3 <0> (ø) ⬇️
...n/java/com/google/api/gax/grpc/BatcherFactory.java 79.66% <100%> (ø) 10 <1> (ø) ⬇️
...java/com/google/api/gax/batching/PartitionKey.java 68.42% <68.42%> (ø) 6 <6> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db35024...caac478. Read the comment docs.

@michaelbausor
Copy link
Copy Markdown
Contributor

This looks good to me. Very interesting that we get such a large performance increase just from the partition key!

...and to safeguard against my machine dying.

😰

@garrettjonesgoogle
Copy link
Copy Markdown
Contributor

LGTM also, after toolkit is updated and client code is regenerated.

@pongad pongad changed the title WIP: bundling: optimize partion key bundling: optimize partion key Mar 21, 2017
pongad added 2 commits March 30, 2017 15:56
This change is still a breaking change,
but it is just compatible enough that GAPIC-generated clients
will compile and work properly.

Toolkit will be updated to take advantage of the new PartitionKey
endpoint.
Once all clients are migrated, we can get rid of the old String endpoint.
* Returns the value of the partition key for the given request.
*/
String getBatchPartitionKey(RequestT request);
protected String getBatchPartitionKey(RequestT request) {

This comment was marked as spam.

@pongad pongad changed the title bundling: optimize partion key BREAKING: bundling: optimize partion key Mar 31, 2017
@pongad
Copy link
Copy Markdown
Contributor Author

pongad commented Mar 31, 2017

As discussed, we'll keep this a breaking change and "atomically" update toolkit and clients

@garrettjonesgoogle
Copy link
Copy Markdown
Contributor

LGTM

@garrettjonesgoogle garrettjonesgoogle merged commit 18e87d7 into googleapis:master Mar 31, 2017
@pongad pongad deleted the partition-key branch April 3, 2017 05:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants