[
https://issues.apache.org/jira/browse/CASSANDRA-18773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17757742#comment-17757742
]
Cameron Zemek commented on CASSANDRA-18773:
-------------------------------------------
[^compact-poc.patch]
I did a patch that does a proof of concept of that idea in my last comment.
Before:
{noformat}
INFO [CompactionExecutor:2] 2023-08-22 03:04:33,591 CompactionTask.java:241 -
Read=56.21% 138.64 KiB/s, Write=42.50% 146.09 KiB/s
INFO [CompactionExecutor:2] 2023-08-22 03:05:33,590 CompactionTask.java:241 -
Read=56.58% 143.37 KiB/s, Write=42.84% 148.96 KiB/s
INFO [CompactionExecutor:2] 2023-08-22 03:06:33,590 CompactionTask.java:241 -
Read=56.51% 144.15 KiB/s, Write=42.91% 149.77 KiB/s{noformat}
After:
{noformat}
INFO [CompactionExecutor:2] 2023-08-22 03:34:34,471 CompactionTask.java:241 -
Read=53.12% 8.07 MiB/s, Write=18.75% 8.38 MiB/s
INFO [CompactionExecutor:2] 2023-08-22 03:35:34,470 CompactionTask.java:241 -
Read=55.08% 7.88 MiB/s, Write=17.99% 8.19 MiB/s
INFO [CompactionExecutor:2] 2023-08-22 03:36:34,470 CompactionTask.java:241 -
Read=54.51% 7.65 MiB/s, Write=18.75% 7.95 MiB/s{noformat}
A 50 times improvement in compaction speed.
> Compactions are slow
> --------------------
>
> Key: CASSANDRA-18773
> URL: https://issues.apache.org/jira/browse/CASSANDRA-18773
> Project: Cassandra
> Issue Type: Improvement
> Components: Local/Compaction
> Reporter: Cameron Zemek
> Priority: Normal
> Fix For: 4.0.x, 4.1.x, 5.0.x, 5.x
>
> Attachments: compact-poc.patch, flamegraph.png, stress.yaml
>
>
> I have noticed that compactions involving a lot of sstables are very slow
> (for example major compactions). I have attached a cassandra stress profile
> that can generate such a dataset under ccm. In my local test I have 2567
> sstables at 4Mb each.
> I added code to track wall clock time of various parts of the code. One
> problematic part is ManyToOne constructor. Tracing through the code for every
> partition creating a ManyToOne for all the sstable iterators for each
> partition. In my local test get a measy 60Kb/sec read speed, and bottlenecked
> on single core CPU (since this code is single threaded) with it spending 85%
> of the wall clock time in ManyToOne constructor.
> As another datapoint to show its the merge iterator part of the code using
> the cfstats from [https://github.com/instaclustr/cassandra-sstable-tools/]
> which reads all the sstables but does no merging gets 26Mb/sec read speed.
> Tracking back from ManyToOne call I see this in
> UnfilteredPartitionIterators::merge
> {code:java}
> for (int i = 0; i < toMerge.size(); i++)
> {
> if (toMerge.get(i) == null)
> {
> if (null == empty)
> empty = EmptyIterators.unfilteredRow(metadata,
> partitionKey, isReverseOrder);
> toMerge.set(i, empty);
> }
> }
> {code}
> Not sure what purpose of creating these empty rows are. But on a whim I
> removed all these empty iterators before passing to ManyToOne and then all
> the wall clock time shifted to CompactionIterator::hasNext() and read speed
> increased to 1.5Mb/s.
> So there are further bottlenecks in this code path it seems, but the first is
> this ManyToOne and having to build it for every partition read.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]