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

perf: increase sessions in the pool in batches #134

Merged
merged 5 commits into from Apr 8, 2020
Merged

Conversation

olavloite
Copy link
Contributor

@olavloite olavloite commented Mar 28, 2020

When more sessions are requested by the user application than are available in the session pool,
the session pool will now create new sessions in batches instead of in steps of 1. This reduces
the number of RPCs needed to serve a burst of requests. The default step size is 25 sessions.

In a default setup with MinSessions=100, MaxSessions=400, NumChannels=4 a session pool that receives a burst of read or write requests will now have to execute 16 BatchCreateSessions RPCs as opposed to 304 BatchCreateSessions RPCs when using steps of 1.

A benchmark for the session pool has also been added to be able to compare performance and the
number of RPCs needed before and after this change. This benchmark can also be used for future
changes to verify that the change does not deteriorate performance or increase the number of
RPCs needed. The full benchmark results for the session pool with varying values for the step size for BatchCreateSessions are:

Execution time in milliseconds

Benchmark (incStep) Score
SessionPoolBenchmark.burstRead 1 1218.416
SessionPoolBenchmark.burstRead 10 827.376
SessionPoolBenchmark.burstRead 20 843.336
SessionPoolBenchmark.burstRead 25 828.906
SessionPoolBenchmark.burstRead 30 1359.492
SessionPoolBenchmark.burstRead 40 1021.871
SessionPoolBenchmark.burstRead 50 1089.514
SessionPoolBenchmark.burstRead 100 901.084
SessionPoolBenchmark.burstReadAndWrite 1 2490.588
SessionPoolBenchmark.burstReadAndWrite 10 2590.583
SessionPoolBenchmark.burstReadAndWrite 20 2476.811
SessionPoolBenchmark.burstReadAndWrite 25 2438.735
SessionPoolBenchmark.burstReadAndWrite 30 2416.405
SessionPoolBenchmark.burstReadAndWrite 40 2570.678
SessionPoolBenchmark.burstReadAndWrite 50 2539.745
SessionPoolBenchmark.burstReadAndWrite 100 2452.292
SessionPoolBenchmark.burstWrite 1 4713.28
SessionPoolBenchmark.burstWrite 10 4840.903
SessionPoolBenchmark.burstWrite 20 4779.517
SessionPoolBenchmark.burstWrite 25 4776.143
SessionPoolBenchmark.burstWrite 30 4707.731
SessionPoolBenchmark.burstWrite 40 4750.286
SessionPoolBenchmark.burstWrite 50 4830.955
SessionPoolBenchmark.burstWrite 100 4843.729
SessionPoolBenchmark.steadyIncrease 1 8003.601
SessionPoolBenchmark.steadyIncrease 10 819.771
SessionPoolBenchmark.steadyIncrease 20 447.573
SessionPoolBenchmark.steadyIncrease 25 425.566
SessionPoolBenchmark.steadyIncrease 30 384.675
SessionPoolBenchmark.steadyIncrease 40 324.946
SessionPoolBenchmark.steadyIncrease 50 279.195
SessionPoolBenchmark.steadyIncrease 100 205.646

Number of BatchCreateSessions RPCs needed

Benchmark (incStep) Score
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 1 304
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 10 34
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 20 19
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 25 16
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 30 14
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 40 12
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 50 10
SessionPoolBenchmark.burstRead:numBatchCreateSessionsRpcs 100 7
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 1 304
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 10 34
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 20 19
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 25 16
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 30 14
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 40 12
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 50 10
SessionPoolBenchmark.burstReadAndWrite:numBatchCreateSessionsRpcs 100 7
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 1 304
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 10 34
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 20 19
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 25 16
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 30 14
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 40 12
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 50 10
SessionPoolBenchmark.burstWrite:numBatchCreateSessionsRpcs 100 7
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 1 304
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 10 34
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 20 19
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 25 16
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 30 14
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 40 12
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 50 10
SessionPoolBenchmark.steadyIncrease:numBatchCreateSessionsRpcs 100 7

@googlebot googlebot added the cla: yes label Mar 28, 2020
@olavloite olavloite added api: spanner kokoro:force-run labels Mar 30, 2020
@olavloite olavloite requested review from skuruppu and hengfengli Mar 30, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run label Mar 30, 2020
Copy link
Contributor

@hengfengli hengfengli left a comment

LGTM. Thanks for doing the benchmark.

olavloite added 5 commits Apr 4, 2020
When more sessions are requested by the user application than are available in the session pool,
the session pool will now create new sessions in batches instead of in steps of 1. This reduces
the number of RPCs needed to serve a burst of requests.

A benchmark for the session pool has also been added to be able to compare performance and the
number of RPCs needed before and after this change. This benchmark can also be used for future
changes to verify that the change does not deteriorate performance or increase the number of
RPCs needed.
@olavloite olavloite force-pushed the batch-increase-sessions branch from edfa509 to e3ac294 Compare Apr 4, 2020
@skuruppu skuruppu merged commit 9e5a1cd into master Apr 8, 2020
12 of 13 checks passed
gcf-merge-on-green bot pushed a commit that referenced this issue Apr 22, 2020
🤖 I have created a release \*beep\* \*boop\* 
---
## [1.53.0](https://www.github.com/googleapis/java-spanner/compare/v1.52.0...v1.53.0) (2020-04-22)


### Features

* optimize maintainer to let sessions be GC'ed instead of deleted ([#135](https://www.github.com/googleapis/java-spanner/issues/135)) ([d65747c](https://www.github.com/googleapis/java-spanner/commit/d65747cbc704508f6f1bcef6eea53aa411d42ee2))


### Bug Fixes

* assign unique id's per test case ([#129](https://www.github.com/googleapis/java-spanner/issues/129)) ([a553b6d](https://www.github.com/googleapis/java-spanner/commit/a553b6d48c4f5ee2d0583e5b825d73a85f06216e))
* check for not null input for Id classes ([#159](https://www.github.com/googleapis/java-spanner/issues/159)) ([ecf5826](https://www.github.com/googleapis/java-spanner/commit/ecf582670818f32e85f534ec400d0b8d31cf9ca6)), closes [#145](https://www.github.com/googleapis/java-spanner/issues/145)
* clean up test instance if creation failed ([#162](https://www.github.com/googleapis/java-spanner/issues/162)) ([ff571e1](https://www.github.com/googleapis/java-spanner/commit/ff571e16a45fbce692d9bb172749ff15fafe7a9c))
* fix flaky test and remove warnings ([#153](https://www.github.com/googleapis/java-spanner/issues/153)) ([d534e35](https://www.github.com/googleapis/java-spanner/commit/d534e350346b0c9ab8057ede36bc3aac473c0b06)), closes [#146](https://www.github.com/googleapis/java-spanner/issues/146)
* increase test timeout and remove warnings ([#160](https://www.github.com/googleapis/java-spanner/issues/160)) ([63a6bd8](https://www.github.com/googleapis/java-spanner/commit/63a6bd8be08a56d002f58bc2cdb2856ad0dc5fa3)), closes [#158](https://www.github.com/googleapis/java-spanner/issues/158)
* retry non-idempotent long-running RPCs ([#141](https://www.github.com/googleapis/java-spanner/issues/141)) ([4669c02](https://www.github.com/googleapis/java-spanner/commit/4669c02a24e0f7b1d53c9edf5ab7b146b4116960))
* retry restore if blocked by pending restore ([#119](https://www.github.com/googleapis/java-spanner/issues/119)) ([220653d](https://www.github.com/googleapis/java-spanner/commit/220653d8e25c518d0df447bf777a7fcbf04a01ca)), closes [#118](https://www.github.com/googleapis/java-spanner/issues/118)
* StatementParser did not accept multiple query hints ([#170](https://www.github.com/googleapis/java-spanner/issues/170)) ([ef41a6e](https://www.github.com/googleapis/java-spanner/commit/ef41a6e503f218c00c16914aa9c1433d9b26db13)), closes [#163](https://www.github.com/googleapis/java-spanner/issues/163)
* wait for initialization to finish before test ([#161](https://www.github.com/googleapis/java-spanner/issues/161)) ([fe434ff](https://www.github.com/googleapis/java-spanner/commit/fe434ff7068b4b618e70379c224e1c5ab88f6ba1)), closes [#146](https://www.github.com/googleapis/java-spanner/issues/146)


### Performance Improvements

* increase sessions in the pool in batches ([#134](https://www.github.com/googleapis/java-spanner/issues/134)) ([9e5a1cd](https://www.github.com/googleapis/java-spanner/commit/9e5a1cdaacf71147b67681861f063c3276705f44))
* prepare sessions with r/w tx in-process ([#152](https://www.github.com/googleapis/java-spanner/issues/152)) ([2db27ce](https://www.github.com/googleapis/java-spanner/commit/2db27ce048efafaa3c28b097de33518747011465)), closes [#151](https://www.github.com/googleapis/java-spanner/issues/151)


### Dependencies

* update core dependencies ([#109](https://www.github.com/googleapis/java-spanner/issues/109)) ([5753f1f](https://www.github.com/googleapis/java-spanner/commit/5753f1f4fed83df87262404f7a7ba7eedcd366cb))
* update core dependencies ([#132](https://www.github.com/googleapis/java-spanner/issues/132)) ([77c1558](https://www.github.com/googleapis/java-spanner/commit/77c1558652ee00e529674ac3a2dcf3210ef049fa))
* update dependency com.google.api:api-common to v1.9.0 ([#127](https://www.github.com/googleapis/java-spanner/issues/127)) ([b2c744f](https://www.github.com/googleapis/java-spanner/commit/b2c744f01a4d5a8981df5ff900f3536c83265a61))
* update dependency com.google.guava:guava-bom to v29 ([#147](https://www.github.com/googleapis/java-spanner/issues/147)) ([3fe3ae0](https://www.github.com/googleapis/java-spanner/commit/3fe3ae02376af552564c93c766f562d6454b7ac1))
* update dependency io.grpc:grpc-bom to v1.29.0 ([#164](https://www.github.com/googleapis/java-spanner/issues/164)) ([2d2ce5c](https://www.github.com/googleapis/java-spanner/commit/2d2ce5ce4dc8f410ec671e542e144d47f39ab40b))
* update dependency org.threeten:threetenbp to v1.4.3 ([#120](https://www.github.com/googleapis/java-spanner/issues/120)) ([49d1abc](https://www.github.com/googleapis/java-spanner/commit/49d1abcb6c9c48762dcf0fe1466ab107bf67146b))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants