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

Add TimedPut to stress test #12559

Closed
wants to merge 3 commits into from

Conversation

jowlyzhang
Copy link
Contributor

@jowlyzhang jowlyzhang commented Apr 18, 2024

This also updates WriteBatch's protection info to include write time since there are several places in memtable that by default protects the whole value slice.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@jowlyzhang jowlyzhang reopened this Apr 19, 2024
@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

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

Some concerns

@@ -1304,6 +1304,14 @@ class NonBatchedOpsStressTest : public StressTest {
(value_base % FLAGS_use_put_entity_one_in) == 0) {
s = db_->PutEntity(write_opts, cfh, k,
GenerateWideColumns(value_base, v));
} else if (FLAGS_use_timed_put_one_in > 0 &&
(value_base % FLAGS_use_timed_put_one_in) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If use_put_entity_one_in and use_timed_put_one_in have common factors (or are equal) then then the actual frequency of TimedPut is really messed up or zero. A partial fix would add a reasonably large prime constant to value_base before this mod operation.

cache_bench_tool.cc (https://github.com/facebook/rocksdb/blob/main/cache/cache_bench_tool.cc) has an example of efficiently, randomly choosing disjoint actions with chosen frequencies. Search for lookup_insert_threshold. (Modulo operator is slow btw.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great point! I was only thinking that used_timed_put_one_in will be inaccurate if put entity is also enabled, but didn't realize in the case when they have a common factor, the former will be as if it's unset. Thanks for calling that out and the example for how to solve it. Let me add the partial fix of adding a reasonable large prime. And I will convert these one_in type of arguments to be percentage based and use the strategy in cache bench tool for them in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

one_in is the standard for db_stress, so that's fine. I was just pointing to the cache_bench code for an example of randomized behavior with exclusive probabilities.

db_stress_tool/db_stress_common.cc Outdated Show resolved Hide resolved
db/write_batch.cc Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

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

LGTM, potentially a little more simplification

db/write_batch.cc Show resolved Hide resolved
PutFixed64(&encoded_write_time, write_unix_time);
std::array<Slice, 2> value_with_time{{value, encoded_write_time}};
SliceParts packed_value(value_with_time.data(), 2);
PutLengthPrefixedSliceParts(&b->rep_, packed_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I was hoping to get rid of the SliceParts stuff. Here we're fundamentally putting the packed value contiguously in &b->rep_ so it seems like we can use that for protection info rather than doing a bunch of extra copies for SliceParts stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I started with this hoping that it could save copying to a string buffer, but the SliceParts used by the protection info will create such a string buffer anyway, so this is unnecessarily hacky.

PutFixed64(&encoded_write_time, unix_write_time);
std::array<Slice, 2> value_with_time{{val, encoded_write_time}};
SliceParts packed_value(value_with_time.data(), 2);
return UpdateProtInfo(cf, key, packed_value, kTypeValuePreferredSeqno);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here the data comes unpacked, and we have to physically or virtually pack it. SliceParts makes sense here, especially if we end up fixing this TODO: https://github.com/facebook/rocksdb/blob/9.1.fb/util/hash.cc#L91

db_stress_tool/db_stress_gflags.cc Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@jowlyzhang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jowlyzhang merged this pull request in 8b3d9e6.

@jowlyzhang jowlyzhang deleted the stress_timed_put branch April 30, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants