3 releases (breaking)
0.3.0 | Sep 16, 2024 |
---|---|
0.2.0 | Aug 20, 2024 |
0.1.0 | Jan 13, 2024 |
#77 in #server-framework
150 downloads per month
94KB
2.5K
SLoC
WTX
A collection of different transport implementations and related tools focused primarily on web technologies. Contains the implementations of 5 IETF RFCs (RFC6265, RFC6455, RFC7541, RFC7692, RFC9113), 2 formal specifications (gRPC, PostgreSQL) and several other invented ideas.
- Client API Framework
- Database Client
- Database Schema Manager
- gRPC Client/Server
- HTTP Client Framework
- HTTP Server Framework
- HTTP2 Client/Server
- Pool Manager
- UI tools
- WebSocket Client/Server
Embedded devices with a working heap allocator can use this no_std
crate.
Performance
Many things that generally improve performance are used in the project, to name a few:
- Manual vectorization: When an algorithm is known for processing large amounts of data, several experiments are performed to analyze the best way to split loops in order to allow the compiler to take advantage of SIMD instructions in x86 processors.
- Memory allocation: Whenever possible, all heap allocations are called only once at the start of an instance creation and additionally, stack memory usage is preferably prioritized over heap memory.
- Fewer dependencies: No third-party is injected by default. In other words, additional dependencies are up to the user through the selection of Cargo features, which decreases compilation times. For example, you can see the mere 16 dependencies required by the PostgreSQL client using
cargo tree -e normal --features postgres
.
Since memory are usually held at the instance level instead of being created and dropped on the fly, it is worth noting that its usage can growth significantly depending on the use-case. If appropriated, try using a shared pool of resources or try limiting how much data can be exchanged between parties.
High-level benchmarks
Checkout wtx-bench to see a variety of benchmarks or feel free to point any misunderstandings or misconfigurations.
There are mainly 2 things that impact performance, the chosen runtime and the number of pre-allocated bytes. Specially for servers that have to create a new instance for each handshake, pre-allocating a high number of bytes for short-lived or low-transfer connections can have a negative impact.
Low-level benchmarks
Anything marked with #[bench]
in the repository is considered a low-level benchmark in the sense that they measure very specific operations that generally serve as the basis for other parts.
Take a look at https://bencher.dev/perf/wtx to see all low-level benchmarks over different periods of time.
Examples
Demonstrations of different use-cases can be found in the wtx-instances
directory as well as in the documentation.
Limitations
Does not support systems with 16bit memory addresses and expects the infallible addition of the sizes of 8 allocated chunks of memories, otherwise the program will overflow in certain arithmetic operations involving usize
potentially resulting in unexpected operations.
For example, in a 32bit system you can allocate a maximum of 2^29 bytes of memory for at most 8 elements. Such a scenario should be viable with little swap memory due to the likely triggering of the OOM killer or through specific limiters like ulimit
.
Possible future features
- WebSocket over an HTTP/2 stream (https://datatracker.ietf.org/doc/html/rfc8441).
- WebTransport over HTTP/2 (https://datatracker.ietf.org/doc/draft-ietf-webtrans-http2).
- Static web server
Dependencies
~1.5MB
~38K SLoC