Skip to content

Feature request: file pread and pwrite #767

@tomjridge

Description

@tomjridge

I have the following scenario:

I have many writes to make to a file. Each write is of a fixed length (eg 4096 bytes). Each write occurs at a different offset in the file. No writes overlap. The data for each write is held in a bigstring buffer. Essentially I have batched updates to different regions in a file.

I would like these writes to happen "in parallel", preferably with only one system call.

Let's focus on the "in parallel" part.

At the moment, for each write, I can lseek to the position and then write the data. But this doesn't parallelize because the lseek of one write will interfere with the lseek of another.

If the file based pread/pwrite were supported (ie the call documented here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html and write.html , with explicit file offset), I could at least issue the writes in parallel, without them interfering with each other.

Ideally it would be possible to submit a single write-family syscall, with a list of buffers, where each buffer also includes the offset in the file at which the buffer should be written. But I don't know if Linux aio, or some other mechanism, can accomplish this. Perhaps the basic mechanisms are supported in libuv or similar?

Anyway, any advice appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions