fixed offset being way off

This commit is contained in:
askiiart 2024-10-25 16:29:05 -05:00
parent 1573de227c
commit 00ea574448
Signed by untrusted user who does not match committer: askiiart
GPG key ID: EA85979611654C30

View file

@ -33,19 +33,21 @@ fn large_random_file_generation(path: String) {
fn _large_random_file_generation_helper(i: &u64, out: Arc<Mutex<Result<File, Error>>>) { fn _large_random_file_generation_helper(i: &u64, out: Arc<Mutex<Result<File, Error>>>) {
let mut rng = XorShiftRng::seed_from_u64(2484345508); let mut rng = XorShiftRng::seed_from_u64(2484345508);
let block_size = 1310720;
// NOTE: update this both here and in `large_random_file_generation()` // NOTE: update this both here and in `large_random_file_generation()`
let num_threads = 12; let num_threads = 12;
let mut data = [0u8; 1310720]; let mut data = [0u8; 1310720];
let block_size = 1310720;
// enter desired size in bytes, must be a multiple of 655360 // enter desired size in bytes, must be a multiple of 655360
// this is not a typo, the extra zero after 65536is for the threads // this is not a typo, the extra zero after 65536is for the threads
// 26843545600 = 25 GiB // 26843545600 = 25 GiB
let blocks_per_thread: u64 = 26843545600 / (block_size * num_threads); let blocks_per_thread: u64 = 26843545600 / (block_size * num_threads);
println!("{}", i);
for u in (i * blocks_per_thread)..((i + 1) * blocks_per_thread) { for u in (i * blocks_per_thread)..((i + 1) * blocks_per_thread) {
rng.fill_bytes(&mut data); rng.fill_bytes(&mut data);
let offset: u64 = (i * blocks_per_thread * 1310720) + (1310720 * u); //let offset: u64 = (i * blocks_per_thread * 1310720) + (1310720 * u);
let offset: u64 = u * block_size;
let mut out = out.lock().unwrap(); let mut out = out.lock().unwrap();
out.as_mut().unwrap().write_all_at(&data, offset); out.as_mut().unwrap().write_all_at(&data, offset);
} }