Repository navigation
Conversation
Text index rebuilds can produce hundreds of small files whose combined inline data exceeds the 16 MiB manifest limit. Count inline bytes from the final paths and store the largest added or replaced files as blobs until the manifest fits. Include unchanged base entries in the budget when updating a published part. Use the existing precommit and blob upload path for spilled files. Share their payload across upload requests and independent readers. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Text index files can outgrow the 1 MiB per-file inline limit while a merge is still writing them. Keeping the entire file in memory until finalize makes the peak allocation grow with the file size. Once a write crosses the limit, pass the buffered prefix and subsequent blocks to the local staging writer. Release the prefix allocation after the transfer. At finalize, register the staged file for publication through the existing precommit and blob upload path. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Stream new part files to the configured local or S3 staging backend. Keep the size, content hash and staging handle when a writer closes. At commit, read the files selected for inline placement and publish the remaining blobs from staging. Hardlinks, moves and open readers retain the source until their last reference is released. Exercise the manifest budget with 100 rows and 20 temporary text index segments in both a merge and a mutation. Cover multipart staging and cleanup on RustFS after a successful insert or an injected failure. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
k-morozov
marked this pull request as draft
November 28, 2026 17:10
This reverts commit 6430520. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
An inline candidate written in chunks can retain substantially more memory than its payload when the transaction takes ownership. Request a smaller allocation before moving the finalized string into the manifest entry. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Pin LZ4 for the text index rebuild so randomized server codecs cannot make the segment dictionaries fit below the manifest limit. Generate 100 rows across 20 segments and check that both the merge and mutation still select entries for blob placement. Exclude the memory measurement at compile time under sanitizers, where the allocation tracker cannot support the assertion. This avoids Clang's unreachable-code diagnostic after `GTEST_SKIP`. Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
k-morozov
marked this pull request as ready for review
November 28, 2026 23:28
…limit Randomized dictionary settings can make the 100-row fixture fit within the manifest budget. Keep the dictionary settings stable and report the segment and blob-placement checks separately for the merge and mutation. Use the same per-file inline limit in the writer and the manifest validator. Include the namespace and ref in the retained-entry limit error and document staging, the placement counter and failed commits. CI: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2969&sha=a2b90dc739fc9e8169a4784148258164f8b191de&name_0=PR PR: #2969 Co-authored-by: Codex (GPT-6) <noreply@openai.com> Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
This branch has not been deployed
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.
What changed
A text-index rebuild can write hundreds of files that are individually small enough for inline placement. When their combined contents exceeded 16 MiB, CAS rejected the manifest after the merge had already built the index. A retry could repeat the entire merge and hit the same limit.
At commit, CAS counts the inline bytes from unchanged base-manifest entries and from the paths being added or replaced. If the total exceeds 16 MiB, it switches the largest eligible entries supplied by the transaction to blob placement until the manifest fits. During writes, an inline candidate such as
skp_idx_idx_s.dct.idxspills to a local temporary file as soon as it exceeds 1 MiB, including on disks configured for S3 staging. Smaller files stay in memory. On finalize, CAS trims spare string capacity before transferring their bytes to the transaction. The combined contents of these files can still exceed 16 MiB in RAM before commit. Manifest budget · Spill after 1 MiB · Trim retained capacityWhy the PR keeps partial streaming
We also tested streaming every file to the configured staging backend from the first byte. This reduced the writer's retained memory to 25,232 bytes for 64 small files, but on RustFS with S3 staging it increased both the memory peak and the time needed to rebuild a text index. The PR reverts that experiment. Full streaming · Revert
Peak tracked memory for a one-million-row text-index rebuild on RustFS 1.0.6, from one profiled run per cell in
system.part_log. The three columns compare the historical commits before the final string-capacity change.MATERIALIZE INDEX idx_s, one 1M-row partMATERIALIZE INDEX idx_s, one 1M-row partIn the separate timing series with S3 staging, median merge duration rose from 149.7 s on C2 to 293.3 s on C3, and median mutation duration rose from 146.6 s to 288.9 s (three runs per cell). Staging small files in S3 added writes and reads during index construction. For example, a proxy trace of the merge counted 818 GETs on C2 and 3,095 on C3. The median paired change was +99% for merge duration and +97% for mutation duration. Peak tracked memory increased by 18% and 26%, respectively, in that timing series. Local-staging timings varied across paired runs. These results rule out streaming every file from the first byte as the default for this PR. CAS streaming benchmark results for Antalya 26.8
Follow-up in a separate PR
The remaining case is one disk transaction that finalizes many files smaller than 1 MiB. For example, 64 index files of 600 KiB each still retain 37.76 MiB before commit after trimming excess capacity. The proposed follow-up gives the transaction a shared 16 MiB memory budget for inline candidates across both open writers and finalized files. Small writes can stay in RAM while space is available. A writer that needs more space spills its current file to local staging. The existing commit-time policy continues to choose inline or blob placement for each manifest. The transaction budget will be developed and benchmarked in a separate PR. The available data contain no paired measurements for that implementation.
Verification
CASInlineCapGapsandCASInlineCandidateMemorypassed with the final callback, including the exact 16 MiB boundary, one byte over budget, and payload preservation on either side of the 1 MiB spill threshold.05815test pins LZ4 at the table level. With server defaults ofLZ4,ZSTD(1)andZSTD(3), the merge and mutation each wrote 20 temporary index segments and selected three entries for blob placement. Indexed lookup andCHECK TABLEpassed in all three runs. The fixed memory-test translation unit compiled under ASan+UBSan with unreachable-code warnings treated as errors.CHECK TABLE.0.idxthrough63.idx(600 KiB each). With the same callback signature,shrink_to_fit()reduced tracked memory before commit from 64.26 to 37.76 MiB in every block. The median paired cost was 1.44 ms (+9.58%) for writing and finalizing all 64 files. This follow-up measured only the writer.Related: #2441
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
CAS disks can commit merges and mutations whose small files together exceed the 16 MiB manifest inline limit by storing the excess contents as blobs.
Documentation entry for user-facing changes
CAS enforces the existing 16 MiB per-manifest inline limit automatically.
CI/CD Options
Exclude tests:
Regression jobs to run: