Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNDB-11613 SAI compressed indexes #1474

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

pkolaczk
Copy link

What is the issue

SAI Indexes consume too much storage space, sometimes.

What does this PR fix and why was it fixed

This PR allows to compress both the per-sstable and per-index components of SAI.
Use index_compression table param to control the per-sstable components compression.
Use compression property on the index to control the per-index components compression.

Checklist before you submit for review

  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits

@pkolaczk pkolaczk force-pushed the c11613-sai-compression branch from b6c7de2 to cc3605e Compare January 20, 2025 15:43
@pkolaczk pkolaczk changed the title C11613 sai compression CNDB-11613 SAI compressed indexes Jan 21, 2025
maoling and others added 8 commits January 21, 2025 12:35
What was ported:
- current compaction throughput measurement by CompactionManager
- exposing current compaction throughput in StorageService
  and CompactionMetrics
- nodetool getcompactionthroughput, including tests

Not ported:
- changes to `nodetool compactionstats`, because that would
  require porting also the tests which are currently missing in CC
  and porting those tests turned out to be a complex task without
  porting the other changes in the CompactionManager API
- Code for getting / setting compaction throughput as double
This commit introduces a new AdaptiveCompressor class.

AdaptiveCompressor uses ZStandard compression with a dynamic
compression level based on the current write load. AdaptiveCompressor's
goal is to provide similar write performance as LZ4Compressor
for write heavy workloads, but a significantly better compression ratio
for databases with a moderate amount of writes or on systems
with a lot of spare CPU power.

If the memtable flush queue builds up, and it turns out the compression
is a significant bottleneck, then the compression level used for
flushing is decreased to gain speed. Similarly, when pending
compaction tasks build up, then the compression level used
for compaction is decreased.

In order to enable adaptive compression:
  - set `-Dcassandra.default_sstable_compression=adaptive` JVM option
    to automatically select `AdaptiveCompressor` as the main compressor
    for flushes and new tables, if not overriden by specific options in
    cassandra.yaml or table schema
  - set `flush_compression: adaptive` in cassandra.yaml to enable it
    for flushing
  - set `AdaptiveCompressor` in Table options to enable it
    for compaction

Caution: this feature is not turned on by default because it
may impact read speed negatively in some rare cases.

Fixes riptano/cndb#11532
Reduces some overhead of setting up / tearing down those
contexts that happened inside the calls to Zstd.compress
/ Zstd.decompress. Makes a difference with very small chunks.

Additionally, added some compression/decompression
rate metrics.
@pkolaczk pkolaczk force-pushed the c11613-sai-compression branch from cc3605e to 93bbdb4 Compare January 21, 2025 12:09
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
79.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@cassci-bot
Copy link

❌ Build ds-cassandra-pr-gate/PR-1474 rejected by Butler


2 new test failure(s) in 3 builds
See build details here


Found 2 new test failures

Test Explanation Branch history Upstream history
...t=set,wide=false,scenario=COMPACTED_QUERY] regression 🔴🔵🔵 🔵🔵🔵🔵🔵🔵🔵
o.a.c.u.b.BinLogTest.testTruncationReleasesLogS... regression 🔴🔴🔵 🔵🔵🔵🔵🔵🔵🔵

Found 228 known test failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants