Skip to content

perf: drop per-request schema and stream-metadata scans on ingest - #160

Merged
VibeSWE merged 4 commits into
mainfrom
perf/ingest-request-overhead
Nov 24, 2026
Merged

VibeSWE merged 4 commits into
mainfrom
perf/ingest-request-overhead

Conversation

@VibeSWE

@VibeSWE VibeSWE commented Nov 24, 2026 •

Copy link
Copy Markdown

Description

Two small reductions in per-request work on the ingest path.

  • Schema validation looks fields up by name. fields_mismatch scanned the schema once per field of every row. A lookup table built once per batch replaces the scan; the first field of a name still wins. This path runs for batches that leave the known-scalar fast path (arrays, nested values, new fields). A differential test compares the table with the previous scan, which is kept as a test-only oracle.
  • Two scans of stream metadata are dropped. ingest and post_event listed every internal stream of the tenant, locking each stream's metadata, to ask whether one named stream is internal; they now look that stream up. The dataset field-count check built a sorted schema to read its length; it now reads the length of the stored schema map.

Measured

By the agent that wrote the changes, release build. These numbers were not re-measured:

Change Before After
Field lookup, 100 fields × 400 rows, instructions per batch 67.5M 12.4M
Internal-stream check, 64 streams, instructions per request 4,647 539

The field-count change is not measured on its own.

Verified

This branch was not tested on its own. With all six PRs of this set merged together (#156–#161): cargo test --lib 1,515 passed, 0 failed, and on a running server every one of 17 protobuf requests (15 realistic shapes filling the 10 MiB payload limit, 2 crafted) returned 200 and stored the expected number of rows, authenticated with an API key.

Related

A third change from the same pass, reading the stream metadata under one lock per request, is held back: #155.

Merging

Independent of the OTLP PRs and merges cleanly with them. It conflicts with the security-hardening PR in one place, where both append tests to the same module in ingest_utils.rs; keep both.


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

🤖 Generated with Claude Code

VibeSWE and others added 3 commits November 23, 2026 16:24
fields_mismatch scanned the schema once per field of every row. A lookup table
built once per batch replaces the scan; the first field of a name still wins.
It runs for batches that leave the known-scalar fast path (arrays, nested
values, new fields).

Benchmark by the agent that wrote it (100 fields, 400 rows, release build):
67.5M -> 12.4M instructions per batch. A differential test compares the table
with the previous scan, which is kept as a test-only oracle.

Written by a GLM-5.3 agent; reviewed by Claude, not re-measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- ingest and post_event listed every internal stream of the tenant, locking
  each stream's metadata, to ask whether one named stream is internal. They
  now look up that stream.
- The dataset field-count check built a sorted Schema to read its length. It
  now reads the length of the stored schema map.

Benchmark by the agent that wrote the first change (64 streams, release
build): 4,647 -> 539 instructions per request. The second is not measured on
its own.

First change written by a GLM-5.3 agent; reviewed by Claude, not re-measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@VibeSWE VibeSWE added the performance Throughput, latency or resource cost label Nov 24, 2026
…verhead

# Conflicts:
#	src/handlers/http/modal/utils/ingest_utils.rs
@VibeSWE
VibeSWE merged commit fcba4e5 into main Nov 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Throughput, latency or resource cost

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant