@@ -20,12 +20,13 @@ use exn::Result;
2020use exn:: bail;
2121use foyer:: BlockEngineBuilder ;
2222use foyer:: DeviceBuilder ;
23- use foyer:: FifoConfig ;
2423use foyer:: FsDeviceBuilder ;
2524use foyer:: HybridCache ;
2625use foyer:: HybridCacheBuilder ;
2726use foyer:: HybridCachePolicy ;
2827use foyer:: IoEngineBuilder ;
28+ use foyer:: IopsCounter ;
29+ use foyer:: LfuConfig ;
2930use foyer:: PsyncIoEngineBuilder ;
3031use foyer:: RecoverMode ;
3132use foyer:: RuntimeOptions ;
@@ -69,6 +70,23 @@ impl FoyerEngine {
6970 let mut db = FsDeviceBuilder :: new ( data_dir) . with_capacity ( disk_capacity as usize ) ;
7071 if let Some ( throttle) = disk_throttle {
7172 db = db. with_throttle ( throttle. into ( ) ) ;
73+ } else {
74+ const DEFAULT_THROUGHPUT_PER_CORE : usize = 187_500_000 ; // ~1.5Gbps
75+ const IOPS_PER_CORE : usize = 10_000 ; // 10k IOPS
76+ let throughput = DEFAULT_THROUGHPUT_PER_CORE * num_cpus ( ) . get ( ) ;
77+ let write_throughput_quota = throughput / 4 ; // 25% of throughput for writes
78+ let read_throughput_quota = throughput - write_throughput_quota; // Remaining for reads
79+ let iops = IOPS_PER_CORE * num_cpus ( ) . get ( ) ;
80+ let write_iops_quota = iops / 4 ; // 25% of IOPS for writes
81+ let read_iops_quota = iops - write_iops_quota; // Remaining for reads
82+ let throttle = foyer:: Throttle {
83+ write_iops : Some ( write_iops_quota. try_into ( ) . unwrap ( ) ) ,
84+ read_iops : Some ( read_iops_quota. try_into ( ) . unwrap ( ) ) ,
85+ write_throughput : Some ( write_throughput_quota. try_into ( ) . unwrap ( ) ) ,
86+ read_throughput : Some ( read_throughput_quota. try_into ( ) . unwrap ( ) ) ,
87+ iops_counter : IopsCounter :: PerIo ,
88+ } ;
89+ db = db. with_throttle ( throttle) ;
7290 }
7391 let dev = db
7492 . build ( )
@@ -90,7 +108,7 @@ impl FoyerEngine {
90108 key_size + value_size
91109 } )
92110 . with_shards ( parallelism)
93- . with_eviction_config ( FifoConfig :: default ( ) )
111+ . with_eviction_config ( LfuConfig :: default ( ) )
94112 . storage ( )
95113 . with_engine_config (
96114 BlockEngineBuilder :: new ( dev)
0 commit comments