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

avoid quadratic startup time in LeveledManifest

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 1.1.0
    • None

    Description

      Checking that each sstable is in the manifest on startup is O(N**2) in the number of sstables:

      .       // ensure all SSTables are in the manifest
              for (SSTableReader ssTableReader : cfs.getSSTables())
              {
                  if (manifest.levelOf(ssTableReader) < 0)
                      manifest.add(ssTableReader);
              }
      
      private int levelOf(SSTableReader sstable)
      {
          for (int level = 0; level < generations.length; level++)
          {
              if (generations[level].contains(sstable))
                  return level;
          }
          return -1;
      }
      

      Note that the contains call is a linear List.contains.

      We need to switch to a sorted list and bsearch, or a tree, to support TB-levels of data in LeveledCompactionStrategy.

      Attachments

        1. speed_up_level_of.diff
          3 kB
          Dave Brosius

        Activity

          People

            dbrosius David Brosius
            jbellis Jonathan Ellis
            David Brosius
            Peter Schuller
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: