Skip to content

[Draft][POC][ray-core] [REP-64 POC] Embedded RocksDB Storage Backend for Ray GCS - #63032

Closed
jhasm wants to merge 63 commits into
ray-project:masterfrom
jhasm:jhasm/rep-64-poc-1
Closed

jhasm wants to merge 63 commits into
ray-project:masterfrom
jhasm:jhasm/rep-64-poc-1

Conversation

@jhasm

@jhasm jhasm commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

NOTE: This is a POC. Production ready version of this change is in #63657

Summary

This PR is a proof of concept for REP-64 (Embedded GCS Storage Backend), not a feature merge. It is here to prove the design works, surface its risks, and produce reproducible evidence for every concrete claim in the REP — before anyone sinks weeks into production hardening.

The dossier this PR ships under rep-64-poc/ is the load-bearing artifact. Per-claim verdicts and one-command repros are in rep-64-poc/EVIDENCE.md.

Want to help validate? The POC was developed on a single Linux ext4 VM. Everything that needs a different filesystem, cloud volume, K8s cluster, arm64, or LLVM toolchain with sanitizers is gated on collaborators. rep-64-poc/COLLABORATORS.md is a triage queue: pick one based on what you have access to, run the listed commands, drop the JSON output here. Each item lists what to test, why it matters, exact commands, and what success looks like.

TL;DR

The REP's design works on the substrates we can test rigorously here, with five findings that warrant maintainer attention before merge:

Finding Action requested
🔴 REP's "0.01–0.1 ms RocksDB write" claim is misleading. That's a memtable-only / sync=false number. The durable-write path the REP requires is fsync-bounded: 3.81 ms p50 on probe-verified ext4. The per-call cost is physics — no software path can reduce it. (Reads remain 0.01–0.1 ms class as claimed.) REP perf section needs a sync vs non-sync split.
🟡 Inline Async* calls block the GCS event loop for the full 3.8 ms fsync. Added an opt-in offload path (gcs_rocksdb_async_offload) that posts each call to a boost::asio::thread_pool; the event loop returns in ~40 µs. Same per-call latency, but 2.5× aggregate throughput under pipelined writers (215 → 593 ops/s after the strand-correctness fix below) thanks to RocksDB group commit. Currently default-off; see Open Question 6. Decide: keep opt-in, flip default to offload, or remove inline path entirely.
🟡 Offload path silently broke per-key submission-order ordering, now fixed via boost::asio::strand bucketing. The first offload commit (e710272d) routed every Async* call to the bare pool, which lets two AsyncPut(K, !overwrite) calls both observe "not found" and both write — and three other manifestations of the same bug (LWW, Delete-then-Put, read-your-writes). Single-key ops now dispatch through RunIoForKey(table, key, work) → strand bucket of hash(table, key) % gcs_rocksdb_strand_buckets (default 64). Multi-key/scan ops use RunIoUnordered (bare pool; semantics match Redis pipelining and InMemoryStoreClient under concurrent callers). Zero measurable perf cost — pipelined offload throughput went 535 → 593 ops/s (within run-to-run noise). Full audit in rep-64-poc/POC_AUDIT.md. Confirm the strand approach (vs OptimisticTransactionDB) is the production pattern you want; sanity-check the bucket-count default.
🟡 Cluster-ID-mismatch fail-fast cannot be implemented as the REP draws it. Ray's GCS init order has InitKVManager() before GetOrGenerateClusterId() and the persisted ID is the cluster ID. PVC-mismatch detection requires an external authoritative source (K8s downward API). Deferred to Phase 8 with an honest write-up. Confirm the deferral is acceptable; alt-design welcome.
🟢 Two Ray-core regressions surfaced and are fixed inline. Both are independently upstream-worthy: @boost URL (jfrog → archives.boost.io); BUILD.rocksdb lib path. Either could be split into a separate small PR if the maintainers prefer. Indicate preference: bundled vs split commits.

Phases 1–8 each produced a written report with claim addressed / method / result / skepticism / pivot decision. Verdicts:

# REP claim Verdict
1 RocksDB integrates into Ray Bazel build cleanly ✅ Verified
2 Binary size bounded (PLAN pivot trigger: 50 MB) ✅ Verified — 32.0 MB unstripped / 23.1 MB stripped [master: 23.8 MB unstripped / 16.5 MB stripped] [Delta: +8.2 MB unstripped (+34%), +6.5 MB stripped (+39%)]
3 StoreClient API fits RocksDB ✅ Verified — StoreClientTestBase PASSES unmodified
4 State persists across close+reopen at storage layer ✅ Verified — sub-100 ms cold open at 10k entries
5 Ack ⇒ durable ✅ Verified on ext4 (cloud PVs pending collaborator)
6 Atomic GetNextJobID under N-thread contention ✅ Verified — caught + fixed a real TOCTOU race in this phase
7 RocksDB write 0.01–0.1 ms ❌ Contradicted for sync writes (3.81 ms p50, fsync-bounded; offload path leaves per-call cost unchanged but unblocks the event loop and yields 2.5× pipelined throughput; per-key strand layer adds zero measurable cost on top)
8 RocksDB read 0.01–0.1 ms ✅ Confirmed (0.97 µs p50)
9 Recovery time ≥ Redis-based FT 🟡 Provisional yes (sub-100 ms storage-layer; head-to-head pending)
10 Stale-data protection on PVC swap 🟡 Storage-layer marker tested; fail-fast deferred to Phase 8

Full evidence dossier: rep-64-poc/EVIDENCE.md.

Size comparison after building image and wheel locally:

Artifact Published (2.55.1) This build (3.0.0.dev0 + RocksDB) Δ
.whl py3.10 manylinux2014_x86_64 70.2 MiB 73.4 MiB +3.2 MiB (+4.6%)
Final docker image (ray-py3.10-cpu) 2.15 GB 2.17 GB +~20 MB (+0.9%)

What's in this PR

Production-bound code (would land in a real merge)

  • bazel/BUILD.rocksdb (new) — drives RocksDB's CMake build via rules_foreign_cc, all optional features OFF, CMAKE_INSTALL_LIBDIR=lib for portability.
  • bazel/ray_deps_setup.bzl — adds @com_github_facebook_rocksdb; switches @boost URL to archives.boost.io (Ray-core regression fix, independent of REP-64).
  • src/ray/gcs/store_client/rocksdb_store_client.{h,cc} (new) — full StoreClient implementation. All 9 methods. Mutex-RMW GetNextJobID. Sync writes via WriteOptions::sync = true. AsyncBatchDelete uses MultiGet for the existence probe and skips tombstone writes for keys the probe found absent. AsyncDelete similarly skips the sync delete (and its fsync) when the key was not present. Cluster-ID marker plumbing (skipped when cluster_id is empty — see below). Two Async* execution paths: inline (default; runs on the caller's thread, matches InMemoryStoreClient semantics) and offload (gated by gcs_rocksdb_async_offload; posts work to a boost::asio::thread_pool so the event loop returns in ~40 µs, with the user callback re-posted to io_service). On the offload path, single-key ops (Put/Get/Delete/Exists) dispatch through a boost::asio::strand bucketed by hash(table, key) % gcs_rocksdb_strand_buckets so per-key submission order is preserved; multi-key/scan ops use the bare pool. Destructor uses wait() (not stop()+join()) to drain queued offload work without abandoning callbacks.
  • src/ray/gcs/store_client/tests/rocksdb_store_client_test.cc (new) — Phase 3 walking-skeleton unit tests (PutGet, RecoverAcrossReopen, JobIdMonotonicAndPersists, ClusterIdMarkerWritesOnFirstOpen) plus offload-path tests (OffloadPathRoundtripsAcrossPoolThreads, OffloadPathDestructorJoinsBeforeDbClose) plus four strand-correctness tests (OffloadStrandSerializesOverwriteFalseRace, OffloadStrandPreservesLastWriterWinsForSameKey, OffloadStrandPreservesDeleteThenPut, OffloadStrandPreservesCrossKeyParallelism).
  • src/ray/gcs/store_client/tests/rocksdb_smoke_test.cc (new) — Phase 2 link-and-run smoke test for the RocksDB dep.
  • src/ray/gcs/store_client/BUILD.bazel — new gcs_rocksdb_store_client library wired into gcs_store_client_lib.
  • src/ray/gcs/store_client/tests/BUILD.bazel — new rocksdb_smoke_test and rocksdb_store_client_test cc_test targets.
  • src/ray/gcs/BUILD.bazel — wires the new lib into gcs_server_lib.
  • src/ray/gcs/gcs_server.{h,cc} — adds StorageType::ROCKSDB_PERSIST + kRocksDbStorage = "rocksdb"; new InitKVManager branch. Passes empty cluster_id to RocksDbStoreClient because Ray's init order makes a real cluster_id unavailable at this point (fully written up in reports/phase-3-skeleton.md). Threads gcs_rocksdb_async_offload, gcs_rocksdb_io_pool_size, and gcs_rocksdb_strand_buckets from RayConfig into the RocksDbStoreClient ctor.
  • src/ray/common/ray_config_def.h — adds four knobs: gcs_storage_path (filesystem path for the RocksDB instance, required when gcs_storage=rocksdb), gcs_rocksdb_async_offload (default false, opt-in offload-IO path), gcs_rocksdb_io_pool_size (default 4, only meaningful when offload is on), gcs_rocksdb_strand_buckets (default 64, controls per-key ordering granularity on the offload path).

POC harness (lives entirely in rep-64-poc/, not on the production path)

Each phase ships a self-contained harness:

  • Phase 1 — harness/durability/probe_fsync.py (fsync-honesty probe), harness/docker-compose/ (Redis baseline).
  • Phase 4 — harness/durability/kill9/{writer.cc, verifier.cc, run_kill9.py}. Includes a deliberately-broken --ghost-writes mode that proves the harness has fault sensitivity.
  • Phase 5 — harness/concurrency/concurrency_test.cc. 16-thread × 1000-call stress on GetNextJobID + parallel-write linearizability + post-restart counter monotonicity. Caught + drove a real TOCTOU bug fix in GetOrCreateColumnFamily.
  • Phase 6 — harness/store_client_parity/rocksdb_parity_test.cc. Subclasses Ray's existing StoreClientTestBase (the same one the in-memory and Redis backends use). PASSES unmodified.
  • Phase 7 — harness/microbench/storage_microbench.cc. C++ side-by-side latency benchmark, p50/p95/p99/throughput. Default working dir is $HOME/.cache/... not /tmp — see methodology note about tmpfs masking fsync. Phase 7 addendum (commit e710272d) extends the bench with --include-offload, --io-pool-size, and --sequential flags so inline vs offload can be compared head-to-head; results in phase7-{sequential,pipelined}-offload-vs-inline.json. Second addendum (commit 31adefb2a0) adds --strand-buckets and re-runs the full matrix to confirm the strand layer doesn't regress throughput; results in phase7-strand-{sequential,pipelined}.json.
  • Phase 8 — harness/recovery/recovery_bench.cc (storage-layer cold-open + scan); harness/kind/ray-head-rocksdb.yaml (reference K8s manifest with annotated failure modes); harness/cloud/cloud_fsync_check.sh (collaborator-runnable cloud-volume wrapper).

Dossier (/rep-64-poc/)

  • rep-64-poc/README.md — orientation for reviewers.
  • rep-64-poc/EVIDENCE.md — claim-to-evidence map. Read first.
  • rep-64-poc/RISKS.md — live risk register with end-of-POC status per row.
  • rep-64-poc/POC_AUDIT.md — post-strand walkthrough of the full RocksDbStoreClient surface (what was checked for the same class of ordering bug, what changed, what was verified correct as-is, intentional design choices flagged for reviewer pushback).
  • rep-64-poc/reports/phase-N-*.md — eight phase reports with claim / method / result / skepticism / repro / pivot.
  • rep-64-poc/reproducers/README.md — one-command repros for everything that runs on the dev VM.
  • rep-64-poc/COLLABORATORS.md — per-task help queue for things that need other environments (different FS, cloud volume, K8s, arm64, sanitizers).
  • rep-64-poc/PLAN.md — the up-front plan, kept for the audit trail.

Test plan

  • bazel build //src/ray/gcs/store_client/tests:rocksdb_smoke_test — green, 8.3 MB binary
  • bazel test //src/ray/gcs/store_client/tests:rocksdb_smoke_test — 64 ms PASS
  • bazel test //src/ray/gcs/store_client/tests:rocksdb_store_client_test — 10/10 PASS (~7.4 s) covering Phase 3 baseline (4) + offload roundtrip + dtor (2) + strand correctness (4: !overwrite race with 128 issuer threads, LWW × 32 trials, Delete-Put × 64 trials, cross-key 1024 keys)
  • bazel test //rep-64-poc/harness/concurrency:concurrency_test --runs_per_test=10 — 40/40 PASS, no flake
  • bazel test //rep-64-poc/harness/store_client_parity:rocksdb_parity_test — StoreClientTestBase PASS
  • bazel build //:gcs_server with the new code path — 32 MB unstripped / 24 MB stripped, --help exits 0
  • Phase 4 kill-9 harness, ext4 + sync=1 — 0 acked-but-missing across 1k and 5k writes
  • Phase 4 ghost-writes negative control — exactly 50/50 acked-but-missing detected
  • Phase 7 microbench on probe-verified honest ext4 — sync put p50 3.81 ms, get p50 0.97 µs
  • Phase 7 addendum (offload): inline vs offload, sequential — 211.9 vs 213.5 ops/s (per-op latency identical within noise; ~40 µs offload dispatch overhead)
  • Phase 7 addendum (offload): inline vs offload, pipelined — 215.5 vs 535.2 ops/s (2.5× from group commit aggregating concurrent fsyncs)
  • Phase 7 addendum (strand): sequential — inline 214.6 vs offload 225.7 ops/s, p50 3.77 vs 3.64 ms (identical within noise; strand dispatch is sub-microsecond)
  • Phase 7 addendum (strand): pipelined — inline 240.0 vs offload 593.6 ops/s (still 2.5×; strand layer cost is zero measurable)
  • Phase 8 storage-layer recovery: 34 ms / 39 ms / 81 ms at 100 / 1k / 10k entries

Pending — collaborator-runnable (see rep-64-poc/COLLABORATORS.md for what to do, exact commands, and where to put results):

  • ASAN/TSAN runs of the four test targets (needs Clang ≥ 14 with sanitizer runtimes)
  • End-to-end actor-survival test (harness/integration/test_rocksdb_recovery.py) — needs a Ray container image built from this branch
  • K8s pod-delete recovery timing — needs the same image
  • Cloud-volume substrate sweep (EBS / GCE PD / Azure Disk) via cloud_fsync_check.sh
  • Different-filesystem fsync probe + microbench (xfs / btrfs / zfs / NFS)
  • arm64 sanity sweep
  • macOS build-only smoke (catches @boost / rules_foreign_cc regressions)
  • Pipelined throughput on a real NVMe with deeper queues — feeds Open Question 6
  • Docker Compose Redis-vs-RocksDB head-to-head harness
  • chaos_rocksdb_store_client_test.cc mirroring chaos_redis_store_client_test.cc

The POC stops short of running these because each requires hardware, cloud, or toolchain that the dev VM doesn't have. The reproducers and per-task instructions are shipped so collaborators can pick whichever matches their environment.

Open questions for maintainers

  1. REP perf-table revision. The 0.01–0.1 ms RocksDB-write number conflates memtable-only and sync-on-write paths. Phase 7 has the data; want me to send a small REP-revision PR alongside this?
  2. Boost URL fix scope. The @boost URL change (jfrog → archives.boost.io) is independent of REP-64 and would unblock every Ray master build today. Bundle here, or split into a separate small PR?
  3. Cluster-ID fail-fast deferral. The current code passes empty cluster_id to RocksDbStoreClient and skips the marker check (Phase 3 report). Is the K8s-downward-API plumbing path acceptable as the way forward, or is a different design preferred?
  4. PVC StorageClass guidance. The K8s manifest assumes RWO; multi-AZ recovery (pod re-scheduled to a different AZ) needs the StorageClass to allow re-attachment. Do you want guidance committed alongside the manifest, or treated as KubeRay-operator territory?
  5. Test-target naming / placement. The Phase 3 walking-skeleton tests live alongside the InMemory / Redis tests under //src/ray/gcs/store_client/tests:rocksdb_store_client_test. POC-specific tests sit under //rep-64-poc/harness/... to keep production trees minimal. Is the split right?
  6. Inline vs offload default. The PR ships gcs_rocksdb_async_offload = false (inline path) so behavior matches InMemoryStoreClient and the code is the simplest to reason about. But inline blocks the GCS event loop for the full 3.8 ms fsync per call, which is almost certainly unacceptable at any non-trivial write rate; offload returns the loop in ~40 µs and yields 2.5× pipelined throughput, with per-key strand bucketing now closing the ordering gap that the bare-pool offload had. Three live options: keep opt-in, flip default to offload, or remove the inline path entirely. Phase 7 addenda have the comparative numbers; this is a maintainer judgment call. Caveat: queue-fill backpressure under saturation is a real production concern that's not yet plumbed (the bench's pipelined p50 of 9 s is queue-wait, not fsync — would need congestion control before flipping default).
  7. Per-key strand approach. Single-key offload ops dispatch through RunIoForKey(table, key, work) → strand bucket of hash(table, key) % gcs_rocksdb_strand_buckets (default 64; ~16× headroom over default pool size of 4). The alternative is RocksDB's OptimisticTransactionDB, which only closes the !overwrite TOCTOU and leaves the other three same-key ordering manifestations (LWW, Delete-then-Put, read-your-writes) broken. POC_AUDIT.md has the full reasoning; multi-key/scan ops intentionally use the bare pool with looser semantics matching Redis pipelining and InMemoryStoreClient under concurrent callers. Confirm the strand approach is what you want, and sanity-check the bucket-count default.

Migration / risk

This branch does not change behavior for existing Redis-backed Ray clusters. RAY_GCS_STORAGE defaults to its current value; the new "rocksdb" value is opt-in. RAY_GCS_STORAGE_PATH defaults to empty and only matters when RAY_GCS_STORAGE=rocksdb. RAY_GCS_ROCKSDB_ASYNC_OFFLOAD defaults to false (inline path); flipping it on for production needs the backpressure follow-on noted in Open Question 6. RAY_GCS_ROCKSDB_STRAND_BUCKETS defaults to 64 and is only meaningful when offload is on; tuning is documented in POC_AUDIT.md.

The boost URL fix changes the upstream URL for the @boost archive. The pinned SHA256 is unchanged; the new URL serves the same archive content (verified manually with curl + sha256sum). Builds that previously failed will now succeed; no other change.

How to review

Reviewing only the core integration (C++ path)

If you only care about the RocksDB-backed StoreClient itself and not the POC dossier / harness /
reports, the change is a small, contained surface. The list below is everything you need to read and
the only commands you need to run.

Files to read (in this order, ~600 lines total of new C++):

  1. src/ray/gcs/store_client/rocksdb_store_client.{h,cc} — the implementation. All 9 StoreClient
    methods, mutex-RMW GetNextJobID, sync writes (WriteOptions::sync = true), inline vs.
    boost::asio::thread_pool offload paths, per-key boost::asio::strand bucketing on the offload path,
    destructor wait() (not stop()+join()).
  2. src/ray/gcs/gcs_server.{h,cc} — wires StorageType::ROCKSDB_PERSIST / kRocksDbStorage = "rocksdb"
    into InitKVManager; threads the three config knobs into the ctor.
  3. src/ray/common/ray_config_def.h — four new knobs: gcs_storage_path, gcs_rocksdb_async_offload
    (default false), gcs_rocksdb_io_pool_size (default 4), gcs_rocksdb_strand_buckets (default 64).
  4. bazel/BUILD.rocksdb (new) + bazel/ray_deps_setup.bzl — RocksDB pulled via rules_foreign_cc with all optional features OFF. The @boost URL change is an unrelated Ray-core build fix (see Open Question 2).
  5. src/ray/gcs/store_client/BUILD.bazel, src/ray/gcs/store_client/tests/BUILD.bazel,
    src/ray/gcs/BUILD.bazel — Bazel wiring; no logic.

Time-boxed:

  • 10 minutes — rep-64-poc/EVIDENCE.md, then skim rep-64-poc/RISKS.md.
  • 30 minutes — read each phase report's "Result" and "Skepticism" sections plus rep-64-poc/POC_AUDIT.md. Skip method bodies.
  • 1 hour — re-run the quick sanity sweep (4 bazel tests, ~10 minutes after first cold build), spot-check one or two repros from rep-64-poc/reproducers/README.md.
  • Half a day — re-run on your own substrate, especially Phase 7 microbench (different fsync class) and Phase 8 recovery_bench. Numbers should track ours within an order of magnitude on commodity-PV-class storage.

All numerical claims are reproducible from the bench harnesses; please run them rather than taking the numbers on faith.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements an embedded RocksDB storage backend for the Ray GCS as part of the REP-64 proof of concept, including Bazel build updates, the RocksDbStoreClient class, and various test harnesses. The review feedback highlights critical performance concerns regarding synchronous I/O operations blocking the main event loop and suggests offloading these tasks to a background thread pool. Other recommendations include using MultiGet in AsyncBatchDelete for efficiency, improving the robustness of job counter recovery, and reducing mutex contention during column family creation.

@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch 2 times, most recently from a193a06 to 58e33f7 Compare April 30, 2026 06:19
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from 455be22 to 065a6ad Compare April 30, 2026 17:49
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from b998ff4 to 4b70384 Compare May 1, 2026 01:14
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from 9407321 to 695a780 Compare May 1, 2026 17:12
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from f96f937 to 9c9b0e6 Compare May 1, 2026 20:20
jhasm and others added 8 commits May 1, 2026 21:40
…concept

Proof of concept for REP-64 (Embedded GCS Storage Backend). Not a
feature merge — the dossier under rep-64-poc/ is the load-bearing
artifact: per-claim verdicts, reproducible evidence, and a
production-hardening backlog.

Core code changes (the bits that would land in a real merge):

  bazel/BUILD.rocksdb (new)
    Drives RocksDB's CMake build via rules_foreign_cc, all optional
    features OFF, CMAKE_INSTALL_LIBDIR=lib for cross-distro portability.

  bazel/ray_deps_setup.bzl
    Adds @com_github_facebook_rocksdb (v9.11.2, SHA pinned, GitHub
    release tarball).

  src/ray/gcs/store_client/rocksdb_store_client.{h,cc} (new)
    Full StoreClient implementation. All 9 methods. Mutex-RMW
    GetNextJobID. Sync writes via WriteOptions::sync = true.
    Cluster-ID marker plumbing (skipped when cluster_id is empty —
    see Phase 3 report for the K8s deferral rationale).

  src/ray/gcs/gcs_server.{h,cc}
    Adds StorageType::ROCKSDB_PERSIST + kRocksDbStorage = "rocksdb",
    new init paths in both gcs_table_storage construction and
    InitKVManager. Passes empty cluster_id because Ray's GCS init
    order makes a real cluster_id unavailable at this point —
    fully written up in rep-64-poc/reports/phase-3-skeleton.md.

  src/ray/common/ray_config_def.h
    Adds RAY_CONFIG(std::string, gcs_storage_path, "") for the
    RAY_GCS_STORAGE_PATH env var.

  src/ray/gcs/BUILD.bazel + src/ray/gcs/store_client/BUILD.bazel
    Adds rocksdb_store_client cc_library and wires it into the
    gcs_server lib's deps.

  src/ray/gcs/store_client/tests/{rocksdb_smoke_test.cc,
                                    rocksdb_store_client_test.cc} (new)
    Phase 2 + Phase 3 walking-skeleton tests: cluster-ID marker,
    PutGet roundtrip, RecoverAcrossReopen, JobID monotonicity.

Verification on this VM (Bazel 7.5.0, GCC 11, ext4 on /dev/sda3):

  bazel build  //src/ray/gcs:gcs_server                     OK
  bazel test   //src/ray/gcs/store_client/tests:rocksdb_smoke_test         PASS
  bazel test   //src/ray/gcs/store_client/tests:rocksdb_store_client_test  PASS (4/4)
  bazel test   //rep-64-poc/harness/concurrency:concurrency_test           PASS (4/4)
  bazel test   //rep-64-poc/harness/store_client_parity:rocksdb_parity_test PASS (StoreClientTestBase)

Binary size impact: gcs_server grows from 23.8 MB → 38.4 MB unstripped
(16.5 MB → 26.9 MB stripped). Well under the PLAN's 50 MB pivot.

POC dossier (rep-64-poc/):
  EVIDENCE.md           single-page claim-to-evidence map (read first)
  README.md             orientation
  RISKS.md              live risk register, end-of-POC status per row
  PLAN.md               the up-front 9-phase plan
  reports/phase-N-*.md  9 phase reports: claim, method, result,
                        skepticism, repro, pivot decision
  harness/              every test / benchmark / reproducer the POC
                        produced (docker-compose, durability/kill9,
                        concurrency, microbench, recovery, kind, cloud)
  reproducers/README.md one-command repros for everything

Three findings highlighted up-front in EVIDENCE.md:

  1. The REP's "0.01-0.1 ms RocksDB write" claim is misleading. That's
     a memtable-only number; sync-on-write is fsync-bounded at
     3.81 ms p50 on probe-verified ext4. Reads remain 0.01-0.1 ms class
     as claimed.

  2. The cluster-ID-mismatch fail-fast story (REP "Stale data
     protection") cannot be implemented as drawn. Ray's GCS init order
     has InitKVManager() before GetOrGenerateClusterId(), and the
     persisted ID *is* the cluster ID — there's nothing to mismatch
     against. PVC-mismatch detection requires an external authoritative
     source (K8s downward API). Deferred to a follow-on PR with the
     deferral honestly documented.

  3. Binary size impact is well under the PLAN's 50 MB pivot trigger.
     +6.6 MB stripped on gcs_server.

Pending follow-ons (not blockers for the POC; documented in
EVIDENCE.md and per-phase reports):

  - Build a Ray container image from this branch to unblock the
    actor-survival end-to-end test, K8s pod-delete recovery timing,
    and full Redis-vs-RocksDB head-to-head.
  - TSAN / ASAN runs of the test targets on a Ray-CI-toolchain host.
  - Cloud-volume substrate sweep (EBS / GCE PD) via collaborator
    running cloud_fsync_check.sh.
  - drop_caches-equipped variants of Phase 4 / Phase 8 on a host
    with sudo.
  - Multi-threaded-writer microbench variant (Phase 7 v2) for
    group-commit aggregate-throughput benefit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…r counter parse

Two fixes to RocksDbStoreClient based on the automated review on PR ray-project#63032:

- AsyncBatchDelete: replace per-key Get with a single MultiGet so
  the existence probe runs in one I/O round instead of N. Mirrors
  the structure of AsyncMultiGet.
- Constructor counter recovery: parse with std::stoll plus an
  explicit int-range check so an overflowed-or-corrupt counter on
  disk produces a clear FATAL instead of an unrecoverable
  std::out_of_range. Catch std::exception (not bare ...) for clearer
  diagnostics. Drop the redundant job_id_mutex_ lock — the
  constructor runs before any other thread can observe `this`.

Verified locally:
  bazel test //src/ray/gcs/store_client/tests:rocksdb_store_client_test  PASS (0.9s)
  bazel test //rep-64-poc/harness/store_client_parity:rocksdb_parity_test  PASS (116.9s)
  bazel test //rep-64-poc/harness/concurrency:concurrency_test  PASS (172.1s)

Two other points from the same review (sync I/O on the GCS event
loop; cf_mutex_ contention during CreateColumnFamily) are
intentionally left as-is for the POC and discussed in the PR
review-comment replies.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
Two failing checks on PR ray-project#63032:

  buildkite/microcheck — lint phase failing on three sub-jobs:

    * clang_format: ~10 of the new POC C++ files (in
      rep-64-poc/harness/ and src/ray/gcs/store_client/) had
      formatting drift from the project's clang-format style.
      Reformat in place; no semantic changes.

    * copyright_format: rocksdb_smoke_test.cc was missing the
      Apache 2.0 copyright header that ci/lint/copyright-format.sh
      requires for *.cc / *.h under src/. Header added.

    * pre_commit: black + ruff caught a few items in the Python
      harness scripts:
        - probe_fsync.py: 3x lambda-assignments (E731) -> def
        - run_recovery.py: unused `populate` variable (F841)
        - bench.py / test_rocksdb_recovery.py: unused imports (F401)
        - black reformat across 4 harness scripts
      Plus end-of-file-fixer added trailing newlines to three
      result JSON files.

  docs/readthedocs.com:anyscale-ray — RTD build failing because
  intersphinx fetch of pytorch.org/docs/stable/objects.inv now 404s,
  and Sphinx is run with -W (warning-as-error). Cherry-pick the fix
  applied upstream in ray-project#63038 (commit beea531): repoint torch's
  intersphinx mapping to docs.pytorch.org/docs/2.7/objects.inv,
  which matches Ray's runtime torch pin.

Verified locally:
  ci/lint/copyright-format.sh -c                  PASS
  ci/lint/check-git-clang-format-output.sh        PASS
  pre-commit run --files <touched>                PASS  (pydoclint
    skipped — local Python is 3.9 but pydoclint needs 3.10+; CI
    runs it on a 3.10+ image)
  ruff / buildifier / black                       PASS

No production code logic changed. Diff is purely formatting +
copyright + the doc-conf intersphinx-URL fix.

Signed-off-by: Santosh Jha <[email protected]>
Addresses gemini-bot review comment id 3165761812 (high priority):
the inline path runs RocksDB ops (including the WAL fsync ~3.8 ms
on probe-verified ext4) on the GCS event loop, blocking other RPCs.

This change adds a *second* execution path, gated by a new config
flag, so maintainers can compare both modes empirically before
choosing one for production:

  * gcs_rocksdb_async_offload (bool, default false)
      false -> current behaviour: each Async* runs inline, callback
               posts to io_service. Easiest to reason about; matches
               InMemoryStoreClient.
      true  -> RocksDB work posts to a boost::asio::thread_pool;
               callback still posts to io_service. RocksDB's group
               commit aggregates concurrent writers into one fsync,
               so aggregate write throughput scales with pool size.

  * gcs_rocksdb_io_pool_size (uint32, default 4)
      Worker count for the offload pool. Ignored when offload is off.
      Clamped to >= 1 if a misconfigured 0 ever reaches us.

Implementation:

  * RocksDbStoreClient ctor takes new offload_io + io_pool_size
    args (defaulted so existing tests are source-compatible).
  * Single private RunIo(work) helper centralises the dispatch
    branch — every AsyncXxx wraps its body in RunIo so the
    inline/offloaded fork lives in exactly one place.
  * Destructor explicitly stops+joins the pool BEFORE walking the
    cf-handle map, so an in-flight pool task can't dereference a
    destroyed handle.
  * gcs_server.cc passes the two config values through at both
    construction sites.
  * Tests:
      OffloadPathRoundtripsAcrossPoolThreads — 64 Puts then 64
        Gets through a 4-thread pool, all values verified.
      OffloadPathDestructorJoinsBeforeDbClose — 16 Puts via pool,
        immediate dtor, reopen + read confirms durability and
        proves the join completes (would deadlock otherwise).
  * BUILD: rocksdb_store_client now deps on @boost//:asio.

Phase 7 microbench updates and PR-comment reply with side-by-side
numbers come in follow-up commits.

Verified locally:
  bazel test //src/ray/gcs/store_client/tests:rocksdb_store_client_test
    -> 6/6 PASS in 1.1 s (4 original + 2 new offload tests)
  bazel test //rep-64-poc/harness/store_client_parity:rocksdb_parity_test
    -> StoreClientTestBase PASS in 113 s (inline path unchanged)
  bazel test //rep-64-poc/harness/concurrency:concurrency_test
    -> 4/4 PASS in 147 s (inline path unchanged)
  bazel build //src/ray/gcs/store_client:rocksdb_store_client
    -> compiles clean, no warnings

Signed-off-by: Santosh Jha <[email protected]>
Extends the microbench with --include-offload, --io-pool-size, and
--sequential flags so the two execution paths added in e710272d can
be measured side-by-side. Per-op timing now captures end-to-end
(issue -> callback) latency rather than issue-only, which is the only
fair comparison for the offload path (issue-only timing makes it
look ~5000x faster than it really is — that's just enqueue cost).

Two regimes, because they answer different questions:

  Sequential (--sequential, one in-flight at a time):
    rocksdb_inline   211.9 ops/s, p50 3.78 ms
    rocksdb_offload  213.5 ops/s, p50 3.82 ms
  -> Per-op latency identical within noise. Offload adds ~40 us
     dispatch overhead, dwarfed by the 3.8 ms fsync.

  Pipelined (default, issuer fires back-to-back):
    rocksdb_inline   215.5 ops/s
    rocksdb_offload  535.2 ops/s   (2.5x throughput)
  -> Group commit aggregates concurrent fsyncs once there are
     multiple in-flight writers.

Phase 7 report (reports/phase-7-microbench.md) gains a section
"Inline vs offload-IO path" with both tables and the maintainer-
decision framing the gemini comment asks for. JSON files for both
runs land under results/ for reproducibility.

The pipelined-mode p50 of 9.2 s in the offload row is a queue-
saturation artifact (issuer >> drain rate), not a per-op cost;
explicitly called out in the report so a reader doesn't misread it
as a regression.

Followups (will address in a separate commit):
- multi-threaded-writer mode (Phase 7 v2) so we can measure the
  group-commit benefit without the queue-saturation artifact
- bounded-inflight throttle so pipelined mode reports honest tail
  latency

Verified locally:
  bazel build -c opt //rep-64-poc/harness/microbench:storage_microbench
    -> compiles clean
  ./storage_microbench --include-offload --sequential
    -> see numbers above (reproducible)

Signed-off-by: Santosh Jha <[email protected]>
Three small lint fixes after rebasing onto upstream/master (this is
what was failing in microcheck build 44632):

  clang-format (line-break before-vs-after `<<` differs):
    src/ray/gcs/store_client/rocksdb_store_client.cc
    rep-64-poc/harness/microbench/storage_microbench.cc

  buildifier (trailing comma + visibility-attribute order):
    bazel/ray_deps_setup.bzl
    rep-64-poc/harness/durability/kill9/BUILD.bazel

No semantic changes. Verified locally:
  ci/lint/git-clang-format --commit upstream/master --diff -> clean
  buildifier --mode=check on changed files -> clean
  python3 -m black --check (22.10.0, the pinned version) -> clean
  python3 -m ruff check -> clean

Signed-off-by: Santosh Jha <[email protected]>
Pre-commit clang-format (microcheck build 44683 step
"pre_commit") flagged the AsyncGet call in
OffloadPathRoundtripsAcrossPoolThreads. Local
ci/lint/check-git-clang-format-output.sh missed it because that
script only diffs against the parent commit; pre-commit runs on
all files. This commit applies the exact diff suggested by the
CI's clang-format hook.

Verified locally:
  pre-commit run clang-format --all-files -> Passed

Signed-off-by: Santosh Jha <[email protected]>
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from ace576f to 60ba26d Compare May 1, 2026 21:41
@jhasm
jhasm marked this pull request as ready for review May 2, 2026 01:26
@jhasm
jhasm requested a review from a team as a code owner May 2, 2026 01:26
@ray-gardener ray-gardener Bot added the docs An issue or change related to documentation label May 2, 2026
jhasm and others added 16 commits May 13, 2026 18:03
Runs every test script in sequence and aggregates results.  Designed so
test failures DO NOT abort the run — the harness exists to surface
findings, so collecting partial signal is more useful than fail-fast.
Infrastructure failures (00-setup, 10-deploy) DO abort, since downstream
tests cannot run without a ready cluster.

Usage:
  run-all.sh [--tier=k3d|remote] [--skip-setup] [--teardown]

Tier selects env file (env/k3d.env or env/remote.env, default k3d).
--skip-setup is for re-runs against an already-deployed cluster.
--teardown calls 99-teardown.sh at the end (k3d-only — refuses on
remote tier where cluster bring-down is the operator's responsibility).

Per-step outcomes (ok / fail / skipped) print at the end so the operator
can see at a glance which steps ran and which need attention.  Exit
status is 1 if any step failed, 0 otherwise — so CI can gate on it
without parsing the markdown.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…knobs

Pragmatic README for collaborators who want to reproduce the rep-64
durability tests.  Pairs with the deeper DESIGN.md and IMPLEMENTATION.md
which already exist; this is the start-here doc.

Sections:
- Quickstart (k3d in 4 commands)
- Tier model (k3d implemented, remote planned)
- Why k3d not kind (Mariner cgroup-v1 incompatibility)
- Scripts catalog with one-line purposes
- How to read summary.md (Tests + Findings, with thresholds table)
- Image story (the :nightly-rep64-fix patched build, ghcr public mirror)
- Known issues:
  * cwd path footgun (RESULTS_DIR is relative)
  * Open finding: rocksdb 0–50% recovery (non-deterministic durability)
  * Substrate sweep skipped on k3d (only local-path available)
- Customization (env knobs table)
- Reproducing on a new cluster (sketches the planned Phase E flow)

Honest about what's NOT yet built — calls out 00-check-remote.sh and
env/remote.env.example as planned-not-done so external readers don't
look for files that aren't there.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…bugs

Found while running run-all end-to-end for the canonical baseline.

Two bugs fell out:

1. 30-pod-delete.sh's "restore rocksdb cluster" step at the end of the
   inmem-baseline path applied the rocksdb manifest but didn't tear down
   the existing memory cluster first.  KubeRay reconciles the spec but
   does NOT recreate head pods on PodTemplate changes — so the running
   pod stayed on memory backend, which 10-deploy-cluster.sh correctly
   refuses to use on the next run.  Fix: call teardown_cluster before
   re-applying so KubeRay gets a fresh shot at materializing the spec.

2. run-all.sh's run_step() captured `$?` after `if "$@"; then ... fi`,
   which in bash returns the if-statement's exit (0 when the test fell
   through), not the failed command's actual rc.  Symptom: log line said
   "FAILED (rc=0)" which is nonsense and would confuse anyone tailing.
   Fix: capture rc directly via `"$@" || rc=$?`.

The run-all orchestrator's overall behavior was correct — required-step
abort propagated and exited cleanly.  Only the cosmetic rc display was
broken, but worth fixing for log readability.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
Found while running the canonical baseline.  Aggregate step at the end of
run-all references \$RESULTS_DIR but the orchestrator never sourced the
env file — the individual test scripts each call load_env themselves, so
none of those env vars were in run-all's own shell.  Symptom:

  ./run-all.sh: line 114: RESULTS_DIR: unbound variable

Fix: call load_env() right after sourcing lib.sh.  Also sets the kubectl
context once up front rather than relying on each test script to do it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…ds run independently

When the rocksdb backend run hit the 300s pod_restart timeout, abort()
exited the script before the inmem baseline ran — the two paths were
sequential rather than independent.  Worse, the failed rocksdb run wrote
no result JSON, so aggregate.py couldn't even surface the failure: the
test silently disappeared from summary.md.

Two pieces:

1. run_backend_with_fallback wraps run_backend in a subshell, so an
   abort inside (head pod won't ready, no SNAPSHOT_JSON, etc.) only
   exits the subshell.  When that happens, write a fail-stub result
   with status=fail + aborted=true so aggregate.py has a row to hang
   the failure off of.

2. Both backends now invoked via `... || true` so failure of either
   doesn't block the other.  The post-baseline rocksdb-restore step's
   abort-on-failure also relaxed to a WARN: leaving the cluster in a
   broken state is operator-noise, not script-fatal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
Captured by run-all.sh against the rep64 k3d cluster on commit cbea070f.
Each *.committed.json is the latest result from that test in
results/k3d/, copied (gitignore policy already keeps results/canonical/
committed and results/k3d/* local-only).

Headline outcomes:

| test                | status  | what it surfaces                             |
|---------------------|---------|----------------------------------------------|
| 20-actor-survival   | pass    | 10/10 detached actors survive disconnect     |
| 30-pod-delete       | fail    | rocksdb: pod_restart 138 s, state 40 %       |
| 30-pod-delete.inmem | fail    | memory baseline: pod_restart 10 s, state 0 % |
| 40-substrate-sweep  | skipped | SUBSTRATE_SWEEP_CLASSES empty on k3d         |
| 50-fast-storage     | skipped | FAST_NVME_CLASS empty on k3d                 |

Three findings surface in summary.md (rocksdb pod_restart > 30 s,
rocksdb state_preserved < 95 %, memory state_preserved < 95 %).

Open POC bugs visible in this baseline (deferred per the
"build harness, find bugs, fix later" directive):

1. rocksdb state_preserved_pct is non-deterministic across runs
   (0%, 40%, 50% observed in this session).  Actor manager writes are
   not durably committed before pod kill — the 2 s flush sleep at
   pod_delete_workload.py:65-66 is insufficient.

2. rocksdb head-pod cold-start exceeds the readiness/liveness probe
   window.  On a cold cluster (fresh PVC + first head-pod restart),
   Ray takes 138 s to bring up GCS+raylet; the kubelet liveness probe
   kills the container before Ray finishes, triggering a CrashLoop.
   Eventual recovery happens via repeated container restarts within
   the 300 s harness timeout.  On a warm cluster the same path takes
   ~10 s, so the bug only manifests for the first restart of a fresh
   deployment — but that's exactly the production-relevant case.

These are the canonical "current state" baseline.  Update this baseline
once either bug is fixed (re-run run-all, copy fresh JSONs over).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…cold-start finding

Two README updates after capturing the canonical baseline:

1. Document the second open finding: rocksdb head-pod cold-start
   exceeds the kubelet liveness probe window.  Symptom: CrashLoop on
   the first restart of a fresh deployment; ~138 s observed.  On warm
   clusters the same path is ~10 s, so the bug only shows on the
   production-relevant first-restart case.

2. Add a "Canonical baseline" section pointing readers at
   results/canonical/ as the committed reference snapshot, with
   instructions to refresh by running run-all and copying the latest
   results over.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…g artifacts)

These were how-we-planned-the-work documents from earlier in the POC's
build-out and aren't needed alongside the shipped harness.  The README
already covers what a consumer needs: how to run the harness and what
to expect from the results.  Anyone curious about the design trail can
read the git history of the harness files.

Also removes the references to these files that lived in:
- README.md (intro paragraph + the "Why k3d, not kind" diagnostic note)
- env/k3d.env (the cgroup-pivot comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: Santosh Jha <[email protected]>
…y" finding

The 30-pod-delete recovery test was reporting non-deterministic
0-50% recovery on rocksdb (observed 0%, 40%, 50%, 70% across runs)
and the canonical baseline attributed this to async-write durability
gaps masked by an insufficient 2s flush sleep. That attribution was
wrong.

Code-path trace + substrate-fsync probe (verdict=honest, p50=4015 us
on /data/gcs) + post-kill `ray list actors` showed the actual cause:
Ray's head pod runs a worker process by default, so any actors K8s
scheduled onto the head pod's worker died with the pod when SIGKILL
hit. The variance was just K8s scheduling roulette: which fraction
of the 10 actors happened to land on the head pod's worker that run.

Fix: HEAD_RAY_CPU=0 in env files, plumbed into the manifest's
headGroupSpec.rayStartParams.num-cpus. The head's raylet advertises
0 CPUs to the Ray scheduler, so user actors only land on worker
pods. The K8s container request/limit stays at HEAD_CPU (the head
still needs real CPU for gcs_server + raylet).

The 2s sleep at pod_delete_workload.py:65-66 and the 3s sleep at
30-pod-delete.sh:74 are removed. Both were based on the now-disproven
async-write hypothesis. AsyncPut runs db_->Put with wo.sync=true so
every write fsyncs the WAL before its callback fires; the chain
RegisterActor -> ALIVE Put -> gcs_publisher.PublishActor -> driver
ConnectActor -> SubmitTask dispatch enforces durability before
ray.get() returns from the actor's first method call.

After the fix, 30-pod-delete reports 100% recovery on rocksdb across
runs; inmem baseline still correctly reports 0%. Canonical baseline
files refreshed; the only remaining finding is the inmem 0% (the
expected contrast against rocksdb's 100% — exactly the point of
running both backends).

README "Open finding 1" rewritten to document the correct
attribution and the fix. The cold-start liveness-probe issue
("Open finding 2") is independent and unaffected.

Signed-off-by: Santosh Jha <[email protected]>
Adds two sections users were asking for:

- "Cleaning up" — soft reset (kubectl delete raycluster + pvc), full
  teardown via 99-teardown.sh or run-all.sh --teardown, and the manual
  k3d cluster delete fallback. Notes 99-teardown.sh's per-tier branch.

- "Switching between tiers" — HARNESS_ENV_FILE selects the profile,
  and lib.sh::load_env auto-flips kubectl context as a side effect
  (the gotcha worth flagging). Includes the workable path against a
  remote cluster today, before the Phase E scripts land.

Signed-off-by: Santosh Jha <[email protected]>
Concrete remote env files contain cluster-specific URLs and namespaces.
Keep them local; the .example template is the committed shape.

Signed-off-by: Santosh Jha <[email protected]>
Mirror env/k3d.env's shape so the remote env diff tells contributors what
to change. Defaults differ from k3d where remote semantics demand it:
IMAGE_PULL_POLICY=IfNotPresent (not Never), STORAGE_CLASS empty (the
preflight rejects empty so we never silently pick the cluster default),
BASELINE_INMEM=0 (k3d canonical baseline already has the contrast),
RESULTS_DIR points at results/remote/.

Signed-off-by: Santosh Jha <[email protected]>
Verifies kubectl reach, namespace existence, RBAC the harness needs
({get,create,delete} of rayclusters/PVCs/configmaps/jobs.batch, plus
{get,delete} pods, create pods/exec, get pods/log), KubeRay CRDs, and
the configured StorageClass(es). The KubeRay-operator-cluster-wide
check is downgraded to optional since most managed-cluster SAs lack
list-deploy-cluster-wide perms — CRDs presence is the load-bearing
signal there. check() surfaces stderr on required failure to make
RBAC denials self-debuggable. Never mutates cluster state.

Required failures abort with rc=1; optional substrate-sweep / fast-NVMe
classes warn-only when missing. Wired into run-all.sh in a follow-up.

Signed-off-by: Santosh Jha <[email protected]>
…e tier

Replaces the previous skip_step stub with a required run_step. Mirrors
the k3d setup branch — failed preflight aborts the run before deploy/
tests, since downstream scripts assume the cluster is reachable and
properly configured.

Signed-off-by: Santosh Jha <[email protected]>
Drops "(planned)" qualifiers from the tier table and the reproducing-
on-a-different-cluster section. Replaces the old Phase-E placeholder
with the actual workflow (cp .example, edit, run-all --tier=remote).
Adds an "Image registry & pull secrets" subsection covering the
namespace default-ServiceAccount workaround for private registries.

Signed-off-by: Santosh Jha <[email protected]>
Both 00-check-remote.sh and lib.sh::write_result used
app.kubernetes.io/component=kuberay-operator to find the operator
Deployment. The KubeRay v1.6.0 Helm chart doesn't apply
component=kuberay-operator; it uses name=kuberay-operator. Result:
the optional operator-presence check always emitted a warning, and
every result JSON's cluster.kuberay_operator_version was "unknown"
even on clusters that did have the operator installed.

Surface: discovered while smoke-testing 00-check-remote.sh against
the running k3d cluster, which has the operator but reported the
optional warning anyway. Fix is one selector swap, applied in both
places where the same selector was used.

Signed-off-by: Santosh Jha <[email protected]>
@jhasm
jhasm force-pushed the jhasm/rep-64-poc-1 branch from 8a1c766 to 2b8d881 Compare May 13, 2026 18:03
…ksDB GCS

Cursor Bugbot flagged that the previous unconditional default of 60s
(raised from upstream's 30s) doubles the startup-failure surfacing time
for ALL Ray deployments, not just RocksDB-backed ones. The justification
(GCS replaying state from the persisted store on cold-start) only applies
when RAY_gcs_storage=rocksdb, so gate the higher default on the backend
and leave the upstream 30s default in place for everyone else. The
RAY_raylet_start_wait_time_s env knob still overrides both.

Signed-off-by: Santosh Jha <[email protected]>
jhasm added a commit to jhasm/ray-enhancements that referenced this pull request May 13, 2026
… REP

POC-driven corrections (from ray-project/ray#63032):
- Performance table: replace memtable-only 0.01-0.1 ms write number with
  fsync-bounded 3-5 ms (POC ext4: 3.81 ms p50); add non-durable row; add
  Redis appendfsync-always note so the comparison is apples-to-apples.
- New "Concurrency and Ordering Semantics" section documenting the
  thread-pool offload path, per-key boost::asio::strand bucketing for
  ordering preservation, opt-in default pending backpressure design,
  and measured 2.5x pipelined throughput.
- Three new env vars in the user-configurable table:
  RAY_GCS_ROCKSDB_ASYNC_OFFLOAD, RAY_GCS_ROCKSDB_IO_POOL_SIZE,
  RAY_GCS_ROCKSDB_STRAND_BUCKETS.
- New "Binary Size Impact" section with POC-measured deltas across
  gcs_server, ray wheel, and Docker image.
- Rewrite stale-data-protection bullet honestly: naive cluster-ID
  marker is unimplementable as drawn (InitKVManager runs before
  GetOrGenerateClusterId); propose operator-injected RAY_CLUSTER_ID
  via K8s downward API as the production design.

Reviewer feedback (from PR ray-project#64):
- Rewrite training-resilience paragraph to state plainly that this REP
  alone does not improve in-flight training resilience -- NCCL still
  breaks, driver still restarts, app still resumes from last checkpoint.
  Frame the win as faster cluster recovery + foundation for detached
  jobs / checkpointable drivers (per @andrewsykim, @edoakes).
- Add RayService caveat to PVC Lifecycle: ownerReferences must point
  to RayService not RayCluster so zero-downtime upgrades don't
  garbage-collect the GCS PVC (per @andrewsykim).
- Clarify "What the Operator Does" that env-var injection on the head
  pod happens regardless of operator-managed vs existingClaim path
  (per @andrewsykim).

Signed-off-by: Santosh Jha <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 10, 2026
@rueian rueian self-assigned this Jun 23, 2026
@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jun 24, 2026
@jhasm

jhasm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Commenting to keep this pr from closing

edoakes added a commit that referenced this pull request Jul 11, 2026
…nce (REP-64) (#63657)

Implements the embedded RocksDB storage backend for GCS fault tolerance
proposed in
[REP-64](ray-project/enhancements#64).

Today, GCS fault tolerance requires an external Redis instance. This PR
adds RocksDB as a second backend, selected via `RAY_gcs_storage=rocksdb`
and `RAY_gcs_storage_path=<path-on-pvc>`. The recovery model is
identical to Redis-backed FT — GCS restarts, reads state from local
disk, workers reconnect — only the location of persisted state differs.

KubeRay operator changes (the `gcsFaultToleranceOptions.backend:
rocksdb` field that auto-manages PVCs) are explicitly out of scope here
and will land in `ray-project/kuberay`.

## Why a new PR

This is a streamlined version of the POC at #63032. That PR carries the
full evidence dossier (phase reports, kill-9 harness, k8s test harness,
microbench results — ~10K lines of supporting material) which served its
purpose during design review. For the merge PR, only the production code
is included; #63032 remains the reference for per-claim reproducibility
evidence and the @andrewsykim review thread.

## What's in this PR

| Commit | What |
|---|---|
| 1 | `bazel/rocksdb.BUILD` + `bazel/ray_deps_setup.bzl` — add RocksDB
9.11.2 as a third-party dependency (static-only, no compression /
jemalloc / tools, built via `rules_foreign_cc`). |
| 2 | `src/ray/gcs/store_client/rocksdb_store_client.{h,cc}` + 4 tests +
`storage_microbench` binary. RocksDB I/O runs on a
`boost::asio::thread_pool` (keeping the WAL fsync off the GCS event
loop) with per-key `boost::asio::strand`s bucketed by `hash(table, key)`
for submission-order ordering. `WriteOptions::sync = true` on every
mutating call. |
| 3 | Wire it into `GcsServer` (factory dispatch in
`InitClusterStorageBackend` + `InitKVManager`, 3 new config flags,
`node.py` session-name sidecar for restart recovery, raylet startup wait
bumped 30 → 60s on rocksdb). |
| 4 | `TEST_GCS_ROCKSDB=1` fixture toggle in
`python/ray/tests/conftest.py` — existing cluster fixtures
auto-dispatch. |
| 5 | New postmerge buildkite jobs `:ray: core: rocksdb tests` + `:ray:
core: out of disk rocksdb tests`, mirroring the Redis FT jobs. |
| 6 | Docs: new K8s setup page (`kuberay-gcs-rocksdb-ft.md`) + an
"Embedded RocksDB backend" section in `gcs.rst`. |
| 7 | Review follow-ups: remove the inline execution path and the
`gcs_rocksdb_async_offload` toggle so RocksDB I/O always offloads; make
`GetNextJobIDSync` private (tests drive it through the public
`AsyncGetNextJobID`); extract the rocksdb session-name marker logic in
`node.py` into its own helper; collapse `storage_microbench` to a single
`rocksdb` backend; make the soft-durable table set a hardcoded,
documented constant (`SoftDurableTables()`) instead of the
`gcs_rocksdb_soft_durability_tables` config flag, since it's a fixed
design property rather than an operator knob. |

Aggregate: **+2,973 / -20 across 26 files**. All commits signed off
(DCO).

## REP-64 acceptance criteria

1. Release tests pass with `RAY_gcs_storage=rocksdb` — the new postmerge
job runs the standard test suite under the rocksdb backend.
2. New postmerge CI job mirroring Redis GCS FT — ✓ commit 5.
3. Scale tests at parity with Redis — covered by the postmerge job's
`//python/ray/tests/...` target set (includes `test_many_actors.py`).
4. Serve chaos passes — covered by the postmerge job.

## Tests

C++ unit tests under `src/ray/gcs/store_client/tests/`:
- `rocksdb_smoke_test` — Bazel-integration sanity (open / put / get).
- `rocksdb_store_client_test` — RocksDb-specific scenarios: recovery
across close+reopen, cluster-id marker fail-fast, pool-thread write
roundtrip.
- `rocksdb_parity_test` — runs the full `StoreClientTestBase` suite
(same fixture as `in_memory_store_client_test` and
`redis_store_client_test`).
- `rocksdb_concurrency_test` — per-key strand correctness +
JobID-counter atomicity under N-thread contention.

Python integration coverage: the existing `//python/ray/tests/...` /
`//python/ray/dag/...` / `//python/ray/autoscaler/v2/...` suites run
under `TEST_GCS_ROCKSDB=1` via the new buildkite jobs.

> The local k3d cluster recovery test harness from the POC branch was
repeated on this branch. Results and reproduction instructions are in
doc [REP-64 RocksDB GCS — Kubernetes Recovery: Evidence of Correctness &
Reproduction
Guide](https://docs.google.com/document/d/1sd6S1E5-kgOSbMjefjIkvkZztwsMeUikscOqbZHmUSA/edit?usp=sharing)

## Out of scope (follow-ons)

- KubeRay operator support for `gcsFaultToleranceOptions.backend:
rocksdb` — separate `ray-project/kuberay` PR.
- PVC stale-data fail-fast via K8s downward API (`RAY_CLUSTER_ID`
env-injected cluster-id marker) — `RocksDbStoreClient` already supports
the check; needs the KubeRay-side plumbing.
- Remove the soft-durability workaround. The soft-durability relaxation
added here (skipping the per-write WAL fsync on the NODE/ACTOR
death-notification tables, now a hardcoded `SoftDurableTables()`
constant) works around a GCS-core object-reconstruction /
task-resubmission race that RocksDB's fsync latency widens. That race
was proven to be rooted in the GCS code (see #64187). A follow-on PR
will fix the root cause in GCS and remove this workaround so every table
keeps strict per-write fsync.
- macOS / Windows support (targets currently gated on
`@platforms//os:linux`).

## References

- REP-64: ray-project/enhancements#64
- POC PR with full evidence dossier and design-review history: #63032
- Bug provenance: #64187

---------

Signed-off-by: Santosh Jha <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Rueian <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Edward Oakes <[email protected]>
@rueian

rueian commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The production-ready version of this has been merged.

@rueian rueian closed this Jul 28, 2026
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…nce (REP-64) (ray-project#63657)

Implements the embedded RocksDB storage backend for GCS fault tolerance
proposed in
[REP-64](ray-project/enhancements#64).

Today, GCS fault tolerance requires an external Redis instance. This PR
adds RocksDB as a second backend, selected via `RAY_gcs_storage=rocksdb`
and `RAY_gcs_storage_path=<path-on-pvc>`. The recovery model is
identical to Redis-backed FT — GCS restarts, reads state from local
disk, workers reconnect — only the location of persisted state differs.

KubeRay operator changes (the `gcsFaultToleranceOptions.backend:
rocksdb` field that auto-manages PVCs) are explicitly out of scope here
and will land in `ray-project/kuberay`.

## Why a new PR

This is a streamlined version of the POC at ray-project#63032. That PR carries the
full evidence dossier (phase reports, kill-9 harness, k8s test harness,
microbench results — ~10K lines of supporting material) which served its
purpose during design review. For the merge PR, only the production code
is included; ray-project#63032 remains the reference for per-claim reproducibility
evidence and the @andrewsykim review thread.

## What's in this PR

| Commit | What |
|---|---|
| 1 | `bazel/rocksdb.BUILD` + `bazel/ray_deps_setup.bzl` — add RocksDB
9.11.2 as a third-party dependency (static-only, no compression /
jemalloc / tools, built via `rules_foreign_cc`). |
| 2 | `src/ray/gcs/store_client/rocksdb_store_client.{h,cc}` + 4 tests +
`storage_microbench` binary. RocksDB I/O runs on a
`boost::asio::thread_pool` (keeping the WAL fsync off the GCS event
loop) with per-key `boost::asio::strand`s bucketed by `hash(table, key)`
for submission-order ordering. `WriteOptions::sync = true` on every
mutating call. |
| 3 | Wire it into `GcsServer` (factory dispatch in
`InitClusterStorageBackend` + `InitKVManager`, 3 new config flags,
`node.py` session-name sidecar for restart recovery, raylet startup wait
bumped 30 → 60s on rocksdb). |
| 4 | `TEST_GCS_ROCKSDB=1` fixture toggle in
`python/ray/tests/conftest.py` — existing cluster fixtures
auto-dispatch. |
| 5 | New postmerge buildkite jobs `:ray: core: rocksdb tests` + `:ray:
core: out of disk rocksdb tests`, mirroring the Redis FT jobs. |
| 6 | Docs: new K8s setup page (`kuberay-gcs-rocksdb-ft.md`) + an
"Embedded RocksDB backend" section in `gcs.rst`. |
| 7 | Review follow-ups: remove the inline execution path and the
`gcs_rocksdb_async_offload` toggle so RocksDB I/O always offloads; make
`GetNextJobIDSync` private (tests drive it through the public
`AsyncGetNextJobID`); extract the rocksdb session-name marker logic in
`node.py` into its own helper; collapse `storage_microbench` to a single
`rocksdb` backend; make the soft-durable table set a hardcoded,
documented constant (`SoftDurableTables()`) instead of the
`gcs_rocksdb_soft_durability_tables` config flag, since it's a fixed
design property rather than an operator knob. |

Aggregate: **+2,973 / -20 across 26 files**. All commits signed off
(DCO).

## REP-64 acceptance criteria

1. Release tests pass with `RAY_gcs_storage=rocksdb` — the new postmerge
job runs the standard test suite under the rocksdb backend.
2. New postmerge CI job mirroring Redis GCS FT — ✓ commit 5.
3. Scale tests at parity with Redis — covered by the postmerge job's
`//python/ray/tests/...` target set (includes `test_many_actors.py`).
4. Serve chaos passes — covered by the postmerge job.

## Tests

C++ unit tests under `src/ray/gcs/store_client/tests/`:
- `rocksdb_smoke_test` — Bazel-integration sanity (open / put / get).
- `rocksdb_store_client_test` — RocksDb-specific scenarios: recovery
across close+reopen, cluster-id marker fail-fast, pool-thread write
roundtrip.
- `rocksdb_parity_test` — runs the full `StoreClientTestBase` suite
(same fixture as `in_memory_store_client_test` and
`redis_store_client_test`).
- `rocksdb_concurrency_test` — per-key strand correctness +
JobID-counter atomicity under N-thread contention.

Python integration coverage: the existing `//python/ray/tests/...` /
`//python/ray/dag/...` / `//python/ray/autoscaler/v2/...` suites run
under `TEST_GCS_ROCKSDB=1` via the new buildkite jobs.

> The local k3d cluster recovery test harness from the POC branch was
repeated on this branch. Results and reproduction instructions are in
doc [REP-64 RocksDB GCS — Kubernetes Recovery: Evidence of Correctness &
Reproduction
Guide](https://docs.google.com/document/d/1sd6S1E5-kgOSbMjefjIkvkZztwsMeUikscOqbZHmUSA/edit?usp=sharing)

## Out of scope (follow-ons)

- KubeRay operator support for `gcsFaultToleranceOptions.backend:
rocksdb` — separate `ray-project/kuberay` PR.
- PVC stale-data fail-fast via K8s downward API (`RAY_CLUSTER_ID`
env-injected cluster-id marker) — `RocksDbStoreClient` already supports
the check; needs the KubeRay-side plumbing.
- Remove the soft-durability workaround. The soft-durability relaxation
added here (skipping the per-write WAL fsync on the NODE/ACTOR
death-notification tables, now a hardcoded `SoftDurableTables()`
constant) works around a GCS-core object-reconstruction /
task-resubmission race that RocksDB's fsync latency widens. That race
was proven to be rooted in the GCS code (see ray-project#64187). A follow-on PR
will fix the root cause in GCS and remove this workaround so every table
keeps strict per-write fsync.
- macOS / Windows support (targets currently gated on
`@platforms//os:linux`).

## References

- REP-64: ray-project/enhancements#64
- POC PR with full evidence dossier and design-review history: ray-project#63032
- Bug provenance: ray-project#64187

---------

Signed-off-by: Santosh Jha <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Rueian <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Edward Oakes <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core docs An issue or change related to documentation unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants