cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-2864) Alternative Row Cache Implementation
Date Thu, 10 May 2012 15:18:50 GMT


Sylvain Lebresne commented on CASSANDRA-2864:

If you could use the occasion to squash/regroup the patches too, that would be awesome :D

For counters, we need to ensure that the same column is not read twice. I haven't really looked
at the patches yet, but a priori this means that for a flushed memtable mt, "merging mt into
the cache" and "stop merging mt content to the cache on reads" would have to happen atomically,
which will probably be tricky to do efficiently (it's probably possible to do this row-per-row
with a row cursor on the memtable that is being merged to the cache. We would 1) read/deserialize
the row from the cache and merge it to the row in the memtable and then atomically "add the
new content to the cache" and "move the memtable cursor to the next row", and reads would
only merge the cache with those rows that are after the cursor; but anyway, this is way more
complicated that what we want for a first version here).

In any case, given that we currently only support whole CF of counters, the trivial solution
is to disallow this new alternative cache for said CF.
> Alternative Row Cache Implementation
> ------------------------------------
>                 Key: CASSANDRA-2864
>                 URL:
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Daniel Doubleday
>            Assignee: Daniel Doubleday
>              Labels: cache
>             Fix For: 1.2
> we have been working on an alternative implementation to the existing row cache(s)
> We have 2 main goals:
> - Decrease memory -> get more rows in the cache without suffering a huge performance
> - Reduce gc pressure
> This sounds a lot like we should be using the new serializing cache in 0.8. 
> Unfortunately our workload consists of loads of updates which would invalidate the cache
all the time.
> *Note: Updated Patch Description (Please check history if you're interested where this
was comming from)*
> h3. Rough Idea
> - Keep serialized row (ByteBuffer) in mem which represents unfiltered but collated columns
of all ssts but not memtable columns
> - Writes dont affect the cache at all. They go only to the memtables
> - Reads collect columns from memtables and row cache
> - Serialized Row is re-written (merged) with mem tables when flushed
> h3. Some Implementation Details
> h4. Reads
> - Basically the read logic differ from regular uncached reads only in that a special
CollationController which is deserializing columns from in memory bytes
> - In the first version of this cache the serialized in memory format was the same as
the fs format but test showed that performance sufferd because a lot of unnecessary deserialization
takes place and that columns seeks are O( n ) whithin one block
> - To improve on that a different in memory format was used. It splits length meta info
and data of columns so that the names can be binary searched. 
> {noformat}
> ===========================
> Header (24)                    
> ===========================
> MaxTimestamp:        long  
> LocalDeletionTime:   int   
> MarkedForDeleteAt:   long  
> NumColumns:          int   
> ===========================
> Column Index (num cols * 12)              
> ===========================
> NameOffset:          int   
> ValueOffset:         int   
> ValueLength:         int   
> ===========================
> Column Data                
> ===========================
> Name:                byte[]
> Value:               byte[]
> SerializationFlags:  byte  
> Misc:                ?     
> Timestamp:           long  
> ---------------------------
> Misc Counter Column        
> ---------------------------
> TSOfLastDelete:      long  
> ---------------------------
> Misc Expiring Column       
> ---------------------------
> TimeToLive:          int   
> LocalDeletionTime:   int   
> ===========================
> {noformat}
> - These rows are read by 2 new column interators which correspond to SSTableNamesIterator
and SSTableSliceIterator. During filtering only columns that actually match are constructed.
The searching / skipping is performed on the raw ByteBuffer and does not create any objects.
> - A special CollationController is used to access and collate via cache and said new
iterators. It also supports skipping the cached row by max update timestamp
> h4. Writes
> - Writes dont update or invalidate the cache.
> - In CFS.replaceFlushed memtables are merged before the data view is switched. I fear
that this is killing counters because they would be overcounted but my understading of counters
is somewhere between weak and non-existing. I guess that counters if one wants to support
them here would need an additional unique local identifier in memory and in serialized cache
to be able to filter duplicates or something like that.
> {noformat}
>     void replaceFlushed(Memtable memtable, SSTableReader sstable)
>     {
>         if (sstCache.getCapacity() > 0) {
>             mergeSSTCache(memtable);
>         }
>         data.replaceFlushed(memtable, sstable);
>         CompactionManager.instance.submitBackground(this);
>     }
> {noformat}
> Test Results: See comments below

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message