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

[JSON-API] surrogate template id cache #10806

Merged
merged 5 commits into from
Sep 10, 2021
Merged

[JSON-API] surrogate template id cache #10806

merged 5 commits into from
Sep 10, 2021

Conversation

akshayshirahatti-da
Copy link
Contributor

@akshayshirahatti-da akshayshirahatti-da commented Sep 7, 2021

Initial changes to add a surrogate_template_id cache to reduce db queries (#10266)

CHANGELOG_BEGIN
CHANGELOG_END

Preliminary results for this

  • With Gatling multi-user performance tests for oracle with a single template but about 10k queries across 100 parallel users, we see some improvement in throughput and latency in the higher percentiles.
No Surrogate template id cache (baseline)
================================================================================
---- SyncFetchByQuery ----------------------------------------------------------
> Number of requests                                 10000 (OK=10000  KO=-     )
> Min. response time                                    23 (OK=23     KO=-     )
> Max. response time                                   701 (OK=701    KO=-     )
> Mean response time                                   125 (OK=125    KO=-     )
> Std. deviation                                        41 (OK=41     KO=-     )
> response time 90th percentile                        125 (OK=125    KO=-     )
> response time 95th percentile                        148 (OK=148    KO=-     )
> response time 99th percentile                        188 (OK=188    KO=-     )
> response time 99.9th percentile                      221 (OK=221    KO=-     )
> Mean requests/second                               78.74 (OK=78.74  KO=-     )
---- Response time distribution ------------------------------------------------
> t < 800 ms                                         10000 (100%)
> 800 ms < t < 1200 ms                                   0 (  -%)
> t > 1200 ms                                            0 (  -%)
> failed                                                 0 (  -%)
================================================================================



With Surrogate template id cache (regression)
================================================================================
---- SyncFetchByQuery ----------------------------------------------------------
> Number of requests                                 10000 (OK=10000  KO=-     )
> Min. response time                                    21 (OK=21     KO=-     )
> Max. response time                                   633 (OK=633    KO=-     )
> Mean response time                                   106 (OK=106    KO=-     )
> Std. deviation                                        34 (OK=34     KO=-     )
> response time 90th percentile                        106 (OK=106    KO=-     )
> response time 95th percentile                        125 (OK=125    KO=-     )
> response time 99th percentile                        156 (OK=156    KO=-     )
> response time 99.9th percentile                      186 (OK=186    KO=-     )
> Mean requests/second                              93.458 (OK=93.458 KO=-     )
---- Response time distribution ------------------------------------------------
> t < 800 ms                                         10000 (100%)
> 800 ms < t < 1200 ms                                   0 (  -%)
> t > 1200 ms                                            0 (  -%)
> failed                                                 0 (  -%)
================================================================================
  • with JMH QueryBenchmark (i.e ContractDaoBenchmarks) we didn't see any significant difference, even with increased templates.
==> /var/tmp/withCacheBench.log (baseline) <==
Result "com.daml.http.dbbackend.QueryBenchmark.run":
  5.514 ±(99.9%) 0.494 ops/s [Average]
  (min, avg, max) = (4.900, 5.514, 5.859), stdev = 0.327
  CI (99.9%): [5.020, 6.008] (assumes normal distribution)


# Run complete. Total time: 00:03:32

Benchmark           (batchSize)  (extraParties)  (extraTemplates)   Mode  Cnt  Score   Error  Units
QueryBenchmark.run         1000               1                 1  thrpt   10  7.350 ± 0.804  ops/s
QueryBenchmark.run         1000               1                10  thrpt   10  6.478 ± 0.377  ops/s
QueryBenchmark.run         1000               1                20  thrpt   10  5.514 ± 0.494  ops/s

==> /var/tmp/noCacheBench.log (regression)<==
Result "com.daml.http.dbbackend.QueryBenchmark.run":
  5.580 ±(99.9%) 0.296 ops/s [Average]
  (min, avg, max) = (5.217, 5.580, 5.811), stdev = 0.196
  CI (99.9%): [5.284, 5.876] (assumes normal distribution)


# Run complete. Total time: 00:03:28

Benchmark           (batchSize)  (extraParties)  (extraTemplates)   Mode  Cnt  Score   Error  Units
QueryBenchmark.run         1000               1                 1  thrpt   10  7.539 ± 0.326  ops/s
QueryBenchmark.run         1000               1                10  thrpt   10  6.480 ± 0.201  ops/s
QueryBenchmark.run         1000               1                20  thrpt   10  5.580 ± 0.296  ops/s

I haven't looked at the QueryBenchmarks in detail and the reason for the insignificant difference but from the multi-user performance tests there seems to be some benefits seen with the cache (also this benefit seems logical)

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@akshayshirahatti-da akshayshirahatti-da marked this pull request as ready for review September 8, 2021 14:53
@akshayshirahatti-da akshayshirahatti-da force-pushed the surrogate_tpid_cache branch 3 times, most recently from 4b9825e to 2384a5b Compare September 9, 2021 15:50
Copy link
Contributor

@stefanobaghino-da stefanobaghino-da left a comment

Choose a reason for hiding this comment

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

LGTM, just one nitpick. Great work, thanks!

@akshayshirahatti-da akshayshirahatti-da linked an issue Sep 10, 2021 that may be closed by this pull request
@mergify mergify bot merged commit d809fd9 into main Sep 10, 2021
@mergify mergify bot deleted the surrogate_tpid_cache branch September 10, 2021 10:48
azure-pipelines bot pushed a commit that referenced this pull request Sep 15, 2021
This PR has been created by a script, which is not very smart
and does not have all the context. Please do double-check that
the version prefix is correct before merging.

@cocreature is in charge of this release.

Commit log:
```
38227a8 [Ledger API error codes] ErrorCode enrichments [DPP-591] (#10874)
e7c443a enable json index for all fields that are queried with JSON_EXISTS (#10658)
6c1c02a document complete authorized auth0 setup (#10881)
e4230dc Do not drop generated `submissionId`s in `GrpcCommandService` [KVL-1104] (#10882)
b4750a4 trigger reach auth on internal network (#10844)
7908083 add Auth0 support to create-daml-app (#10673)
b86490c Add @adriaanm-da to the release rotation (#10872)
9e918c3 Update trigger-service docs to use --dar option in the corresponding example (#10877)
49a9556 [docs] Fix minor typo in doc of exerciseByKey in TS. (#10863)
f7c07ea interfaces: scala protobuf encoder (#10878)
be4e064 Ledger API Test Tool: support `--additional` tests [KVL-1100] (#10829)
97e14de [Ledger API error codes] ErrorCode interfaces and generator [DPP-591] (#10836)
6dcdaa4 [DPP-589] Add CLI flag to select minimum enabled TLS version (#10854)
1fc58d9 Navigator customviews highlight and choices button, apply custom theme on the login screen (#10859)
6faddc9 Update Daml Documentation to reflect command deduplication related changes [KVL-1094] (#10852)
7c29eee Cleanup normalize from svalue (#10873)
053f22a Convert SValue to Value, and normalize, in a single code pass. (#10828)
37a1cb2 compatibility-tests - Exclude CommandDeduplicationIT from running for existing 1.17 snapshots (#10866)
dfae9f6 Command deduplication - better support for different deduplication modes in conformance tests [KVL-1099] (#10864)
6f151e2 save kibana exports (#10861)
99f0362 [JSON-API] drop package token doc changes (#10865)
b50bb8e Populate `definite_answer` in `ApiException` [KVL-1004] (#10832)
a471225 LF: Add missing collision check for type synonyms (#10841)
1e1c452 LF: drop ad-hoc FrontStack builders (#10839)
8f5b4fa interfaces: protobuf encoder haskell side (#10850)
63f6678 ParticipantPruningIT divulgence test fixes to avoid flakiness on canton (#10860)
8a9d19a Command deduplication - KV conformance test for usage of max deduplication duration [KVL-1098] (#10846)
24fff88 LF: Simplify TransactionBuilder (#10753)
9a4c9df Implement LF desugaring of interface definitions (#10834)
2aaf601 interfaces: protobuf decoder haskell side (#10849)
6dc769b interfaces: lf typechecker implementation (#10843)
d9178d2 Clarify version usage in test tool exclusion docs (#10858)
c113954 Clarify docs for test tool exclusions (#10855)
8c9edd8 es cluster tweaks (#10853)
842c5b1 Drop early access notice from profiler docs (#10856)
7c47aca Improvements to wording in ledger-api protobuf docs (#10851)
cff0358 ledger-api: Remove unimplemented fields [KVL-1094] (#10822)
dcec6ea kvutils: Populate `definite_answer` in rejections [KVL-1004] (#10801)
1c4f173 Command deduplication - kvutils - Always use max deduplication duration as deduplication period [KVL-1098] (#10824)
567fe43 tweak trigger-service docs (#10845)
fb5ab5d setvar doesn't like new lines in assignment, refactor (#10842)
7225c04 [docs] Replace AdoptOpenJDK suggestion by Adoptium (#10837)
6a9c8a6 release 1.17.0-snapshot.20210910.7786.0.976ca400 (#10838)
6ed2124 LF: clean up useless version tests. (#10833)
85f6f36 Modify the name of the secrets-url CLI flag to tls-secrets-url [DPP-604] (#10840)
d809fd9 [JSON-API] surrogate template id cache (#10806)
```
Changelog:
```
- The Trigger Service can now accept separate `--auth-internal` and
  `--auth-external` CLI arguments, where `--auth-internal` is the
  address used by the Trigger Service to reach the Auth Middleware
  directly, and `--auth-external` is the address the Trigger Service uses
  in generated URLs sent back to the client. The `--auth` option remains
  and keeps working as before, setting both internal and external
  addresses to the same given value.
- The `create-daml-app` template now includes support for a third
  authentication scheme (in addition to the existing "dev mode" and Daml
  Hub support): Auth0.
Sandbox: Add CLI flag to select minimum enabled TLS version for ledger API server.
- [Navigator] The currently selected custom view is now highlighted on the sidebar

kvutils - committer side deduplication always uses max_deduplication_duration + min_skew as a deduplication period for all the requests.
Modify the name of the secrets-url CLI flag to tls-secrets-url.
```

CHANGELOG_BEGIN
CHANGELOG_END
akrmn added a commit that referenced this pull request Sep 15, 2021
Manual release process. @akrmn is in charge of this release.

Commit log:
```
b5648c0 Make `CommandTracker` distinguish submissions of the same command using `submissionId` [KVL-1104] (#10868)
b4328b3 ledger-api-test-tool - Add conformance test for parallel command deduplication using CommandSubmissionService [KVL-1099] (#10869)
0c32e3b Fix Parallel Indexer initialization issue [DPP-542] (#10889)
b3e4975 Chore slow migration error removal (#10886)
e4cce53 Create a new grpc exception for each duplicate result [KVL-1099] (#10887)
a939594 Sandbox on H2 - performance improvements for the append-only schema [DPP-600] (#10888)
9a1a101 Increase timeout for heavy tests in ParticipantPruningIT (#10894)
9093c6c Improve wording for the active contracts service description (#10880)
c12f546 Document #10780 (#10781)
5814f6a update NOTICES file (#10893)
38227a8 [Ledger API error codes] ErrorCode enrichments [DPP-591] (#10874)
e7c443a enable json index for all fields that are queried with JSON_EXISTS (#10658)
6c1c02a document complete authorized auth0 setup (#10881)
e4230dc Do not drop generated `submissionId`s in `GrpcCommandService` [KVL-1104] (#10882)
b4750a4 trigger reach auth on internal network (#10844)
7908083 add Auth0 support to create-daml-app (#10673)
b86490c Add @adriaanm-da to the release rotation (#10872)
9e918c3 Update trigger-service docs to use --dar option in the corresponding example (#10877)
49a9556 [docs] Fix minor typo in doc of exerciseByKey in TS. (#10863)
f7c07ea interfaces: scala protobuf encoder (#10878)
be4e064 Ledger API Test Tool: support `--additional` tests [KVL-1100] (#10829)
97e14de [Ledger API error codes] ErrorCode interfaces and generator [DPP-591] (#10836)
6dcdaa4 [DPP-589] Add CLI flag to select minimum enabled TLS version (#10854)
1fc58d9 Navigator customviews highlight and choices button, apply custom theme on the login screen (#10859)
6faddc9 Update Daml Documentation to reflect command deduplication related changes [KVL-1094] (#10852)
7c29eee Cleanup normalize from svalue (#10873)
053f22a Convert SValue to Value, and normalize, in a single code pass. (#10828)
37a1cb2 compatibility-tests - Exclude CommandDeduplicationIT from running for existing 1.17 snapshots (#10866)
dfae9f6 Command deduplication - better support for different deduplication modes in conformance tests [KVL-1099] (#10864)
6f151e2 save kibana exports (#10861)
99f0362 [JSON-API] drop package token doc changes (#10865)
b50bb8e Populate `definite_answer` in `ApiException` [KVL-1004] (#10832)
a471225 LF: Add missing collision check for type synonyms (#10841)
1e1c452 LF: drop ad-hoc FrontStack builders (#10839)
8f5b4fa interfaces: protobuf encoder haskell side (#10850)
63f6678 ParticipantPruningIT divulgence test fixes to avoid flakiness on canton (#10860)
8a9d19a Command deduplication - KV conformance test for usage of max deduplication duration [KVL-1098] (#10846)
24fff88 LF: Simplify TransactionBuilder (#10753)
9a4c9df Implement LF desugaring of interface definitions (#10834)
2aaf601 interfaces: protobuf decoder haskell side (#10849)
6dc769b interfaces: lf typechecker implementation (#10843)
d9178d2 Clarify version usage in test tool exclusion docs (#10858)
c113954 Clarify docs for test tool exclusions (#10855)
8c9edd8 es cluster tweaks (#10853)
842c5b1 Drop early access notice from profiler docs (#10856)
7c47aca Improvements to wording in ledger-api protobuf docs (#10851)
cff0358 ledger-api: Remove unimplemented fields [KVL-1094] (#10822)
dcec6ea kvutils: Populate `definite_answer` in rejections [KVL-1004] (#10801)
1c4f173 Command deduplication - kvutils - Always use max deduplication duration as deduplication period [KVL-1098] (#10824)
567fe43 tweak trigger-service docs (#10845)
fb5ab5d setvar doesn't like new lines in assignment, refactor (#10842)
7225c04 [docs] Replace AdoptOpenJDK suggestion by Adoptium (#10837)
6a9c8a6 release 1.17.0-snapshot.20210910.7786.0.976ca400 (#10838)
6ed2124 LF: clean up useless version tests. (#10833)
85f6f36 Modify the name of the secrets-url CLI flag to tls-secrets-url [DPP-604] (#10840)
d809fd9 [JSON-API] surrogate template id cache (#10806)
```
Changelog:
```

- [Sandbox] - Added a CLI parameter for configuring the number of connections in the database connection pool used for serving ledger API requests
[Docs] Improved description of the purpose and usage of the active contracts service
[Docs/JSON API] documented 256B limitation of Oracle query store
- The Trigger Service can now accept separate `--auth-internal` and
  `--auth-external` CLI arguments, where `--auth-internal` is the
  address used by the Trigger Service to reach the Auth Middleware
  directly, and `--auth-external` is the address the Trigger Service uses
  in generated URLs sent back to the client. The `--auth` option remains
  and keeps working as before, setting both internal and external
  addresses to the same given value.
- The `create-daml-app` template now includes support for a third
  authentication scheme (in addition to the existing "dev mode" and Daml
  Hub support): Auth0.
Sandbox: Add CLI flag to select minimum enabled TLS version for ledger API server.
- [Navigator] The currently selected custom view is now highlighted on the sidebar

kvutils - committer side deduplication always uses max_deduplication_duration + min_skew as a deduplication period for all the requests.
Modify the name of the secrets-url CLI flag to tls-secrets-url.
```

changelog_begin
changelog_end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/json-api HTTP JSON API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore surrogate template id cache in JSON API
3 participants