Skip to content

Commit cd49ecb

Browse files
authored
feat: add tiered compactor and some metrics test (#461)
* feat: add tiered compactor and some metrics test * chore: fmt * chore: replace rand with fastrand * chore: change visibility * chore: remove redundant parameters * refactor: change major_compaction in TieredCompactor to static method
1 parent 0aed53c commit cd49ecb

File tree

5 files changed

+1687
-12
lines changed

5 files changed

+1687
-12
lines changed

src/compaction/leveled.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,3 +1264,53 @@ pub(crate) mod tests {
12641264
}
12651265
}
12661266
}
1267+
1268+
#[cfg(all(test, feature = "tokio"))]
1269+
pub(crate) mod tests_metric {
1270+
1271+
use fusio::path::Path;
1272+
use tempfile::TempDir;
1273+
1274+
use crate::{
1275+
compaction::{
1276+
leveled::LeveledOptions,
1277+
tests_metric::{read_write_amplification_measurement, throughput},
1278+
},
1279+
inmem::immutable::tests::TestSchema,
1280+
trigger::TriggerType,
1281+
DbOption,
1282+
};
1283+
1284+
#[tokio::test(flavor = "multi_thread")]
1285+
#[ignore]
1286+
async fn read_write_amplification_measurement_leveled() {
1287+
let temp_dir = TempDir::new().unwrap();
1288+
let leveled_options = LeveledOptions {
1289+
major_threshold_with_sst_size: 3,
1290+
level_sst_magnification: 4,
1291+
..Default::default()
1292+
};
1293+
let option = DbOption::new(
1294+
Path::from_filesystem_path(temp_dir.path()).unwrap(),
1295+
&TestSchema,
1296+
)
1297+
.leveled_compaction(leveled_options)
1298+
.max_sst_file_size(1024); // Small file size to force multiple files
1299+
1300+
read_write_amplification_measurement(option).await;
1301+
}
1302+
1303+
#[tokio::test(flavor = "multi_thread")]
1304+
#[ignore]
1305+
async fn throughput_leveled() {
1306+
let temp_dir = TempDir::new().unwrap();
1307+
let mut option = DbOption::new(
1308+
Path::from_filesystem_path(temp_dir.path()).unwrap(),
1309+
&TestSchema,
1310+
)
1311+
.leveled_compaction(LeveledOptions::default());
1312+
option.trigger_type = TriggerType::SizeOfMem(1 * 1024 * 1024);
1313+
1314+
throughput(option).await;
1315+
}
1316+
}

0 commit comments

Comments
 (0)