Skip to content

Optimize DuckDB sync pipeline after merge projection work #21

Description

@marcusschiesser

Context

Follow-up work from docs/sync-optimization-ideas.md.

Current 10k trace sync timings:

Run Initial Sync No-Op Sync
Final optimized merge projection 5.80-5.88s ~22-23ms

Current representative profiled cost shape:

Phase Time
Object load + OTEL conversion 2.86-2.90s
Raw row normalization 0.28-0.30s
Projection total ~1.70s
Bookkeeping ~0.002s

Tasks

  • Pipeline object loading and projection with bounded concurrency while keeping DuckDB writes serialized.
  • Parse OTEL resource spans directly into RawEventRow records for sync, skipping the intermediate IngestionEvent[] allocation where possible.
  • Build pre-normalized projection rows or deltas during OTEL conversion so projection does not re-normalize event bodies.
  • Benchmark vectorized DuckDB bulk loading for raw event storage and observation appends against the current row appender path.
  • Remove in-memory eventJson from RawEventRow if no hot compatibility path depends on it.
  • Add an explicit empty projection fast path that skips existing-row probes, deletes, and historical replay checks on fresh caches.

Acceptance Criteria

  • Each task has before/after timing for the 10k trace perf run.
  • pnpm --filter @agentpond/duckdb test passes for each completed task.
  • pnpm test passes before closing the ticket.
  • Update docs/sync-optimization-ideas.md if implementation results change the recommended order or measured bottlenecks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions