-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Prototype/fdb layer replace couch rate #3127
Prototype/fdb layer replace couch rate #3127
Conversation
5c477f3
to
2adc534
Compare
I should mention that my hack to generate the batch_size graphs had a bug where it would double count if a transaction would be retried. That spike to ~8500 just happens to be at the transition in this graph. There's always a conflict towards the start of view indexing due to a conflict on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, this looks really good and is a lot simpler than the previous implementation.
I'm not convinced about having the default implementation of batch_module
in the same file as couch_views_batch
. I initially found it confusing trying to figure out where it starts and where couch_views_batch
is. I would prefer we have a couch_batch
module similar to couch_rate
with the default module and couch_views_batch
.
I agree with Garren. This separation would also hide the |
Just wanted to mention that the scope of |
In regards to
The meck can be used from ExUnit.
|
e04b8ef
to
309d388
Compare
@garrensmith I've split the behavior/implementation between @iilyak For the scope I agree that this is a lot more narrow. I started by trying to figure out the AIMD/congestion algorithms in both couch_rate and couch_replicator but after thinking awhile I realized that having an AIMD based algorithm isn't appropriate for batch sizes since we want to avoid failing batches as much as possible because every failed batch is wasted time when building a view. I did a number of different approaches to try and measure optimal batch sizes and behaviors. An earlier version of this work actually tried to optimize the rate of indexing within the bounds of transaction sizes. That lead to the realization that just maximizing the work done in a single transaction was most beneficial overall for indexing throughput. That's how it ended up being so simple and narrow in the end. For the meck-via-Elixir, that would have worked if this test were running in the same VM but those tests are run separately against an instance of |
We have two kinds of Elixir tests
Unit tests are run on the same VM |
309d388
to
46f355b
Compare
@nickva I've addressed your three main suggestions. For the metrics I don't have a good answer other than maybe expose the timing logs I've currently somewhat hacked in the views branch. Let me know if you think some sort of combined metric there would be useful and I can add that. |
@davisp Looks, let's skip the metrics for now, could be a future enhancement I am getting a consistent timeout in the |
@nickva I sometimes have one but it seems to be only occasionally for the first run after compiling and then doesn't happen again. Let me know if you find anything though. Flaky tests are never good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Nice work!
And good comments from Ilya and Garren about re-structuring it as two modules.
Left a few style and param validation comments, up to you there if you feel they are too nitpicky
46f355b
to
c3511dd
Compare
@nickva I've addressed all of your suggestions. Let me know if you have anything else. @iilyak @garrensmith I'm pretty sure I've addressed all of your concerns, let me know if there's anything left to handle. |
@davisp lgtm +1 to merge, also good job adding extra tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change from me and then it looks good.
c3511dd
to
df3b74a
Compare
rel/overlay/etc/default.ini
Outdated
; batch_initial_size = 100 ; Initial batch size in number of documents | ||
; batch_search_increment = 500 ; Size change when searching for the threshold | ||
; batch_sense_increment = 100 ; Size change increment after hitting a threshold | ||
; batch_max_tx_size = 9000000 ; Maximum transaction size in bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we name it batch_max_tx_size_bytes
to make it clear that units are different compared to batch_initial_size
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. after batch_max_tx_size -> batch_max_tx_size_bytes
rename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
df3b74a
to
77f9c8b
Compare
Updated the max size parameter to include bytes. Will merge when CI comes back green. |
77f9c8b
to
718b7b0
Compare
This implementation was difficult to understand and had behavior that was too difficult to predict. It would break if view behavior changed in significant ways from what was originally expected.
The couch_views_batch module is responsible for sensing the largest batch sizes that can be successfully processed for a given indexer process. It works by initially searching for the maximum number of documents that can be included in a batch. Once this threshold is found it then works by slowly increasing the batch size and decreasing when its found again. This approach works to maximise batch sizes while being reactive to when a larger batch would cross over the FoundationDB transaction limits which causes the entire batch to be aborted and retried which wastes time during view builds.
This test doesn't fail correctly any longer. Rather than attempting to create a new pathological view case I've just moved it to eunit where we can use meck to throw errors directly.
Overview
Replace the couch_rate rate limiting algorithm with couch_views_batch to dynamically optimize the indexer batch size during view updates.
While working on optimizing couch_views I ran into couch_rate behaving oddly. Reading through the implementation it was nearly impossible to predict how changing various parameters would affect the behavior under load. The rate limiting algorithms were also a bit misapplied. We don't really want a rate "limiter" so much as a rate "maximizer".
After failing to comprehend couch_rate and realizing that it was missing some fairly important signals (specifically, the approximate transaction size) I decided to take a whack at simplifying things. The new approach is quite a bit simpler and results in the ability to both successfully index large views (1,000,000 doc ranges were tested) but also has a more predictable and simple behavior.
The graph above is a representative of the behavior. Batch sizes start out small when a view indexer starts. The batch size is quickly ramped up to search for the threshold of a batch size, and then batch sizes are adjusted in much smaller increments to follow the optimal batch size.
Matching the old behavior of couch_rate to attempt to maintain a consistent transaction time limit can be accomplished trivially by adjusting the
couch_views.batch_tx_max_time
parameter.Testing recommendations
make check
Checklist
rel/overlay/etc/default.ini