Cassandra 21134 - Direct I/O Background Writes#4814
Closed
samueldlightfoot wants to merge 18 commits into
Closed
Conversation
…act, harden abort tests - Revert compressed and maxCompressedLength to private in CompressedSequentialWriter - Document that writeChunk post-call buffer position is unspecified - Fix test Javadoc class name typo - Use explicit finishOnClose(false) in abort tests Add abort/cleanup path tests for DirectCompressedSequentialWriter to guard against native memory leaks
Reusable chunk CRC32
…21134-direct-compaction-writes # Conflicts: # src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java
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.
CASSANDRA-21134: Direct I/O for background SSTable writes
Summary
Adds an opt-in
O_DIRECTwrite path for background SSTable producers, bypassing the OSpage cache for data that is unlikely to be re-read soon after being written. Memtable
flush data stays buffered (it is hot and benefits from the page cache).
Enabled via a new YAML knob:
The path is gated by:
background_write_disk_access_mode == direct),path), and
OperationType-keyed allowlist (DataComponent#DIRECT_WRITE_SUPPORT).Selection happens centrally in
DataComponent.buildWriter; producers are unchanged.Operations covered (DIO eligible)
COMPACTIONMAJOR_COMPACTIONTOMBSTONE_COMPACTIONANTICOMPACTIONGARBAGE_COLLECTCLEANUPUPGRADE_SSTABLESWRITESTREAMThe allowlist is exhaustive: any new
OperationTypewithwritesData == truethat is notclassified will fail static initialization (
AssertionError).Operations NOT covered
FLUSH(memtable flush)UNSUPPORTED_POLICYSCRUBUNSUPPORTED_CORRECTNESStryAppendneedsmark()/resetAndTruncate(), which the DIO writer cannot satisfy.DataComponent.buildWriter; the DIO gate never runs.CompressedSequentialWriterhas a DIO subclass in this change.Removing a
UNSUPPORTED_CORRECTNESSentry requires code changes; removingUNSUPPORTED_POLICYis a configuration / policy decision.Key code
io/DirectIoSupport.java— eligibility enum (SUPPORTED/UNSUPPORTED_CORRECTNESS/UNSUPPORTED_POLICY/NOT_APPLICABLE).io/sstable/format/DataComponent.java— central selection + allowlist + exhaustivenesscheck; first activation per op is logged.
io/compress/DirectCompressedSequentialWriter.java— new writer; aligned buffers, nomark()/resetAndTruncate().io/compress/CompressedSequentialWriter.java— refactored to allow the DIO subclass tooverride the write chunk path;
writeChunkcontract documented and asserted.config/Config.java,config/DatabaseDescriptor.java— new knobs, validation, andstartup wiring; buffer size aligned to FS block size and auto-grown to chunk length.
service/StartupChecks.java— fails fast ifdirectis requested on a platform/FS thatdoes not support
O_DIRECT.Tests introduced
DirectCompressedSequentialWriterTest(unit, 818 lines) — covers the DIO writer inisolation: chunk-boundary alignment, buffer auto-expansion to chunk length, abort/close
paths, checksum + compression-info component correctness, error handling.
DataComponentDirectWriteSelectionTest(unit) — verifies the selection matrix:per-OperationType eligibility, exhaustiveness assertion, compression-enabled gate,
config-mode gate.
StreamingDirectWriteTest(in-JVM distributed) — proves chunked streaming(
CassandraStreamReader/CassandraCompressedStreamReader→BigTableWriter.openDataWriter→OperationType.STREAM) selects the DIO writer whenenabled; ZCS is disabled in the test since it bypasses the selection point.
DirectIoTestUtils— shared helpers (FS block size, alignment) for the suites above.AntiCompactionTest,CompactionsTest— extended to exercise the DIO path end-to-endfor the compaction operations in the allowlist.
DatabaseDescriptorTest— validation of the new knobs (mode parsing, buffer-sizealignment, defaults).
Not in scope
patch by Sam Lightfoot; reviewed by for CASSANDRA21134
The Cassandra Jira