Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Feature: Allow users to tinker with RocksDB configuration via file; Upgrade RocksDb #1638

Merged
merged 15 commits into from
Nov 6, 2019

Conversation

kwek20
Copy link
Contributor

@kwek20 kwek20 commented Oct 7, 2019

Description

In order to easily change rocksdb settings, you can now configure it directly though a config file.
Current settings but in a config would look like this:

create_if_missing=true
create_missing_column_families=true
max_log_file_size=1048576
max_manifest_file_size=1048576
max_open_files=10000
max_background_compactions=1
allow_concurrent_memtable_write=true
max_subcompactions=[your_number_of_cpus]

A full list of options can be found here, but only those inside the DBOptions section will be used: https://github.com/facebook/rocksdb/blob/master/examples/rocksdb_option_file_example.ini
This file CAN be downloaded and used, or one can copy the OPTIONS-0000XX file inside the mainnetdb folder, and rename it to the specified configuration file name.

Configurable options for enabling this are the following:
DB_CONFIG_FILE / --db-config-file: The location of the RocksDB configuration file. By default set to rocksdb-config.properties, which leads to a properties file in the main IRI directory(so not inside mainnet/db folder)

Fixes #1630
Fixes #1629
Fixes #1624

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How Has This Been Tested?

It loads the config

Checklist:

  • My code follows the style guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@iotaledger iotaledger deleted a comment Oct 7, 2019
@iotaledger iotaledger deleted a comment Oct 7, 2019
@kwek20 kwek20 changed the title Rocksdb config Feature: Rocksdb from a config Oct 30, 2019
@kwek20
Copy link
Contributor Author

kwek20 commented Nov 4, 2019

Splitting up the methods indicated by codacy will in my opinion make it less readable.
Therefor i chose to ignore the suggestion, and this PR is ready for merge!

@kwek20 kwek20 requested review from GalRogozinski and luca-moser and removed request for GalRogozinski November 4, 2019 16:26
Copy link
Contributor

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

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

Nice,
Just questions and nits

@@ -82,6 +83,7 @@ SpentAddressesProvider provideSpentAddressesProvider() {
PersistenceProvider persistenceProvider = new RocksDBPersistenceProvider(
configuration.getSpentAddressesDbPath(),
configuration.getSpentAddressesDbLogPath(),
configuration.getDbConfigFile(),
Copy link
Contributor

Choose a reason for hiding this comment

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

So mainnet-db and spent-addresses-db uses the same name?
IIUC it is just the name but there are still separate locations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea same config. i dont really think there will be added value of splitting the 2 apart, unless we hire a rocksdb expert who can tinker enough to make a difference. But assuming we will work on a new persistence layer anyways, i doubt it will happen soon :)


BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig().setFilter(bloomFilter);
cache = new LRUCache(cacheSize * SizeUnit.KB, 2);
compressedCache = new LRUCache(32 * SizeUnit.KB, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

Those changes resulted in performance benefits? Or was it something you had to do due to RocksDb upgrade

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the update, i did benchmark and unfortunately no notable improvements :(

*
* @param dbPath The location where the database will be stored
* @param logPath The location where the log files will be stored
* @param configFile The location where the RocksDB config is read from
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param configFile The location where the RocksDB config is read from
* @param configPath The location where the RocksDB config is read from

Comment on lines 570 to 578
InputStream stream = new FileInputStream(config);
try {
configProperties.load(stream);
options = DBOptions.getDBOptionsFromProps(configProperties);
} catch (IllegalArgumentException e) {
log.warn("RocksDB configuration file is empty, falling back to default values");
} finally {
stream.close();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I always like to use "try with resources" e.g.
try (InputStream stream = new FileInputStream(config))

Just a bit less verbose. What you did works as well, but I'd rather we use the shorter way throughout the project.

@GalRogozinski
Copy link
Contributor

Codacy is still complaining but this is due to existing code you copy pasted, so it is fine

@GalRogozinski GalRogozinski changed the title Feature: Rocksdb from a config Feature: Allow users to tinker with RocksDB configuration via file; Upgrade RocksDb Nov 6, 2019
@GalRogozinski GalRogozinski merged commit 621d916 into iotaledger:dev Nov 6, 2019
Comment on lines +591 to +597
if (!BaseIotaConfig.Defaults.DB_LOG_PATH.equals(logPath) && logPath != null) {
if (!options.dbLogDir().equals("")) {
log.warn("Defined a db log path in config and commandline; Using the command line setting.");
}

options.setDbLogDir(logPath);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit late, I just noticed this code while merging conflicts...
Why is this here @kwek20 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is here due to the fact we can define the db log on the config file and the logbath on iri.ini/cmdline. In order to warwn the user they defined it twice, we add a log

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants