Vectorizes `quiche::header_properties::HasInvalidHeaderChars`.

Previously, `HasInvalidHeaderChars` scanned each byte using an early-exit loop
over a 256-entry `std::array<bool, 256>` lookup table (`IsInvalidHeaderChar`),
which blocked LLVM auto-vectorization and consumed ~3,640 GCUs fleet-wide
(`IsInvalidHeaderChar` consumed an additional ~192 GCUs).

This change replaces the lookup table with a branch-free `constexpr` predicate
(`IsValidHeaderCharImpl`) and accumulates validity over `uint8_t` bytes using
bitwise `&=`. With `-c opt`, Clang vectorizes `HasInvalidHeaderChars` at
`vectorization width: 16, interleaved count: 4` with zero register spills.

Microbenchmark results on Broadwell (`//third_party/quiche/balsa:header_properties_benchmark`,
`setarch x86_64 -R --benchmark_repetitions=5 --benchmark_min_time=0.5s`):

- 16 B: 15.6 ns (984 MB/s) -> 11.7 ns (1.32 GB/s)
- 64 B: 56.0 ns (1.07 GB/s) -> 12.0 ns (5.04 GB/s, 4.7x)
- 256 B: 246 ns (1.01 GB/s) -> 27.2 ns (8.93 GB/s, 9.0x)
- 4096 B: 3,448 ns (1.11 GB/s) -> 384 ns (9.95 GB/s, 9.0x)

Also adds exhaustive 256-byte and vector-boundary unit tests in
`HeaderPropertiesTest` (verified in default and `-c dbg --config=asan` modes)
and a multi-size microbenchmark in
`//third_party/quiche/balsa:header_properties_benchmark`.

Developed with this skill: http://google3/experimental/users/birenroy/skills/vectorizing_cpp_strings/

Protected by optimization with no functional change; not protected.

PiperOrigin-RevId: 1033890867
2 files changed
tree: 87bc9c76158b009959bc69f9c87570746a76c098
  1. build/
  2. depstool/
  3. quiche/
  4. .bazelrc
  5. .bazelversion
  6. BUILD.bazel
  7. CONTRIBUTING.md
  8. LICENSE
  9. MODULE.bazel
  10. MODULE.bazel.lock
  11. README.md
  12. WHITESPACE
README.md

QUICHE

QUICHE stands for QUIC, Http, Etc. It is Google‘s production-ready implementation of QUIC, HTTP/2, HTTP/3, and related protocols and tools. It powers Google’s servers, Chromium, Envoy, and other projects. It is actively developed and maintained.

There are two public QUICHE repositories. Either one may be used by embedders, as they are automatically kept in sync:

To embed QUICHE in your project, platform APIs need to be implemented and build files need to be created. Note that it is on the QUICHE team's roadmap to include default implementation for all platform APIs and to open-source build files. In the meanwhile, take a look at open source embedders like Chromium and Envoy to get started:

To contribute to QUICHE, follow instructions at CONTRIBUTING.md.

QUICHE is only supported on little-endian platforms.

Build and run standalone QUICHE

QUICHE has binaries that can run on Linux platforms.

Follow the instructions to install Bazel.

sudo apt install libicu-dev clang lld
cd <directory that will be the root of your quiche implmentation>
git clone https://github.com/google/quiche.git
cd quiche
CC=clang bazel build -c opt //...
./bazel-bin/quiche/<target_name> <arguments>

There are several targets that can be built and then run. Full usage instructions are available using the --helpfull flag on any binary.

  • quic_packet_printer: from a provided packet, parses and prints out the contents that are accessible without decryption.

Usage: quic_packet_printer server|client <hex dump of packet>

  • crypto_message_printer: dumps the contents of a QUIC crypto handshake message in a human readable format.

Usage: crypto_message_printer_bin <hex of message>

  • quic_client: connects to a host using QUIC and HTTP/3, sends a request to the provided URL, and displays the response.

Usage: quic_client <URL>

  • quic_server: listens forever on --port (default 6121) until halted via ctrl-c.

  • masque_client: tunnels to a URL via an identified proxy (See RFC 9298).

Usage: masque_client [options] <proxy-url> <urls>

  • masque_server: a MASQUE tunnel proxy that defaults to port 9661.

Usage: masque_server

  • web_transport_test_server: a server that clients can connect to via WebTransport.

  • moqt_relay: a relay for the Media Over QUIC transport for publishers and subscribers can connect to.

Usage: moqt_relay

Logging

Most log messages in QUICHE use the QUICHE_DLOG macro. In standalone quiche, these all either go to stderr, or are suppressed, based on the --stderrthreshold flag.

To send INFO level log messages to a file, you would therefore invoke

<binary> <args> > <logfile> 2>&1

Use the --helpfull flag for more.