Skip to content

a bug? #71

@rustMyGod

Description

@rustMyGod

hello
I want to test performance on mmap,BIO,AIO,and iouring(by tokio-uring) by write 1KB data to 1G files 1024 times . then i write the code bellow.when program running i find something unexpected.

  1. too many threads created and destroyed,maybe 20+ thousands.(my test server is 8c16g,5.15.10-1.el7.elrepo.x86_64)
  2. some file succeed ,some not,no exception throwed,program is still alive,but no worker threads work now .many file are only 794MB and not growing, the others are 1024MB. bug here?
  3. the writing speed is much more slowly than tranditional io(maybe all AIO model slowly the same).
use std::thread;
use std::time::Duration;
use std::time::Instant;
use std::{path::PathBuf, sync::Arc};
use tokio::sync::mpsc;
use tokio::sync::mpsc::UnboundedSender;
use tokio::sync::Mutex;
use tokio::time::sleep;
use tokio_uring::fs::{File, OpenOptions};
fn main() {
    tokio_uring::start(async {
        let (tx, mut rx) = mpsc::unbounded_channel::<()>();
        let txx = Arc::new(tx);
        let count = Instant::now();
        for i in 0..1024 {
            let t = txx.clone();
            tokio_uring::spawn(create(i, t));
        }

        drop(txx);
        while let Some(_) = rx.recv().await {}
        println!("{:?}", count.elapsed());
    });
}

async fn create(idx: i32, tx: Arc<UnboundedSender<()>>) {
    let path = PathBuf::from(r"/data2/testuring/".to_owned() + idx.to_string().as_str());
    let mut file = OpenOptions::new()
        .read(true)
        .write(true)
        .create(true)
        .open(&path)
        .await
        .unwrap();
    // file.set_len(1024 * 1024 * 1024).await.unwrap();
    println!("create file={} {:?}", idx, thread::current().id());
    let x=b"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
    let y=&x[..];
    let size_1_g = 1024 * 1024 * 1024;
    let mut idx = 0;
    while idx < size_1_g {
        let (_, _) = file.write_at(y, idx).await;
        idx = idx + 1024;
    }
    println!("end file={:?} {:?}", &path, thread::current().id());
    file.close().await.unwrap();
    drop(tx);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions