$ show alibaba/xquic
XQUIC is a production-grade C implementation of the QUIC transport protocol (RFC 9000) and HTTP/3 (RFC 9114), developed by Alibaba. It provides a full-featured QUIC stack including connection management, packet encryption, loss detection, congestion control (BBR, CUBIC, NewReno, Copa), and HTTP/3 with QPACK header compression. The library also supports experimental extensions such as Multipath QUIC, Forward Error Correction (FEC), and Media over QUIC (MoQ) for streaming media. The architecture is modular with a callback-driven engine, pluggable congestion control and TLS backends (BoringSSL, BabaSSL), and extensive testing infrastructure including unit tests (CUnit), integration shell scripts, and interoperability tests. The codebase is well-structured with reusable utility components (ring buffers, hash tables, object pools, timer managers) and demonstrates strong software engineering practices, though the large number of feature flags and experimental extensions introduce some complexity and potential drift.
The LLM identified 4 files worth highlighting for reuse:
A two-dimensional hash table that supports lookups by two keys simultaneously. It uses separate buckets for each dimension and provides insert, delete, and lookup operations. This is a non-trivial data structure that can be reused in any project requiring efficient two-key mappings.
A fixed-capacity circular memory buffer that supports enqueue, dequeue, undo (pop without deallocation), and duplicate operations. It is designed for variable-sized objects and provides efficient memory reuse. The implementation is clean and isolated, making it reusable for any FIFO or sliding window scenario.
A pre-allocated object pool with optional mprotect-based memory protection. It manages fixed-size objects in contiguous memory blocks and provides allocate/free operations with O(1) overhead. The pool can be configured to protect unused pages, useful for debugging or security-critical applications.
A type-safe string formatting library inspired by nginx's ngx_sprintf. It supports format specifiers like %s, %d, %x, %p, and custom types for IP addresses, times, etc. The implementation avoids buffer overflows by using a pre-allocated buffer and provides a chain of buffers for large output. It is a drop-in replacement for printf in constrained environments.