perf(db): accelerate parallel trace ingestion / 加速并行 trace 摄取 - #673
Merged
Conversation
Replace the dual token fan-out with one packed-token consumer that only assembles selected metric values. Add regression coverage for nested lookalikes, scalar and compound values, duplicate keys, malformed input, and both metric phases.\n\n中文:优化 trace 指标解析。用单一 packed-token 消费器替代双路 token 分发,仅组装需要的指标值;补充嵌套同名字段、标量与复合值、重复键、异常输入及两个指标阶段的回归测试。
Split CPU-heavy trace preparation from atomic persistence, run it in a vCPU-scaled bounded worker pool, cap concurrent uploads, and recheck links under row locks. Add worker transfer, queue-bound, failure-recovery, and concurrent-ingest regression coverage.\n\n中文:并行化 trace replay 预处理。将 CPU 密集型预处理与原子化持久化拆分,使用按 vCPU 数量伸缩的有界 worker 池执行,限制并发上传,并在行锁内重新检查关联状态;补充 worker 数据传输、队列内存上限、失败恢复及并发摄取回归测试。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stream-jsontoken fan-out with one packed-token consumer that materializes only selected metricsos.availableParallelism()INGEST_TRACE_WORKERSoverrideinsertTraceReplay()API for backfills and other callersThis follows merged PR #672 and addresses the parser slowdown observed while staging InferenceX run
30781275770.Functional-safety validation
3332.5pxvs3334px ± 1px), with the authoritative sharded CI run triggered when this PR leaves draft中文说明
stream-jsontoken 分发改为单一 packed-token 消费器,只实例化实际需要的指标os.availableParallelism()使用有界 worker 池执行 CPU 密集型预处理INGEST_TRACE_WORKERS覆盖insertTraceReplay()API,兼容 backfill 和其他调用方这是已合并 PR #672 的后续优化,用于解决暂存 InferenceX 运行
30781275770时观察到的解析性能下降。功能安全验证
3332.5px,预期3334px ± 1px),PR 退出 draft 后将以分片 CI 结果为准Note
Medium Risk
Touches ETL persistence (row locking, concurrent trace linking) and large-document JSON parsing; behavior is heavily tested but ingest correctness and memory bounds matter in production.
Overview
Speeds up CI trace ingestion for large agentic runs by replacing the dual
stream-jsontoken tee with a single packed-token pass that only assembles selectedmetrics/warmup_metricskeys (fewer tokens on multi‑GiB blobs), plus new parser tests for nested lookalikes, duplicate keys, and edge cases.Splits trace work into prepare vs persist:
prepareTraceReplaydoes gzip/derivation (usable from worker threads);persistPreparedTraceReplayuploads chunks and links rows. Persistence nowSELECT … FOR UPDATEand recheckstrace_replay_idinside the transaction so concurrent ingests cannot insert orphan blobs. Cache-hit metrics are computed during prepare and applied in the same transaction.CI path (
ingest-ci-run) queues trace jobs on aTraceReplayWorkerPoolsized from vCPUs /INGEST_TRACE_WORKERS, holds each worker slot until the upload callback finishes (bounded memory), and limits DB uploads with anAsyncSemaphore(max 2 concurrent). SequentialinsertTraceReplay()remains for other callers.Reviewed by Cursor Bugbot for commit f4e4518. Bugbot is set up for automated code reviews on this repo. Configure here.