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

db bench: usability of the pinning policy parameter #720

Merged

Conversation

udi-speedb
Copy link
Contributor

No description provided.

@udi-speedb udi-speedb linked an issue Oct 16, 2023 that may be closed by this pull request
@udi-speedb udi-speedb force-pushed the 687-db_bench-usability-of-the-pinning-policy-parameter branch from 5470540 to 64dc9ed Compare October 16, 2023 14:28
@udi-speedb udi-speedb force-pushed the 687-db_bench-usability-of-the-pinning-policy-parameter branch from 64dc9ed to 6ceb098 Compare October 17, 2023 11:30
@Guyme Guyme requested review from mrambacher and removed request for Yuval-Ariel October 17, 2023 12:15
@@ -818,7 +819,27 @@ DEFINE_bool(
" Note `cache_index_and_filter_blocks` must be true for this option to have"
" any effect.");

DEFINE_string(pinning_policy, "", "URI for registry TablePinningPolicy");
DEFINE_bool(scoped_pinning_policy, false, "Use Speedb's Scoped Pinning Policy");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please leave this as a string? Boolean parameters make it much harder to do validation and more alternatives.

Copy link
Contributor

Choose a reason for hiding this comment

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

The string could be compared to the kClassName or the like...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole point was to make it easy for users such as @erez-speedb to command db_bench to use scoped pinning policy. A boolean achieves just that. The whole point of this PR is usability and making the lives of the user easy.

And what validations are you referring to in this context?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we add a third pinning policy and the value is a boolean, then you can only set one of the booleans. A string is simpler and more expandable/adaptable. Look at the code for handling different Envs to see an example.

I believe the problem before was the string that was required was too complex. This code simplifies the string (and provides validation) by separating the fields that were in one string into multiple parameters.

And is it really that much harder to say --pinning_policy=scoped than --scoped_pinning_policy?

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 have reverted it to a string but the values are NOT the Class names (which are long and hard to remember. @erez-speedb complained about the length of the command line as it is).
The values (at the moment are: "default" and "scoped")

Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly suggest making the values class names and changing the class name if you do not like it. Using name/nickname of "scoped" seems very reasonable to me. The MergeOperators with names like "MergeSortOperator" and "sortlist" are great examples of names and nicknames that make sense

Comment on lines +9349 to +9352
if (FLAGS_cost_write_buffer_to_cache) {
if (FLAGS_db_write_buffer_size > FLAGS_cache_size) {
ErrorExit("--cache_size must be >= --db_write_buffer_size");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this have to do with the pinning policy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indirectly. These flags are used later in the calculation of the pinnning capacity.

Comment on lines 9673 to +9674
ValidateMetadataCacheOptions();
ValidatePinningRelatedOptions();
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't these two mutually exclusive? The MetadataCacheOptions are not used if PinningRelatedOptions are used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily. When using the default policy ValidateMetadataCacheOptions is applicable. Each one specific flags and their inter-dependencies.
What do you propose instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Are the MetadataCacheOptions validation a problem with db_bench or the code in general?

I guess leave it for now. Not worth the hassle.

//
class ScopedPinningPolicy : public RecordingPinningPolicy {
public:
ScopedPinningPolicy();
ScopedPinningPolicy(const ScopedPinningOptions& options);

static const char* kClassName() { return "speedb_scoped_pinning_policy"; }
static const char* kNickName() { return "speedb.ScopedPinningPolicy"; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine with the name "ScopedPinning" but "Scoped" or "scoped" would be acceptable too. The fact the class is PinningPolicy implies "Pinning"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -890,7 +891,12 @@ DEFINE_string(fs_uri, "",
" with --env_uri."
" Creates a default environment with the specified filesystem.");

DEFINE_string(pinning_policy, "", "URI for registry TablePinningPolicy");
DEFINE_string(pinning_policy,
ROCKSDB_NAMESPACE::DefaultPinningPolicy::kNickName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not leave empty be the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allows the user to clearly see the actual pinning policy used by default.
Please see also my answer to your comment below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Setting this to a legal value rather than empty makes it much harder to tell if it is updated. If it is empty, then the system will use default. If not, it should use the one that is set.

Comment on lines +897 to +899
"The options are: "
"'DefaultPinning': Default RocksDB's pinning polcy. "
"'ScopedPinning': Speedb's Scoped pinning policy.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why explicitly state what the options are? If more were added via a plugin, this would be wrong. It also makes it hard to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obviously, however, the top priority here IMO is to make it easy for the users (and seeing the strings to use does just that). That is a purpose of a help string.
Adding a new policy is a rare event. Such a policy would probably have its own set of configuration flags that should be added anyway to db_bench, so, I believe that the developer adding the policy would update the help string / default if necessary.

@udi-speedb
Copy link
Contributor Author

@mrambacher - I have pushed another commit. Hopefully the last one. Please see if there is anything that you really think is important enough. Otherwise, please approve. Thanks

@Yuval-Ariel
Copy link
Contributor

@udi-speedb note that theres a conflict

@udi-speedb
Copy link
Contributor Author

@udi-speedb note that theres a conflict

Thanks. Resolved

Copy link
Contributor

@mrambacher mrambacher left a comment

Choose a reason for hiding this comment

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

thanks

@@ -890,7 +891,12 @@ DEFINE_string(fs_uri, "",
" with --env_uri."
" Creates a default environment with the specified filesystem.");

DEFINE_string(pinning_policy, "", "URI for registry TablePinningPolicy");
DEFINE_string(pinning_policy,
ROCKSDB_NAMESPACE::DefaultPinningPolicy::kNickName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting this to a legal value rather than empty makes it much harder to tell if it is updated. If it is empty, then the system will use default. If not, it should use the one that is set.

@udi-speedb udi-speedb force-pushed the 687-db_bench-usability-of-the-pinning-policy-parameter branch from 6f5965d to 52156ff Compare October 19, 2023 16:36
@udi-speedb udi-speedb merged commit 8c68304 into main Oct 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

db_bench usability of the pinning policy parameter
3 participants