Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

RocksDB Blog 2 min read Deep dive hardMaster

IO Activity Tagging

RocksDB automatically tags every IO operation with an `IOActivity` enum value (flush, compaction, DB open, Get, MultiGet, iterator, checksum verification, entity reads and others) and propagates it through `IOOptions` to the file system. Custom FileSystem implementations can switch on this tag to prioritize latency-sensitive user reads, throttle background compaction, or track DB-open IO. RocksDB also exposes per-activity read and write latency histograms such as FILE_READ_GET_MICROS and FILE_WRITE_COMPACTION_MICROS for diagnosing bottlenecks. Values 0x80–0xFE are reserved for custom use.

Related posts

  • Timeseries indexing at scale

    Datadog Engineering mediumAdept

    Datadog replaced its timeseries index, which auto-generated materialized indexes from a log of slow queries, with an inverted index that unconditionally indexes every metric;tag pair, much like search engines map words to documents. The original Go service used SQLite for index definitions and the query log and RocksDB for Tagsets, Metrics and Indexes. It worked for predictable programmatic queries, but unpredictable user queries fell back to full scans, causing timeouts and manual index toil. The next-gen design drops SQLite, keeps RocksDB, and answers tag filters by intersecting posting lists of timeseries IDs. The two generations are compared on performance and reliability.

  • Evolving our real-time timeseries storage again: Built in Rust for performance at scale

    Datadog Engineering hardMaster

    Datadog's sixth-generation real-time timeseries database (RTDB) is a Rust rewrite that unifies two earlier engines, one for scalar metrics and one for DDSketch distributions, after earlier generations built on Cassandra, Redis, MDBM, a Go B+ tree and RocksDB. Its storage engine, Monocle, is an LSM tree with a worker-per-shard, thread-per-core design. Kafka intake tasks route data over per-shard MPSC channels to single-threaded Tokio shards, which keeps locks off the write path. Permit-based throttling and CoDel-based cost scheduling keep the system stable under load, and snapshots provide recovery. Datadog reports 60x higher ingestion throughput and 5x faster queries at peak scale.

  • Husky: Efficient compaction at Datadog scale

    Datadog Engineering hardMaster

    Husky, Datadog's observability event store layered over object storage, keeps query cost low by controlling fragment count and layout through streaming compaction. Writers flush small sorted fragments into time-bucketed tables. Compactors lazily run size-tiered k-way merges, waiting until a few dozen fragments are available, which cuts CPU and object-store API costs by an order of magnitude. Metadata is swapped atomically in FoundationDB. A custom columnar format with per-column headers and fixed-size row groups lets each compaction use one GET per input, saturate the CPU and run in bounded memory, and sort schemas let queries skip fragments using only their metadata.

  • Native Async/Coroutine Reads in RocksDB

    RocksDB Blog hardMaster

    RocksDB 11.10.0 adds experimental native asynchronous Get/MultiGet APIs (callback-based GetAsync/MultiGetAsync and Folly-task-based CoroDB::CoGet/CoMultiGet) that suspend a read at the SST block-miss filesystem boundary and resume it on the same io_uring-backed EventBase thread, so a small read executor can sustain high storage queue depth without one parked thread per read. Per-request PerfContext/IOStatsContext are swapped in and out of TLS via Folly RequestContext, with CPU time counted only during active slices. Benchmarks on four cores with an 11 GB direct-I/O dataset show coroutines losing ~14% at low concurrency with single-key lookups but gaining up to 305% over threads with larger batches, and 8–55% over the older ReadOptions::async_io path at 20+ tasks.

  • Performance improvements in the Datadog Agent metrics pipeline

    Datadog Engineering mediumAdept

    Profiling the Go-based Datadog Agent under heavy DogStatsD load showed that computing a unique context key per metric, especially sorting and deduplicating tags, dominated CPU. Datadog specialized the sort by tag count, switched to murmur3 with 64-bit keys to hit Go's fast map paths, and then replaced ordered hash chaining with order-independent XOR of tag hashes, deduplicated through a reusable fixed-size custom hash set that removes sorting entirely. Micro-benchmarks show context generation 11–80% faster depending on tag count, and at ~200k metrics/s on 4-core VMs Agent CPU fell about 40% (1 core vs 1.6).

The quest for software engineering knowledge.

Look:
Layout: