mirror of https://github.com/apache/cassandra
add SSTableWriter buffer size option; increase default.
patch by jbellis; reviewed by Sammy Yu for CASSANDRA-339 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@802185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8a9c25ae0e
commit
e24925d49e
|
|
@ -190,29 +190,41 @@
|
|||
<!-- Memory, Disk, and Performance -->
|
||||
<!--======================================================================-->
|
||||
|
||||
<!-- Add column indexes to a row after its contents reach this size -->
|
||||
<ColumnIndexSizeInKB>256</ColumnIndexSizeInKB>
|
||||
<!-- Buffer size to use when flushing memtables to disk.
|
||||
(Only one memtable is ever flushed at a time.)
|
||||
Increase (decrease) the index buffer size relative to the data buffer
|
||||
if you have few (many) columns per key. -->
|
||||
<FlushDataBufferSizeInMB>32</FlushDataBufferSizeInMB>
|
||||
<FlushIndexBufferSizeInMB>8</FlushIndexBufferSizeInMB>
|
||||
|
||||
<!-- Add column indexes to a row after its contents reach this size.
|
||||
Increase if your column values are large, or if you have a very large
|
||||
number of columns. The competing causes are, Cassandra has to
|
||||
deserialize this much of the row to read a single column, so you
|
||||
want it to be small - at least if you do many partial-row reads
|
||||
- but all the index data is read for each access, so
|
||||
you don't want to generate that wastefully either. -->
|
||||
<ColumnIndexSizeInKB>64</ColumnIndexSizeInKB>
|
||||
|
||||
<!--
|
||||
The maximum amount of data to store in memory before flushing to
|
||||
The maximum amount of data to store in memory per ColumnFamily before flushing to
|
||||
disk. Note: There is one memtable per column family, and this threshold
|
||||
is based solely on the amount of data stored, not actual heap memory
|
||||
usage (there is some overhead in indexing the columns).
|
||||
-->
|
||||
<MemtableSizeInMB>32</MemtableSizeInMB>
|
||||
|
||||
<MemtableSizeInMB>64</MemtableSizeInMB>
|
||||
<!--
|
||||
The maximum number of columns in millions to store in memory
|
||||
The maximum number of columns in millions to store in memory per ColumnFamily
|
||||
before flushing to disk. This is also a per-memtable setting.
|
||||
Use with MemtableSizeInMB to tune memory usage.
|
||||
-->
|
||||
<MemtableObjectCountInMillions>0.01</MemtableObjectCountInMillions>
|
||||
<MemtableObjectCountInMillions>0.1</MemtableObjectCountInMillions>
|
||||
|
||||
<!-- Unlike most systems, in Cassandra writes are faster than
|
||||
reads, so you can afford more of those in parallel.
|
||||
A good rule of thumb is 2 concurrent reads per processor core.
|
||||
You especially want more concurrentwrites if you are using
|
||||
CommitLogSync + CommitLogSyncDelay. -->
|
||||
Increase ConcurrentWrites to the number of clients writing
|
||||
at once if you enable CommitLogSync + CommitLogSyncDelay. -->
|
||||
<ConcurrentReads>8</ConcurrentReads>
|
||||
<ConcurrentWrites>32</ConcurrentWrites>
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ public class DatabaseDescriptor
|
|||
private static int consistencyThreads_ = 4; // not configurable
|
||||
private static int concurrentReaders_ = 8;
|
||||
private static int concurrentWriters_ = 32;
|
||||
|
||||
private static int flushDataBufferSizeInMB_ = 32;
|
||||
private static int flushIndexBufferSizeInMB_ = 32;
|
||||
private static List<String> tables_ = new ArrayList<String>();
|
||||
private static Set<String> applicationColumnFamilies_ = new HashSet<String>();
|
||||
|
||||
|
|
@ -224,6 +227,17 @@ public class DatabaseDescriptor
|
|||
concurrentWriters_ = Integer.parseInt(rawWriters);
|
||||
}
|
||||
|
||||
String rawFlushData = xmlUtils.getNodeValue("/Storage/FlushDataBufferSizeInMB");
|
||||
if (rawFlushData != null)
|
||||
{
|
||||
flushDataBufferSizeInMB_ = Integer.parseInt(rawFlushData);
|
||||
}
|
||||
String rawFlushIndex = xmlUtils.getNodeValue("/Storage/FlushIndexBufferSizeInMB");
|
||||
if (rawFlushIndex != null)
|
||||
{
|
||||
flushIndexBufferSizeInMB_ = Integer.parseInt(rawFlushIndex);
|
||||
}
|
||||
|
||||
/* TCP port on which the storage system listens */
|
||||
String port = xmlUtils.getNodeValue("/Storage/StoragePort");
|
||||
if ( port != null )
|
||||
|
|
@ -909,4 +923,14 @@ public class DatabaseDescriptor
|
|||
{
|
||||
return commitLogSync_;
|
||||
}
|
||||
|
||||
public static int getFlushDataBufferSizeInMB()
|
||||
{
|
||||
return flushDataBufferSizeInMB_;
|
||||
}
|
||||
|
||||
public static int getFlushIndexBufferSizeInMB()
|
||||
{
|
||||
return flushIndexBufferSizeInMB_;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.utils.BloomFilter;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
|
||||
|
||||
public class SSTableWriter extends SSTable
|
||||
|
|
@ -26,8 +27,8 @@ public class SSTableWriter extends SSTable
|
|||
public SSTableWriter(String filename, int keyCount, IPartitioner partitioner) throws IOException
|
||||
{
|
||||
super(filename, partitioner);
|
||||
dataFile = new BufferedRandomAccessFile(path, "rw", 4 * 1024 * 1024);
|
||||
indexFile = new BufferedRandomAccessFile(indexFilename(), "rw", 1024 * 1024);
|
||||
dataFile = new BufferedRandomAccessFile(path, "rw", DatabaseDescriptor.getFlushDataBufferSizeInMB() * 1024 * 1024);
|
||||
indexFile = new BufferedRandomAccessFile(indexFilename(), "rw", DatabaseDescriptor.getFlushIndexBufferSizeInMB() * 1024 * 1024);
|
||||
bf = new BloomFilter(keyCount, 15);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Inserter(Thread):
|
|||
self.count = 0
|
||||
client = get_client(port=9160)
|
||||
client.transport.open()
|
||||
for i in xrange(0, 1000):
|
||||
for i in xrange(0, 200):
|
||||
data = md5(str(i)).hexdigest()
|
||||
for j in xrange(0, 1000):
|
||||
key = '%s.%s.%s' % (time.time(), id, j)
|
||||
|
|
|
|||
Loading…
Reference in New Issue