Add TdsKVBackend storage driver and wire TDS backend into KVCacheManagerBase and KVCacheStore. - #948
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
copybara-service
Bot
force-pushed
the
test_983561034
branch
2 times, most recently
from
September 22, 2026 18:26
0d5aa8a to
1f26b1e
Compare
copybara-service
Bot
force-pushed
the
test_983561034
branch
3 times, most recently
from
September 23, 2026 20:03
5bc6bcc to
77da526
Compare
…gerBase and KVCacheStore. Standard buffered POSIX file I/O copies KV cache blocks through the Linux kernel page cache, incurring CPU `memcpy` overhead and host RAM page-cache bloat on high-throughput storage tiers such as Lustre, NFS, and NVMe SSDs. Implement `tpu_raiden::kv_cache::backends::storage::TdsKVBackend` (`tkv::backends::storage::TdsKVBackend`) inheriting from `KVBackend`, and wire `"tds"` backend creation and Host DRAM pool buffer registration (`RegisterBuffer`) into `KVCacheManagerBase` and `KVCacheStore`. All registration and data movement is delegated to `libtdsul` rather than to a hand-rolled I/O engine. Host buffers are registered with `tds_buffer_register_vaddr` / `tds_buffer_register_dmabuf` using `TDS_MEM_HOST`, the target file is registered with `tds_storage_handle_register` through an `fd://<fd>` URI, and transfers are issued via `tds_read` / `tds_write` / `tds_readv` / `tds_writev`. `TdsKVBackend` opens the storage file with `O_DIRECT` and hands that descriptor to `libtdsul`. Because `O_DIRECT` is a property of the open file description, the underlying `pread` / `pwrite` inherit it and bypass the kernel page cache. For 4KB-aligned, registered slices this is a zero-bounce transfer (`direct_ops`). Unaligned buffer addresses, slice lengths, or file offsets are staged through a 4KB-aligned bounce buffer owned by `TdsKVBackend` (`bounced_ops`), which performs a read-modify-write to preserve surrounding bytes and an `ftruncate` to preserve exact logical file sizes. Per `go/tdsul-api`, bounce staging belongs in the framework adapter and never inside `libtdsul`. A separate `o_direct_ops` counter measures whether the page-cache bypass was actually retained, because both the open path and the I/O path can silently fall back to buffered mode. Vendor `libtdsul` under `third_party/tpu_raiden/tpu_sync/tpudirect_storage/` so that non-experimental `tpu_raiden` targets do not depend on an `//experimental/...` package. This copy is an interim measure; see the TODO in its BUILD file. It also carries three fixes to `ThreadPoolConductor` that upstream does not have: worker CPU affinity is applied only when an explicit core range is configured, `pthread_create` failures retry unpinned instead of leaving a silently dead worker, and `Stop()` drains the pending task queue instead of leaking queued requests. PiperOrigin-RevId: 983561034
copybara-service
Bot
force-pushed
the
test_983561034
branch
from
September 23, 2026 20:18
77da526 to
73a517a
Compare
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.
Add TdsKVBackend storage driver and wire TDS backend into KVCacheManagerBase and KVCacheStore.
Standard buffered POSIX file I/O copies KV cache blocks through the Linux kernel page cache, incurring CPU
memcpyoverhead and host RAM page-cache bloat on high-throughput storage tiers such as Lustre, NFS, and NVMe SSDs.Implement
tpu_raiden::kv_cache::backends::storage::TdsKVBackend(tkv::backends::storage::TdsKVBackend) inheriting fromKVBackend, and wire"tds"backend creation and Host DRAM pool buffer registration (RegisterBuffer) intoKVCacheManagerBaseandKVCacheStore.All registration and data movement is delegated to
libtdsulrather than to a hand-rolled I/O engine. Host buffers are registered withtds_buffer_register_vaddr/tds_buffer_register_dmabufusingTDS_MEM_HOST, the target file is registered withtds_storage_handle_registerthrough anfd://<fd>URI, and transfers are issued viatds_read/tds_write/tds_readv/tds_writev.TdsKVBackendopens the storage file withO_DIRECTand hands that descriptor tolibtdsul. BecauseO_DIRECTis a property of the open file description, the underlyingpread/pwriteinherit it and bypass the kernel page cache. For 4KB-aligned, registered slices this is a zero-bounce transfer (direct_ops). Unaligned buffer addresses, slice lengths, or file offsets are staged through a 4KB-aligned bounce buffer owned byTdsKVBackend(bounced_ops), which performs a read-modify-write to preserve surrounding bytes and anftruncateto preserve exact logical file sizes. Pergo/tdsul-api, bounce staging belongs in the framework adapter and never insidelibtdsul. A separateo_direct_opscounter measures whether the page-cache bypass was actually retained, because both the open path and the I/O path can silently fall back to buffered mode.Vendor
libtdsulunderthird_party/tpu_raiden/tpu_sync/tpudirect_storage/so that non-experimentaltpu_raidentargets do not depend on an//experimental/...package. This copy is an interim measure; see the TODO in its BUILD file. It also carries three fixes toThreadPoolConductorthat upstream does not have: worker CPU affinity is applied only when an explicit core range is configured,pthread_createfailures retry unpinned instead of leaving a silently dead worker, andStop()drains the pending task queue instead of leaking queued requests.