I’ve seen a few issues related to this, and it seems like this is just “we haven’t gotten to it yet” rather than something fundamental, but I wanted to make sure.

Is there some complexity delaying the implementation of these APIs? Is there a recommended alternative other than “roll your own” or “use Swift NIO”?

One difficulty with AsyncBytes specifically is that the current implementation is poorly suited to server-side use cases. It's very much aimed at the "small device, regular files, low parallelism, low installed memory, priority donation is very important" iOS use profile.

A good way to fix this would be to reimplement it on top of io_uring on Linux (I did carefully leave room in the implementation to swap out the "back end"), but that's a somewhat nontrivial project.

1 Like

You should be able to use the NIOFileSystem module to iterate over the data in files. This package supports both Linux and Darwin. Under the hood it uses a separate thread pool and standard sys calls for writing/reading data. It is capable of achieving really high performance and fast throughput.

@David_Smith already mentioned that this isn't ideal for Darwin platforms since it breaks priority propagation and escalation. One idea that we had that might solve this to adopt task executors and task executor preference.

2 Likes