Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-12961

LCS needlessly checks for L0 STCS candidates multiple times

    XMLWordPrintableJSON

    Details

      Description

      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:

              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;
      ......
      

        Attachments

          Activity

            People

            • Assignee:
              vusal.ahmadoglu Vusal Ahmadoglu
              Reporter:
              jjirsa Jeff Jirsa
              Authors:
              Vusal Ahmadoglu
              Reviewers:
              Jeff Jirsa
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: