Skip to content

[#253] (Draft) feat(RocksDBKvBackend): make rocksdb.Options, WriteOptions, ReadOptions configurable#2607

Closed
unknowntpo wants to merge 13 commits intoapache:mainfrom
unknowntpo:feat-rocksdb-options
Closed

[#253] (Draft) feat(RocksDBKvBackend): make rocksdb.Options, WriteOptions, ReadOptions configurable#2607
unknowntpo wants to merge 13 commits intoapache:mainfrom
unknowntpo:feat-rocksdb-options

Conversation

@unknowntpo
Copy link
Contributor

@unknowntpo unknowntpo commented Mar 20, 2024

What changes were proposed in this pull request?

This PR makes rocksdb.Options, WriteOptions, ReadOptions configurable

Why are the changes needed?

see #253 for more information.

Does this PR introduce any user-facing change?

(Please list the user-facing changes introduced by your change, including

User can set Options, WriteOptions, ReadOptions in the gravatino configuration file.

e.g.

gravitino.entity.store.kv.rocksdb.options.<param> = value
gravitino.entity.store.kv.rocksdb.WriteOptions.<param> = value
gravitino.entity.store.kv.rocksdb.ReadOptions.<param> = value

How was this patch tested?

Test methods in RocksDBOptions class with mocks.

References:

@unknowntpo
Copy link
Contributor Author

@yuqi1129 This is the draft PR for making rocksdb.Options configurable by user.
If this PR looks okay, I'll keep adding support for WriteOptions and ReadOptions.

private void initializeOptionSetters() {
// Each option name maps to a lambda that applies the setting to the appropriate
// option object
optionSetters.put("gravitino.entity.store.kv.rocksdb.options.maxBackgroundJobs",
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you can shorten it to options.maxBackgroundJobs or maxBackgroundJobs.

if (configMap.containsKey(optionKey)) {
this.optionSetters.get(optionKey).accept(this, configMap.get(optionKey));
} else {
this.optionSetters.get(optionKey).accept(this, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to set null value. Please remove this line directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll fix it.

* Apply user-defined options to option if this options is configurable.
* TODO: List all configurable options.
*/
public void setOptions(Config config) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you distinguish between a write option and a read option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, this method is responsible for applying config to rocksdb.Options, rocksdb.WriteOptions, rocksdb.ReadOptions.

So I the the method name could be changed to applyUserConfig ?

And if we need to add more options to rocksdb.Options, rocksdb.WriteOptions, rocksdb.ReadOptions.
just add more entries in initializeOptionSetters.

e.g.

optionSetters.put("gravitino.entity.store.kv.rocksdb.options.maxBackgroundJobs",
                (holder, value) -> {
                    holder.options.setMaxBackgroundJobs(Integer.parseInt(value));
                });
optionSetters.put("gravitino.entity.store.kv.rocksdb.writeOptions.noSlowDown",
        (holder, value) -> {
            holder.writeOptions.setNoSlowDown(Boolean.parseBoolean(value));
        });                
optionSetters.put("gravitino.entity.store.kv.rocksdb.readOptions.autoPrefixMode",
        (holder, value) -> {
            holder.readOptions.setAutoPrefixMode(Boolean.parseBoolean(value));
        });    

@unknowntpo unknowntpo marked this pull request as draft March 25, 2024 08:35
@unknowntpo unknowntpo force-pushed the feat-rocksdb-options branch from ab2c3fd to 4a0e733 Compare March 26, 2024 13:24
@unknowntpo unknowntpo marked this pull request as ready for review March 26, 2024 13:25
@unknowntpo unknowntpo force-pushed the feat-rocksdb-options branch from 1385549 to e34a194 Compare March 26, 2024 13:38
@unknowntpo unknowntpo force-pushed the feat-rocksdb-options branch 2 times, most recently from e827ead to 79e6c52 Compare March 28, 2024 06:09
@unknowntpo unknowntpo force-pushed the feat-rocksdb-options branch from 79e6c52 to aae8ce0 Compare March 28, 2024 06:16
@unknowntpo
Copy link
Contributor Author

@yuqi1129 I've added all configs from Options, WriteOptions, ReadOptions, please take a look and we can discuss which one should be dropped.

@yuqi1129
Copy link
Contributor

@yuqi1129 I've added all configs from Options, WriteOptions, ReadOptions, please take a look and we can discuss which one should be dropped.

Okay, I will review it soon, thanks

@unknowntpo
Copy link
Contributor Author

@yuqi1129 I've added all configs from Options, WriteOptions, ReadOptions, please take a look and we can discuss which one should be dropped.

Okay, I will review it soon, thanks

@yuqi1129 Is there any update ?

@jerryshao jerryshao closed this Mar 20, 2026
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.

3 participants