[scd] Add hash lock option #1520
Conversation
| if err != nil { | ||
| return stacktrace.Propagate(err, "Failed to upsert OperationalIntent in repo") | ||
| } | ||
|
|
There was a problem hiding this comment.
This has been ordered as it has no impact and slightly reduce transaction restarts
There was a problem hiding this comment.
This should be in a dedicated PR, please split it out.
|
I think we should check performance under conditions at least somewhat similar to real operations, which I think means at least multiple nodes, probably multiple instances, and latency between nodes. I first measured v0.22.0 with: With 10 users, I got:
I then measured with this branch:
Just to make sure my retag worked: I see some latency improvement versus v0.22.0 and a tiny throughput improvement, so looks reasonable to me. I will leave final approval to @barroco with his greater practical experience with database operations than me. |
86539e0 to
6a5d9fe
Compare
barroco
left a comment
There was a problem hiding this comment.
Still reviewing the results.
| if err != nil { | ||
| return stacktrace.Propagate(err, "Failed to upsert OperationalIntent in repo") | ||
| } | ||
|
|
There was a problem hiding this comment.
This should be in a dedicated PR, please split it out.
| !!! danger | ||
| All DSS instances in a DSS pool must use the same value for this option. Mixing will result in dramatically lower performance. | ||
|
|
||
| You can use the `/aux/v1/configuration/scd_lock_mode` endpoint to retrive the current values of locks for a specifc DSS instance. |
There was a problem hiding this comment.
| You can use the `/aux/v1/configuration/scd_lock_mode` endpoint to retrive the current values of locks for a specifc DSS instance. | |
| You can use the `/aux/v1/configuration/scd_lock_mode` endpoint to retrieve the current values of locks for a specifc DSS instance. |
| !!! danger | ||
| This option requires migration 3.4.1 for CockroachDB and 1.1.1 for Yugabyte to be effective | ||
|
|
||
| Similar to the previous option, but use lock based on hashed cells (with 65k locks). |
There was a problem hiding this comment.
| Similar to the previous option, but use lock based on hashed cells (with 65k locks). | |
| Similar to the SCD global lock option, but use lock based on hashed cells (with 65k locks). |
| for _, cell := range cells { | ||
| // Fibonacci hash: level-13 cell ids only differ in their high bits, | ||
| // so a plain modulo would map them all to the same stripe. | ||
| k := int64((uint64(cell) * 0x9e3779b97f4a7c15) >> 48 % lockStripes) |
There was a problem hiding this comment.
nit: Move the value into a constant.
|
|
||
| Similar to the previous option, but use lock based on hashed cells (with 65k locks). | ||
|
|
||
| This should be better than global lock, as long as cells used don't colide and limit number of entries in the database. |
There was a problem hiding this comment.
| This should be better than global lock, as long as cells used don't colide and limit number of entries in the database. | |
| This should be better than global lock, as long as cells used don't collide and limit number of entries in the database. |
| zap.Bool("global_lock", false), | ||
| zap.Duration("duration", duration), | ||
| zap.Int("cell_count", len(cells)), | ||
| zap.Int("explicit_subscription_id_count", len(subscriptionIds)), |
There was a problem hiding this comment.
Please, add the number of locks acquired.


This PR follow #1518 as it increase performance of that PR.
Add a new option to lock cells using an hash, as an intermediate between the global lock option and the subscriptions lock.
Using
FlightsInSubstest, with 8 clusters, on a single-local CRDB node we can see an improvement others lock methods.(Don't include option in terraform/helm/tanka yet)