LssSettings.h

// LssSettings.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2008

#ifndef Ceda_cxLss_LssSettings_H
#define Ceda_cxLss_LssSettings_H

#include "cxLss.h"

namespace ceda
{

///////////////////////////////////////////////////////////////////////////////////////////////////
// LssSettings

struct LssSettings
{
    LssSettings() :
        flushTimeMilliSec(1000),
        cleanerUtilisationPercent(85.0),
        enableFileBuffering(false),
        enableWriteThrough(false),
        maxNumSegmentsInCache(32),
        numSegmentsPerCheckPoint(128),
        segmentSize(512 * 1024),
        forceIncrementMSSN(false),
        validateSUTDuringCheckPoint(false)
    {
    }

    // Maximum time to flush the log after committing a transaction
    int flushTimeMilliSec;

    // If utilisation falls below this threshold then segment is cleaned
    double cleanerUtilisationPercent;

    // If set then the Win32 file cache will be used.   Typically not required because the LSS 
    // performs its own buffering, with its segment cache.
    // If enableFileBuffering is false then CreateFile() is called with FILE_FLAG_NO_BUFFERING
    bool enableFileBuffering;
    
    // If enableWriteThrough is true then CreateFile() is called with FILE_FLAG_WRITE_THROUGH
    bool enableWriteThrough;

    // Maximum number of segments in the segment cache.  With default values segment cache is
    // 32 x 512kB = 16 MB.
    int maxNumSegmentsInCache;

    // Sets the "rate" at which the store is check pointed.  With the default values a check point 
    // is performed after writing 128 x 512kB = 64 MB to the log.
    // This controls the maximum time taken to perform a recovery scan.  For a modern hard-disk, 
    // it only takes about one second to read 64MB.
    // Performing check points rarely has the advantage of writing less "meta data" to the log, and
    // ensuring that the meta data is well clustered.  It also means the root block is written less
    // often.
    int numSegmentsPerCheckPoint;

    // Size of each segment - the unit of reading from disk.  If too small, then performance 
    // becomes dominated by the head seek and rotational delay times of the hard-disk.  If too
    // large then performance becomes overly dependent on the clustering of related data.
    // As a very rough guide, should equal the product of the maximum transfer rate of the hard-disk 
    // in bytes per second, times the seek time in seconds.
    // Eg for transfer rate = 50 MB/sec, seek = 10 msec then product = 500k
    int segmentSize;

    // Force increment of the MSSN during start up
    bool forceIncrementMSSN;

    // For debugging purposes only.
    bool validateSUTDuringCheckPoint;
};


} // namespace ceda

#endif // include guard