#tokio #disk #pool #sendfile

tk-sendfile

A high-performance file serving library. Serves files in special IO threads. In this version it uses normal file reading, but we will optimize using sendfile on supported systems as quick as tokio allows us to do that.

6 releases (3 breaking)

Uses old Rust 2015

0.4.0 Mar 30, 2017
0.3.2 Mar 14, 2017
0.3.1 Feb 13, 2017
0.3.0 Oct 20, 2016
0.1.0 Oct 17, 2016

#523 in Caching

Download history 34/week @ 2023-11-06 15/week @ 2023-11-13 23/week @ 2023-11-20 23/week @ 2023-11-27 22/week @ 2023-12-04 20/week @ 2023-12-11 16/week @ 2023-12-18 21/week @ 2023-12-25 7/week @ 2024-01-01 18/week @ 2024-01-08 10/week @ 2024-01-15 21/week @ 2024-01-22 19/week @ 2024-01-29 14/week @ 2024-02-05 33/week @ 2024-02-12 122/week @ 2024-02-19

188 downloads per month
Used in tk-http

MIT/Apache

18KB
316 lines

Sendfile for Tokio

Status:alpha
Documentation:http://docs.rs/tk-sendfile

A thread pool that can process file requests and send data to the socket with zero copy (using sendfile).

Challenges:

  1. While sendfile is non-blocking when writing to socket, it blocks for disk access for two cases: initial open() and for reading file inside the sendfile() system call itself
  2. Doing more than single sendfile operation requires some bookkeeping
  3. It should be possible to implement file cache (both opened files and in-memory file data) transparently for the user
  4. [TODO] Serving user-specified file paths requires non-trivial code to prevent symlink attacks

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6MB
~94K SLoC