Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions crates/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ use exn::Result;
use exn::bail;
use foyer::BlockEngineBuilder;
use foyer::DeviceBuilder;
use foyer::FifoConfig;
use foyer::FsDeviceBuilder;
use foyer::HybridCache;
use foyer::HybridCacheBuilder;
use foyer::HybridCachePolicy;
use foyer::IoEngineBuilder;
use foyer::IopsCounter;
use foyer::LfuConfig;
use foyer::PsyncIoEngineBuilder;
use foyer::RecoverMode;
use foyer::RuntimeOptions;
Expand Down Expand Up @@ -69,6 +70,23 @@ impl FoyerEngine {
let mut db = FsDeviceBuilder::new(data_dir).with_capacity(disk_capacity as usize);
if let Some(throttle) = disk_throttle {
db = db.with_throttle(throttle.into());
} else {
const DEFAULT_THROUGHPUT_PER_CORE: usize = 187_500_000; // ~1.5Gbps
const IOPS_PER_CORE: usize = 10_000; // 10k IOPS
let throughput = DEFAULT_THROUGHPUT_PER_CORE * num_cpus().get();
let write_throughput_quota = throughput / 4; // 25% of throughput for writes
let read_throughput_quota = throughput - write_throughput_quota; // Remaining for reads
let iops = IOPS_PER_CORE * num_cpus().get();
let write_iops_quota = iops / 4; // 25% of IOPS for writes
let read_iops_quota = iops - write_iops_quota; // Remaining for reads
let throttle = foyer::Throttle {
write_iops: Some(write_iops_quota.try_into().unwrap()),
read_iops: Some(read_iops_quota.try_into().unwrap()),
write_throughput: Some(write_throughput_quota.try_into().unwrap()),
read_throughput: Some(read_throughput_quota.try_into().unwrap()),
iops_counter: IopsCounter::PerIo,
};
db = db.with_throttle(throttle);
}
let dev = db
.build()
Expand All @@ -90,7 +108,7 @@ impl FoyerEngine {
key_size + value_size
})
.with_shards(parallelism)
.with_eviction_config(FifoConfig::default())
.with_eviction_config(LfuConfig::default())
.storage()
.with_engine_config(
BlockEngineBuilder::new(dev)
Expand Down
Loading