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

sankalp kohli commented on CASSANDRA-4310:
------------------------------------------

One of the ways of speeding up level compaction mostly when using SSDs is to do 
them in parallel. Here is the algorithm.

public List<Set<sstableReader>> getIndependantCompactions() {
Create a set of stables called compacting. 
Create a List of Set of stables like List<Set<sstableReader>> compactionList.
LIMIT_OF_COMPACTIONS = the number of compactions to do in parallel; 

//Ignore L0 for now. 
for(int level = MAX(8) to 1) {
  while(level is eligible and compactionList.size < LIMIT_OF_COMPACTIONS and we 
have not checked for all stables in this level) {
     select the next stable from level L and also its overlapping stables in 
L+1 level like we do now.
     if stables found in previous step do not overlap with any compacting 
stable(use compacting set to store the stables which are compacting) in this 
set, add then to compactionList. 
     persist next for next call to this method like we do now so that when this 
level become eligible again, it continues from here. 
    
  }
   
  if(compactionList.size >= LIMIT_OF_COMPACTIONS)
     return compactionList;

  //DO it for L0
  //Level 0 is a little different as stables don't don't have mutual exclusion 
of keys. 
  //So we have to check whether two overlapping stables are not schedules as 
two different compactions in parallel.  
  Create a set of stables called L0selected - This will store the stables used 
for compactions. We will also use compacting. 
  while(L0 is eligible and compactionList.size < LIMIT_OF_COMPACTIONS and we 
have not checked for all stables in this level) {
     Find the oldest stable(like normal) which is not being compacted(by 
checking in compacting set) and does not overlap with any stable in L0selected.
     Find up to 31 overlapping stables with the stable found in previous step 
in L0.
     if none of these 32(31 + 1) stables overlap with any stable in L0Selected 
set or are in it then do next step
            Find the overlapping stables in L1 for each 32 stables. If none of 
L1 stable is in compacting set then add them to compactionList. Also add them 
all to L0selected.
            
     
  }
  
   return compactionList;
}

Now compact each set in the list in parallel. 

                
> Make Level Compaction go faster(multiple independant compactions in parallel) 
> for insert heavy workload
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-4310
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-4310
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.1.1
>            Reporter: sankalp kohli
>            Priority: Minor
>              Labels: compaction, leveled
>
> Problem: If you are inserting data into cassandra and level compaction cannot 
> catchup, you will create lot of files in L0.  
> Here is a solution which will help here and also increase the performance of 
> level compaction.
> We can do many compactions in parallel for unrelated data.
> 1) For no over lapping levels. Ex: when L0 stable is compacting with L1, we 
> can do compactions in other levels like L2 and L3 if they are eligible.
> 2) We can also do compactions with files in L1 which are not participating in 
> L0 compactions.
> This is specially useful if you are using SSD and is not bottlenecked by IO. 
> I am seeing this issue in my cluster. The compactions pending are more than 
> 50k.
> I am doing multithreaded to true and also not throttling the IO by putting 
> the value as 0. 
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to