You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jeff Jirsa (JIRA)" <ji...@apache.org> on 2017/06/20 22:17:07 UTC

[jira] [Commented] (CASSANDRA-12961) LCS needlessly checks for L0 STCS candidates multiple times

    [ https://issues.apache.org/jira/browse/CASSANDRA-12961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16056563#comment-16056563 ] 

Jeff Jirsa commented on CASSANDRA-12961:
----------------------------------------

[~calonso] - if you're still interested, I think it's simpler than that.

In the above code block, look at:

{code}
                CompactionCandidate l0Compaction = getSTCSInL0CompactionCandidate();
{code}

If you move that before the loop, we can still keep the check where it is:

{code}
                if (l0Compaction != null)
                    return l0Compaction;
{code}

At each level, without having to actually call all the way down to the (relatively expensive) {{SizeTieredCompactionStrategy.createSSTableAndLengthPairs}} / {{SizeTieredCompactionStrategy.getBuckets}}



> LCS needlessly checks for L0 STCS candidates multiple times
> -----------------------------------------------------------
>
>                 Key: CASSANDRA-12961
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12961
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Compaction
>            Reporter: Jeff Jirsa
>            Priority: Trivial
>              Labels: lhf
>
> It's very likely that the check for L0 STCS candidates (if L0 is falling behind) can be moved outside of the loop, or at very least made so that it's not called on each loop iteration:
> {code}
>         for (int i = generations.length - 1; i > 0; i--)
>         {
>             List<SSTableReader> sstables = getLevel(i);
>             if (sstables.isEmpty())
>                 continue; // mostly this just avoids polluting the debug log with zero scores
>             // we want to calculate score excluding compacting ones
>             Set<SSTableReader> sstablesInLevel = Sets.newHashSet(sstables);
>             Set<SSTableReader> remaining = Sets.difference(sstablesInLevel, cfs.getTracker().getCompacting());
>             double score = (double) SSTableReader.getTotalBytes(remaining) / (double)maxBytesForLevel(i, maxSSTableSizeInBytes);
>             logger.trace("Compaction score for level {} is {}", i, score);
>             if (score > 1.001)
>             {
>                 // before proceeding with a higher level, let's see if L0 is far enough behind to warrant STCS
>                 CompactionCandidate l0Compaction = getSTCSInL0CompactionCandidate();
>                 if (l0Compaction != null)
>                     return l0Compaction;
> ......
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org