Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the BLOCK_SIZE, AUTOFLUSH and AUTOCHECKPOINT lsm_config() options to work in KB instead of bytes. This matches the user guide. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
340c9dcd226859164d190dc711a58ad2 |
User & Date: | dan 2013-02-05 16:03:17.449 |
Context
2013-02-05
| ||
18:06 | Fixes to lsm_work() to bring it into line with documentation: (a) third argument is a number of KB, not a number of db pages, and (b) passing -1 as the third argument means "do as much work as possible". check-in: 2f8966cd9c user: dan tags: trunk | |
16:03 | Change the BLOCK_SIZE, AUTOFLUSH and AUTOCHECKPOINT lsm_config() options to work in KB instead of bytes. This matches the user guide. check-in: 340c9dcd22 user: dan tags: trunk | |
09:52 | Add test file lsm3.test, which should have been added a few days ago. check-in: 5dfd8651df user: dan tags: trunk | |
Changes
Changes to lsm-test/lsmtest_tdb3.c.
︙ | ︙ | |||
751 752 753 754 755 756 757 | } aParam[] = { { "autoflush", 0, LSM_CONFIG_AUTOFLUSH }, { "page_size", 0, LSM_CONFIG_PAGE_SIZE }, { "block_size", 0, LSM_CONFIG_BLOCK_SIZE }, { "safety", 0, LSM_CONFIG_SAFETY }, { "autowork", 0, LSM_CONFIG_AUTOWORK }, { "autocheckpoint", 0, LSM_CONFIG_AUTOCHECKPOINT }, | < | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | } aParam[] = { { "autoflush", 0, LSM_CONFIG_AUTOFLUSH }, { "page_size", 0, LSM_CONFIG_PAGE_SIZE }, { "block_size", 0, LSM_CONFIG_BLOCK_SIZE }, { "safety", 0, LSM_CONFIG_SAFETY }, { "autowork", 0, LSM_CONFIG_AUTOWORK }, { "autocheckpoint", 0, LSM_CONFIG_AUTOCHECKPOINT }, { "mmap", 0, LSM_CONFIG_MMAP }, { "use_log", 0, LSM_CONFIG_USE_LOG }, { "automerge", 0, LSM_CONFIG_AUTOMERGE }, { "max_freelist", 0, LSM_CONFIG_MAX_FREELIST }, { "multi_proc", 0, LSM_CONFIG_MULTIPLE_PROCESSES }, { "worker_automerge", 1, LSM_CONFIG_AUTOMERGE }, { "test_no_recovery", 0, TEST_NO_RECOVERY }, |
︙ | ︙ | |||
975 976 977 978 979 980 981 | } int test_lsm_small_open( const char *zFile, int bClear, TestDb **ppDb ){ | | | | | | | | 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | } int test_lsm_small_open( const char *zFile, int bClear, TestDb **ppDb ){ const char *zCfg = "page_size=256 block_size=64"; return testLsmOpen(zCfg, zFile, bClear, ppDb); } int test_lsm_lomem_open( const char *zFilename, int bClear, TestDb **ppDb ){ /* "max_freelist=4 autocheckpoint=32" */ const char *zCfg = "page_size=256 block_size=64 autoflush=16 " "autocheckpoint=32" "mmap=0 " ; return testLsmOpen(zCfg, zFilename, bClear, ppDb); } int test_lsm_zip_open( const char *zFilename, int bClear, TestDb **ppDb ){ const char *zCfg = "page_size=256 block_size=64 autoflush=16 " "autocheckpoint=32 compression=1 mmap=0 " ; return testLsmOpen(zCfg, zFilename, bClear, ppDb); } lsm_db *tdb_lsm(TestDb *pDb){ if( pDb->pMethods->xClose==test_lsm_close ){ return ((LsmDb *)pDb)->db; |
︙ | ︙ |
Changes to src/lsm.h.
︙ | ︙ | |||
142 143 144 145 146 147 148 | */ int lsm_config(lsm_db *, int, ...); /* ** The following values may be passed as the second argument to lsm_config(). ** ** LSM_CONFIG_AUTOFLUSH: | | > | > > > > | > > > > > > | > | > > > > > > | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | */ int lsm_config(lsm_db *, int, ...); /* ** The following values may be passed as the second argument to lsm_config(). ** ** LSM_CONFIG_AUTOFLUSH: ** A read/write integer parameter. ** ** This value determines the amount of data allowed to accumulate in a ** live in-memory tree before it is marked as old. After committing a ** transaction, a connection checks if the size of the live in-memory tree, ** including data structure overhead, is greater than the value of this ** option in KB. If it is, and there is not already an old in-memory tree, ** the live in-memory tree is marked as old. ** ** The maximum allowable value is 1048576 (1GB). There is no minimum ** value. If this parameter is set to zero, then an attempt is made to ** mark the live in-memory tree as old after each transaction is committed. ** ** The default value is 1024 (1MB). ** ** LSM_CONFIG_PAGE_SIZE: ** A read/write integer parameter. This parameter may only be set before ** lsm_open() has been called. ** ** LSM_CONFIG_BLOCK_SIZE: ** A read/write integer parameter. ** ** This parameter may only be set before lsm_open() has been called. It ** must be set to a power of two between 64 and 65536, inclusive (block ** sizes between 64KB and 64MB). ** ** If the connection creates a new database, the block size of the new ** database is set to the value of this option in KB. After lsm_open() ** has been called, querying this parameter returns the actual block ** size of the opened database. ** ** The default value is 1024 (1MB blocks). ** ** LSM_CONFIG_SAFETY: ** A read/write integer parameter. Valid values are 0, 1 (the default) ** and 2. This parameter determines how robust the database is in the ** face of a system crash (e.g. a power failure or operating system ** crash). As follows: ** |
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | ** contains all successfully committed transactions. ** ** LSM_CONFIG_AUTOWORK: ** A read/write integer parameter. ** ** LSM_CONFIG_AUTOCHECKPOINT: ** A read/write integer parameter. ** ** LSM_CONFIG_MMAP: ** A read/write integer parameter. True to use mmap() to access the ** database file. False otherwise. ** ** LSM_CONFIG_USE_LOG: ** A read/write boolean parameter. True (the default) to use the log | > > > > > > > > > > > > > > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | ** contains all successfully committed transactions. ** ** LSM_CONFIG_AUTOWORK: ** A read/write integer parameter. ** ** LSM_CONFIG_AUTOCHECKPOINT: ** A read/write integer parameter. ** ** If this option is set to non-zero value N, then a checkpoint is ** automatically attempted after each N KB of data have been written to ** the database file. ** ** The amount of uncheckpointed data already written to the database file ** is a global parameter. After performing database work (writing to the ** database file), the process checks if the total amount of uncheckpointed ** data exceeds the value of this paramter. If so, a checkpoint is performed. ** This means that this option may cause the connection to perform a ** checkpoint even if the current connection has itself written very little ** data into the database file. ** ** The default value is 2048 (checkpoint every 2MB). ** ** LSM_CONFIG_MMAP: ** A read/write integer parameter. True to use mmap() to access the ** database file. False otherwise. ** ** LSM_CONFIG_USE_LOG: ** A read/write boolean parameter. True (the default) to use the log |
︙ | ︙ | |||
225 226 227 228 229 230 231 | ** content. */ #define LSM_CONFIG_AUTOFLUSH 1 #define LSM_CONFIG_PAGE_SIZE 2 #define LSM_CONFIG_SAFETY 3 #define LSM_CONFIG_BLOCK_SIZE 4 #define LSM_CONFIG_AUTOWORK 5 | < | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | ** content. */ #define LSM_CONFIG_AUTOFLUSH 1 #define LSM_CONFIG_PAGE_SIZE 2 #define LSM_CONFIG_SAFETY 3 #define LSM_CONFIG_BLOCK_SIZE 4 #define LSM_CONFIG_AUTOWORK 5 #define LSM_CONFIG_MMAP 7 #define LSM_CONFIG_USE_LOG 8 #define LSM_CONFIG_AUTOMERGE 9 #define LSM_CONFIG_MAX_FREELIST 10 #define LSM_CONFIG_MULTIPLE_PROCESSES 11 #define LSM_CONFIG_AUTOCHECKPOINT 12 #define LSM_CONFIG_SET_COMPRESSION 13 |
︙ | ︙ |
Changes to src/lsmInt.h.
︙ | ︙ | |||
41 42 43 44 45 46 47 | /* ** Default values for various data structure parameters. These may be ** overridden by calls to lsm_config(). */ #define LSM_DFLT_PAGE_SIZE (4 * 1024) #define LSM_DFLT_BLOCK_SIZE (1 * 1024 * 1024) #define LSM_DFLT_AUTOFLUSH (1 * 1024 * 1024) | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* ** Default values for various data structure parameters. These may be ** overridden by calls to lsm_config(). */ #define LSM_DFLT_PAGE_SIZE (4 * 1024) #define LSM_DFLT_BLOCK_SIZE (1 * 1024 * 1024) #define LSM_DFLT_AUTOFLUSH (1 * 1024 * 1024) #define LSM_DFLT_AUTOCHECKPOINT (i64)(2 * 1024 * 1024) #define LSM_DFLT_AUTOWORK 1 #define LSM_DFLT_LOG_SIZE (128*1024) #define LSM_DFLT_AUTOMERGE 4 #define LSM_DFLT_SAFETY LSM_SAFETY_NORMAL #define LSM_DFLT_MMAP LSM_IS_64_BIT #define LSM_DFLT_MULTIPLE_PROCESSES 1 #define LSM_DFLT_USE_LOG 1 |
︙ | ︙ | |||
304 305 306 307 308 309 310 | int (*xCmp)(void *, int, void *, int); /* Compare function */ /* Values configured by calls to lsm_config */ int eSafety; /* LSM_SAFETY_OFF, NORMAL or FULL */ int bAutowork; /* Configured by LSM_CONFIG_AUTOWORK */ int nTreeLimit; /* Configured by LSM_CONFIG_AUTOFLUSH */ int nMerge; /* Configured by LSM_CONFIG_AUTOMERGE */ | < | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | int (*xCmp)(void *, int, void *, int); /* Compare function */ /* Values configured by calls to lsm_config */ int eSafety; /* LSM_SAFETY_OFF, NORMAL or FULL */ int bAutowork; /* Configured by LSM_CONFIG_AUTOWORK */ int nTreeLimit; /* Configured by LSM_CONFIG_AUTOFLUSH */ int nMerge; /* Configured by LSM_CONFIG_AUTOMERGE */ int bUseLog; /* Configured by LSM_CONFIG_USE_LOG */ int nDfltPgsz; /* Configured by LSM_CONFIG_PAGE_SIZE */ int nDfltBlksz; /* Configured by LSM_CONFIG_BLOCK_SIZE */ int nMaxFreelist; /* Configured by LSM_CONFIG_MAX_FREELIST */ int bMmap; /* Configured by LSM_CONFIG_MMAP */ i64 nAutockpt; /* Configured by LSM_CONFIG_AUTOCHECKPOINT */ int bMultiProc; /* Configured by L_C_MULTIPLE_PROCESSES */ lsm_compress compress; /* Compression callbacks */ /* Sub-system handles */ FileSystem *pFS; /* On-disk portion of database */ Database *pDatabase; /* Database shared data */ |
︙ | ︙ |
Changes to src/lsm_log.c.
︙ | ︙ | |||
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #define LSM_LOG_WRITE_CKSUM 0x07 #define LSM_LOG_DELETE 0x08 #define LSM_LOG_DELETE_CKSUM 0x09 /* Require a checksum every 32KB. */ #define LSM_CKSUM_MAXDATA (32*1024) /* ** szSector: ** Commit records must be aligned to end on szSector boundaries. If ** the safety-mode is set to NORMAL or OFF, this value is 1. Otherwise, ** if the safety-mode is set to FULL, it is the size of the file-system ** sectors as reported by lsmFsSectorSize(). */ | > > > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | #define LSM_LOG_WRITE_CKSUM 0x07 #define LSM_LOG_DELETE 0x08 #define LSM_LOG_DELETE_CKSUM 0x09 /* Require a checksum every 32KB. */ #define LSM_CKSUM_MAXDATA (32*1024) /* Do not wrap a log file smaller than this in bytes. */ #define LSM_MIN_LOGWRAP (128*1024) /* ** szSector: ** Commit records must be aligned to end on szSector boundaries. If ** the safety-mode is set to NORMAL or OFF, this value is 1. Otherwise, ** if the safety-mode is set to FULL, it is the size of the file-system ** sectors as reported by lsmFsSectorSize(). */ |
︙ | ︙ | |||
399 400 401 402 403 404 405 | }else{ pNew->szSector = 1; } /* There are now three scenarios: ** ** 1) Regions 0 and 1 are both zero bytes in size and region 2 begins | | < | | | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | }else{ pNew->szSector = 1; } /* There are now three scenarios: ** ** 1) Regions 0 and 1 are both zero bytes in size and region 2 begins ** at a file offset greater than LSM_MIN_LOGWRAP. In this case, wrap ** around to the start and write data into the start of the log file. ** ** 2) Region 1 is zero bytes in size and region 2 occurs earlier in the ** file than region 0. In this case, append data to region 2, but ** remember to jump over region 1 if required. ** ** 3) Region 2 is the last in the file. Append to it. */ aReg = &pDb->treehdr.log.aRegion[0]; assert( aReg[0].iEnd==0 || aReg[0].iEnd>aReg[0].iStart ); assert( aReg[1].iEnd==0 || aReg[1].iEnd>aReg[1].iStart ); pNew->cksum0 = pDb->treehdr.log.cksum0; pNew->cksum1 = pDb->treehdr.log.cksum1; if( aReg[0].iEnd==0 && aReg[1].iEnd==0 && aReg[2].iStart>=LSM_MIN_LOGWRAP ){ /* Case 1. Wrap around to the start of the file. Write an LSM_LOG_JUMP ** into the log file in this case. Pad it out to 8 bytes using a PAD2 ** record so that the checksums can be updated immediately. */ u8 aJump[] = { LSM_LOG_PAD2, 0x04, 0x00, 0x00, 0x00, 0x00, LSM_LOG_JUMP, 0x00 }; |
︙ | ︙ |
Changes to src/lsm_main.c.
︙ | ︙ | |||
83 84 85 86 87 88 89 | /* Initialize the new object */ pDb->pEnv = pEnv; pDb->nTreeLimit = LSM_DFLT_AUTOFLUSH; pDb->nAutockpt = LSM_DFLT_AUTOCHECKPOINT; pDb->bAutowork = LSM_DFLT_AUTOWORK; pDb->eSafety = LSM_DFLT_SAFETY; pDb->xCmp = xCmp; | < | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /* Initialize the new object */ pDb->pEnv = pEnv; pDb->nTreeLimit = LSM_DFLT_AUTOFLUSH; pDb->nAutockpt = LSM_DFLT_AUTOCHECKPOINT; pDb->bAutowork = LSM_DFLT_AUTOWORK; pDb->eSafety = LSM_DFLT_SAFETY; pDb->xCmp = xCmp; pDb->nDfltPgsz = LSM_DFLT_PAGE_SIZE; pDb->nDfltBlksz = LSM_DFLT_BLOCK_SIZE; pDb->nMerge = LSM_DFLT_AUTOMERGE; pDb->nMaxFreelist = LSM_MAX_FREELIST_ENTRIES; pDb->bUseLog = LSM_DFLT_USE_LOG; pDb->iReader = -1; pDb->bMultiProc = LSM_DFLT_MULTIPLE_PROCESSES; |
︙ | ︙ | |||
207 208 209 210 211 212 213 214 | int lsm_config(lsm_db *pDb, int eParam, ...){ int rc = LSM_OK; va_list ap; va_start(ap, eParam); switch( eParam ){ case LSM_CONFIG_AUTOFLUSH: { int *piVal = va_arg(ap, int *); | > > | > | | > > > | | < < < < < < < < < | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | int lsm_config(lsm_db *pDb, int eParam, ...){ int rc = LSM_OK; va_list ap; va_start(ap, eParam); switch( eParam ){ case LSM_CONFIG_AUTOFLUSH: { /* This parameter is read and written in KB. But all internal ** processing is done in bytes. */ int *piVal = va_arg(ap, int *); int iVal = *piVal; if( iVal>=0 && iVal<=(1024*1024) ){ pDb->nTreeLimit = iVal*1024; } *piVal = (pDb->nTreeLimit / 1024); break; } case LSM_CONFIG_AUTOWORK: { int *piVal = va_arg(ap, int *); if( *piVal>=0 ){ pDb->bAutowork = *piVal; } *piVal = pDb->bAutowork; break; } case LSM_CONFIG_AUTOCHECKPOINT: { /* This parameter is read and written in KB. But all internal processing ** (including the lsm_db.nAutockpt variable) is done in bytes. */ int *piVal = va_arg(ap, int *); if( *piVal>=0 ){ int iVal = *piVal; pDb->nAutockpt = (i64)iVal * 1024; } *piVal = (int)(pDb->nAutockpt / 1024); break; } case LSM_CONFIG_PAGE_SIZE: { int *piVal = va_arg(ap, int *); if( pDb->pDatabase ){ /* If lsm_open() has been called, this is a read-only parameter. |
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 | *piVal = pDb->nDfltPgsz; } } break; } case LSM_CONFIG_BLOCK_SIZE: { int *piVal = va_arg(ap, int *); if( pDb->pDatabase ){ /* If lsm_open() has been called, this is a read-only parameter. | > > | | | > | | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | *piVal = pDb->nDfltPgsz; } } break; } case LSM_CONFIG_BLOCK_SIZE: { /* This parameter is read and written in KB. But all internal ** processing is done in bytes. */ int *piVal = va_arg(ap, int *); if( pDb->pDatabase ){ /* If lsm_open() has been called, this is a read-only parameter. ** Set the output variable to the block-size in KB according to the ** FileSystem object. */ *piVal = lsmFsBlockSize(pDb->pFS) / 1024; }else{ int iVal = *piVal; if( iVal>=64 && iVal<=65536 && ((iVal-1) & iVal)==0 ){ pDb->nDfltBlksz = iVal * 1024; }else{ *piVal = pDb->nDfltBlksz / 1024; } } break; } case LSM_CONFIG_SAFETY: { int *piVal = va_arg(ap, int *); |
︙ | ︙ |
Changes to www/lsmusr.wiki.
︙ | ︙ | |||
157 158 159 160 161 162 163 | <h1 id=using_lsm_in_applications>2. Using LSM in Applications </h1> <p>LSM is not currently built or distributed independently. Instead, it is part of the SQLite4 library. To use LSM in an application, the application links against libsqlite4 and includes the header file "lsm.h" in any files that access the LSM API. | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | <h1 id=using_lsm_in_applications>2. Using LSM in Applications </h1> <p>LSM is not currently built or distributed independently. Instead, it is part of the SQLite4 library. To use LSM in an application, the application links against libsqlite4 and includes the header file "lsm.h" in any files that access the LSM API. <p><span style=color:red>Pointer to build instructions for sqlite4</span> <h1 id=basic_usage>3. Basic Usage</h1> <h2 id=opening_and_closing_database_connections>3.1. Opening and Closing Database Connections </h2> <p>Opening a connection to a database is a two-step process. The <a href=lsmapi.wiki#lsm_new>lsm_new()</a> function is used to create a new |
︙ | ︙ | |||
949 950 951 952 953 954 955 | this option is set to the number of segments that the library attempts to merge simultaneously. Increasing this value may reduce the total amount of data written to the database file. Decreasing it increases the amount of data written to the file, but also decreases the average number of segments present in the file, which can improve the performance of database read operations. | | > > > > > | < | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | this option is set to the number of segments that the library attempts to merge simultaneously. Increasing this value may reduce the total amount of data written to the database file. Decreasing it increases the amount of data written to the file, but also decreases the average number of segments present in the file, which can improve the performance of database read operations. <p>Additionally, whether or not auto-work is enabled, this option is used to determine the maximum number of segments of a given age that are allowed to accumulate in the database file. This is described in the <a href=#compulsary_work_and_checkpoints>compulsary work and checkpoints</a> section below. <p>The default value is 4. This option must be set to a value between 2 and 8, inclusive. <dt> <a href=lsmapi.wiki#LSM_CONFIG_AUTOWORK>LSM_CONFIG_AUTOWORK</a> <dd> <p style=margin-top:0> <p>This option may be set to either 1 (true) or 0 (false). If it is set to true, then work and checkpoint operations are automatically scheduled within calls to lsm_insert(), lsm_delete(), lsm_delete_range() and lsm_commit(). Otherwise, if it is set to false, these operations must be <a href=#explicit_scheduling>explicitly scheduled</a> by the application. <p>The default value is 1. <dt> <a href=lsmapi.wiki#LSM_CONFIG_MMAP>LSM_CONFIG_MMAP</a> <dd> <p style=margin-top:0> If LSM is running on a system with a 64-bit address space, this option may be set to either 1 (true) or 0 (false). On a 32-bit platform, it is |
︙ | ︙ |