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

Commit

Permalink
Set default database file size large enough (#1363)
Browse files Browse the repository at this point in the history
* make default 100mb file size

* update again

* fix type

* little less extreme file sizes
  • Loading branch information
NikVolf authored and gavofyork committed Jun 21, 2016
1 parent 951512f commit c5f6250
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions util/src/kvdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use std::default::Default;
use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBVector, DBIterator,
IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction};

const DB_FILE_SIZE_BASE: u64 = 10 * 1024 * 1024;
const DB_FILE_SIZE_MULTIPLIER: i32 = 5;

/// Write transaction. Batches a sequence of put/delete operations for efficiency.
pub struct DBTransaction {
batch: WriteBatch,
Expand Down Expand Up @@ -64,7 +67,7 @@ impl DatabaseConfig {
DatabaseConfig {
cache_size: Some(cache_size),
prefix_size: None,
max_open_files: 256
max_open_files: -1,
}
}
}
Expand All @@ -74,7 +77,7 @@ impl Default for DatabaseConfig {
DatabaseConfig {
cache_size: None,
prefix_size: None,
max_open_files: 256
max_open_files: -1,
}
}
}
Expand Down Expand Up @@ -110,6 +113,8 @@ impl Database {
opts.create_if_missing(true);
opts.set_use_fsync(false);
opts.set_compaction_style(DBCompactionStyle::DBUniversalCompaction);
opts.set_target_file_size_base(DB_FILE_SIZE_BASE);
opts.set_target_file_size_multiplier(DB_FILE_SIZE_MULTIPLIER);
if let Some(cache_size) = config.cache_size {
// half goes to read cache
opts.set_block_cache_size_mb(cache_size as u64 / 2);
Expand Down

0 comments on commit c5f6250

Please sign in to comment.