Skip to content

perf: Phase 1–3 low-level ingest, OTLP, Parquet query, caching & connector optimizations - #195

Merged
VibeSWE merged 32 commits into
mainfrom
t3/low-level-performance
Dec 2, 2026
Merged

VibeSWE merged 32 commits into
mainfrom
t3/low-level-performance

Conversation

@VibeSWE

@VibeSWE VibeSWE commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

Implements Phases 1–3 of low-level performance, caching, and durability optimizations across ingest, OTLP, Parquet querying, metastore caching, object-storage multipart uploads, Kafka ingestion, and HotTier management — preserving 100% Parseable API, SQL, OTLP, JSON, PromQL, Flight, and crash-recovery compatibility.

Highlights

  • Release & Build Optimization: Portable + CPU-tuned (x86-64-v3, ARMv8+outline-atomics, apple-m1) release targets, Fat LTO Dockerfiles (205.0 MB → 130.3 MB, -36.4%), auto-selecting scripts/download.sh, opt-in PGO hooks, and switching arrow-flight/tonic to tls-ring.
  • Flat JSON & Ingest Pipeline: Single-pass zero-unsafe 8-byte SWAR + Clinger decimal flat JSON scanner (src/utils/json/strict.rs), off-worker JsonBytes decompression fix (HTTP 400 → 200 on gzip/zstd/br) + /api/v1/logstream/{stream} fast path, native numeric field_stats, packed u128/u64 log clustering sort, coalesced 256 KiB staging IPC reads, and FutexWorkerPool eliminating Rayon sched_yield storms (-99.98%+) with panic logging.
  • OTLP End-to-End Fast Paths (Track 2):
    • Single-pass indexed OTLP Protobuf walk + direct LogRecord wire decoder (src/otel/wire.rs, src/otel/protobuf_stream.rs) with byte-identical prost error/recursion fallback.
    • Single-pass OTLP JSON DeserializeSeed visitor (src/otel/json_fast.rs, -84.2% allocations on 512-record batches).
    • Direct columnar Arrow RecordBatch builders for OTLP Logs, Metrics (including List builders and bit-exact __series_hash_u64), and Traces (direct hex ID writes) wired into ingest_utils.rs.
  • Parquet Querying, Late Materialization & Caching (Tracks 1 & 3):
    • Real Utf8View Parquet scans + recursive Flight wire materialization, Unicode-sound SIMD/SWAR compiled ILIKE predicate pushdown, and certified interior staging elision in Progressive TopK.
    • Two-phase Parquet RowSelection late materialization for eligible local Progressive TopK scans (src/query/ordered_topk.rs) with object-version + RowNumber tracking and single-pass remote/certified guards.
    • Zero-clone SelectedManifestFiles and explicit ParquetCachePolicy (Bypass / Remote / LocalImmutable) in src/query/stream_schema_provider.rs.
    • 16-shard xxh3 O(1) slab-indexed small_file_cache with bound OnceCell<Arc<ParquetMetaData>> (PageIndexPolicy::Optional), LocalImmutable + no-ctime stat validator, 256-FD-capped PinnedLocalFileReader, synchronous localfs.rs publication invalidation, and S1–S7 fixes.
    • Two-tier validated LRU DecodedManifestCache (PostgreSQL conditional body skip, LocalFS FD-fingerprinted & Cloud ETag decode skip) wired end-to-end with *_shared manifest reads and run_soft_pressure_relief().
  • Storage, Kafka & HotTier Hardening (Track 4):
    • S3/GCS/Azure 10,000-part multipart sizing cap, hard P_MAX_UPLOAD_MEMORY_BYTES pre-allocation refusal, 4,000 MiB Azure single-PUT/buffering alignment, and --min-multipart-size bounds.
    • Kafka connector: wired all 7 unapplied ConsumerConfig flags (fixing fetch.wait.max.ms and max.partition.fetch.bytes/fetch.message.max.bytes alias collision), (partition, minute) Arrow batching, transient ArrowError::IoError/IpcError durability, and Dekker SeqCst per-partition backpressure/failure isolation.
    • HotTier: O(1) used/reserved byte counters, dirty-only off-lock checkpoints, and unchanged completed-minute rescan skipping while preserving full startup disk rebuild.

Measured Benchmarks (Pinned 4-CPU Server 0-3 vs 4-CPU Client 4-7, Base bc4c6c79 → Phase 3 a290ffbe)

Workload Base (bc4c6c79) Phase 2 (818a4fa3) Phase 3 (a290ffbe) Total Gain
PromQL query_range (10k samples) 57.17 ms 8.12 ms 7.97 ms 7.17×
/api/v1/logstream flat JSON 1,390 req/s 5,185 req/s 5,053 req/s 3.64×
OTLP JSON Logs (/v1/logs) 909 req/s 1,721 req/s 3,071 req/s 3.38× (1.78× vs P2)
OTLP Protobuf Logs (/v1/logs) 1,917 req/s 4,463 req/s 4,571 req/s 2.38×
OTLP Protobuf Traces (/v1/traces) 2,444 req/s 2,911 req/s 5,559 req/s 2.27× (1.91× vs P2)
Warm LocalFS ILIKE 3.40 ms 1.77 ms 1.52 ms 2.24× (1.16× vs P2)
Flat JSON /api/v1/ingest 3,423 req/s 5,197 req/s 5,034 req/s 1.47×
Warm LocalFS Equality (WHERE =) 3.66 ms 2.74 ms 2.51 ms 1.46×
Wide 32-Col TopK (LIMIT 50) 31.12 ms 22.73 ms 22.26 ms 1.40×
Warm LocalFS Kernel Read I/O (wide32_lat) — 127.0 MiB / 2,746 syscr 61 KiB / 426 syscr -99.95% bytes / -84.5% syscalls

Verification

  • cargo test --offline --locked --lib: 2,322 passed, 0 failed
  • cargo test --offline --locked --features kafka --lib -- connectors::kafka: 91 passed, 0 failed
  • cargo clippy --offline --locked --lib -- -D warnings (default + --features kafka): 0 warnings
  • rustfmt --edition 2024 --check: clean across all modified files
  • Live scripts/ingest-performance/compatibility.py (baseline bc4c6c79 vs candidate a290ffbe): 21/21 scenarios identical
  • scripts/test-download.py (10/10) and scripts/ingest-performance unit tests (22/22) passing

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

VibeSWE and others added 30 commits December 1, 2026 23:58
- Eliminate serde_json::Deserializer round-trips for Float64 (direct
  zmij formatting when guaranteed bit-identical to legacy non-roundtrip
  parsing, keeping exact NaN/Inf/-0.0 and Float16/Float32 fallback) and
  pure-ASCII naive Timestamp(_, None) columns in QueryResponse.
- Downgrade per-batch 'Returning query results' logs in response.rs to
  tracing::debug! while keeping a single top-level info! log for
  non-streaming queries.
- Replace the 4-hop record_batches_to_json round-trip in /counts with
  direct typed Arrow column reads.
- Replace record_batches_to_json in PromQL group_rows and
  discover_labels with direct typed Arrow column reads and handle
  sliced StringViewArray/BinaryViewArray compaction and shared buffer
  deduplication in PromQL's 64 MiB batch admission check.
- Fix local send_null parity in traces.rs and read
  duplicate_anchor_count directly from Arrow in query_context.rs.
Check cached timestamp values and indexed IPC slice bounds against the default partition window. Keep residual filters and forward their batches directly to progressive TopK. Compact sparse Utf8View and BinaryView payloads after selecting winners so discarded buffers do not exhaust the merge reservation.
…ad memory budget

S3 and the GCS XML API reject part numbers above 10,000, but every backend
uploaded in parts of exactly P_MULTIPART_MIN_SIZE. A file larger than
10,000 parts (over 160 GiB at the 16 MiB default) failed at part 10,001,
was aborted, and was retried from staging forever.

- multipart_part_size raises the part size just enough to fit 10,000
  parts, within per-store limits (S3/GCS: 5 GiB parts and 5 TiB objects;
  Azure: 4,000 MiB blocks). A file larger than a store accepts is refused
  before the upload is created. upload_file_parts applies the same
  10,000-part raise as a second guard.
- A raised part that would also exceed P_MAX_UPLOAD_MEMORY_BYTES is refused
  before anything is buffered, and the error names the budget to set.
  A configured part size above the budget keeps its old behaviour.
- UploadBuffering::payload_bytes reserves the raised part size, so the
  memory budget covers what the upload actually allocates.
- Azure caps its single-PUT threshold and base block size at 4,000 MiB, so
  a 4,000-5,120 MiB file is no longer sent as one Put Blob over Azure's
  5,000 MiB limit. Its upload_buffering reports the same size.
- --min-multipart-size / P_MULTIPART_MIN_SIZE is bounded to 5 MiB..=5 GiB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng, and isolate partition failures/backpressure
… records directly

Each resource and scope level is now read in a single pass that merges its
singular fields as prost does and keeps child references (prefix, content
start, content end) instead of a field pass followed by a children pass.
References are capped (1024 scopes, 2048 records, 12 B each) so a walk still
holds under 64 KiB; children past the cap are found by a second pass over the
rest of the level. `outline` only counts records per scope.

Log records are decoded straight from their wire bytes into one reused
LogRecord (src/otel/wire.rs). Any unusual or broken encoding (wrong wire
type, group, oneof switch, duplicate message field, invalid UTF-8, bad
varint, nesting past 24 AnyValue levels) falls back to prost into a fresh
record, so errors stay byte-identical. The size cap is still checked first,
and the reused record is dropped once it retains over 64 KiB.

Adds differential tests against whole-request prost decoding: malformed
wire at every level, recursion limits (array nesting 47/48, groups
100/99/98/97), late partial success, duplicate singulars, oneof switches,
fallback freshness, empty and over-cap batches, and exhaustive cut/damage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e policy

Warm scans no longer deep-clone every File/Column of shared manifests.
collect_from_snapshot_cached now returns SelectedManifestFiles: the loaded
Arc<Option<Manifest>> handles plus newest-first (manifest, file) indices,
pruned (sequential below 2,048 files / 250k columns, ordered Rayon above)
and truncated for LIMIT exactly as before. Scan planning borrows &File
through a ScanFile trait (balanced groups, partitioned files, interior
split, manifest row count), copying only each PartitionedFile path. Only
streams with a hot tier copy their post-prune selection, because
HotTierManager classifies owned files; collect_from_snapshot clones only
surviving shared entries and moves entries out of unshared manifests.

The `object_store_url == "file:///"` check is replaced by ParquetCachePolicy,
classified from the planner path (ParquetScanSource: Staging, HotTier,
Published) and URL: staging leases are Bypass, hot tier and published
LocalFS files are LocalImmutable(origin), other stores are Remote.
Server cache settings are read only for cacheable scans.
local_immutable_cache_enabled keeps both local origins uncached, so
behaviour is unchanged until the local cache is wired in.
parquet_scan_plan_with_cache_options keeps its tuple signature for tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VibeSWE
VibeSWE merged commit 72976dc into main Dec 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant