Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor lsm optimizations. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a02dacd5bd54e993114953435c4c59fd |
User & Date: | dan 2013-02-28 15:56:47.362 |
Context
2013-02-28
| ||
19:09 | Reuse existing lsm_cursor objects instead of always allocating new ones. check-in: 64895935bc user: dan tags: trunk | |
15:56 | Minor lsm optimizations. check-in: a02dacd5bd user: dan tags: trunk | |
2013-02-26
| ||
17:35 | Remove a stray 'breakpoint' from lsm3.test. check-in: 4ebadf909b user: dan tags: trunk | |
Changes
Changes to lsm-test/lsmtest_main.c.
︙ | |||
563 564 565 566 567 568 569 | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | - + | "Options are:\n" " -repeat $repeat (default value 10)\n" " -write $write (default value 10000)\n" " -pause $pause (default value 0)\n" " -fetch $fetch (default value 0)\n" " -keysize $keysize (default value 12)\n" " -valsize $valsize (default value 100)\n" |
︙ | |||
642 643 644 645 646 647 648 | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | - + | } printf("#"); for(i=0; i<ArraySize(aOpt); i++){ if( aOpt[i].zOpt ){ if( aOpt[i].eVal>=0 ){ printf(" %s=%d", &aOpt[i].zOpt[1], aParam[aOpt[i].eVal]); |
︙ | |||
1426 1427 1428 1429 1430 1431 1432 | 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 | - + | #ifdef __linux__ #include <sys/time.h> #include <sys/resource.h> static void lsmtest_rusage_report(void){ int res; struct rusage r; |
︙ | |||
1454 1455 1456 1457 1458 1459 1460 | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 | - + | {"writespeed", do_writer_test}, {"io", st_do_io}, {"insert", do_insert}, {"replay", do_replay}, {"speed", do_speed_tests}, |
︙ |
Changes to lsm-test/lsmtest_tdb3.c.
︙ | |||
812 813 814 815 816 817 818 | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | - + - + | if( rc!=0 ) return rc; eParam = aParam[i].eParam; z++; zStart = z; while( *z>='0' && *z<='9' ) z++; if( *z=='k' || *z=='K' ){ |
︙ | |||
837 838 839 840 841 842 843 | 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | - + - + | case TEST_NO_RECOVERY: if( pLsm ) pLsm->bNoRecovery = iVal; break; case TEST_MT_MODE: if( pLsm ) nThread = iVal; break; case TEST_MT_MIN_CKPT: |
︙ |
Changes to main.mk.
︙ | |||
40 41 42 43 44 45 46 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | - + - + | # Once the macros above are defined, the rest of this make script will # build the SQLite library and testing tools. ################################################################################ # FIXME: Required options for now. # OPTS += -DLSM_MUTEX_NONE |
︙ |
Changes to src/lsmInt.h.
︙ | |||
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | + + | */ #define LSM_START_DELETE 0x01 /* Start of open-ended delete range */ #define LSM_END_DELETE 0x02 /* End of open-ended delete range */ #define LSM_POINT_DELETE 0x04 /* Delete this key */ #define LSM_INSERT 0x08 /* Insert this key and value */ #define LSM_SEPARATOR 0x10 /* True if entry is separator key only */ #define LSM_SYSTEMKEY 0x20 /* True if entry is a system key (FREELIST) */ #define LSM_CONTIGUOUS 0x40 /* Used in lsm_tree.c */ /* ** A string that can grow by appending. */ struct LsmString { lsm_env *pEnv; /* Run-time environment */ int n; /* Size of string. -1 indicates error */ |
︙ |
Changes to src/lsm_file.c.
︙ | |||
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 | 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 | + | p = lsmMallocZeroRc(pFS->pEnv, sizeof(Page), &rc); if( rc ) return rc; fsPageAddToLru(pFS, p); p->pFS = pFS; } p->aData = &((u8 *)pFS->pMap)[pFS->nPagesize * (iReal-1)]; p->iPg = iReal; assert( (p->flags & PAGE_FREE)==0 ); }else{ /* Search the hash-table for the page */ iHash = fsHashKey(pFS->nHash, iReal); for(p=pFS->apHash[iHash]; p; p=p->pHashNext){ if( p->iPg==iReal) break; } |
︙ |
Changes to src/lsm_main.c.
︙ | |||
751 752 753 754 755 756 757 | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | - + - + | /* ** Open a new cursor handle. ** ** If there are currently no other open cursor handles, and no open write ** transaction, open a read transaction here. */ int lsm_csr_open(lsm_db *pDb, lsm_cursor **ppCsr){ |
︙ |
Changes to src/lsm_shared.c.
︙ | |||
1333 1334 1335 1336 1337 1338 1339 | 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 | - + + - + + | dbReleaseReadlock(pDb); } /* ** Open a write transaction. */ int lsmBeginWriteTrans(lsm_db *pDb){ |
︙ |
Changes to src/lsm_tree.c.
︙ | |||
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | + + + + + + + + + + - + | ** discarded. */ static void intArrayTruncate(IntArray *p, int nVal){ p->nArray = nVal; } /* End of IntArray methods. ***********************************************************************/ static int treeKeycmp(void *p1, int n1, void *p2, int n2){ int res; res = memcmp(p1, p2, LSM_MIN(n1, n2)); if( res==0 ) res = (n1-n2); return res; } /* ** The pointer passed as the first argument points to an interior node, ** not a leaf. This function returns the offset of the iCell'th child ** sub-tree of the node. */ static u32 getChildPtr(TreeNode *p, int iVersion, int iCell){ assert( iCell>=0 && iCell<=array_size(p->aiChildPtr) ); if( p->iV2 && p->iV2<=iVersion && iCell==p->iV2Child ) return p->iV2Ptr; return p->aiChildPtr[iCell]; } /* ** Given an offset within the *-shm file, return the associated chunk number. */ static int treeOffsetToChunk(u32 iOff){ assert( LSM_SHM_CHUNK_SIZE==(1<<15) ); return (int)(iOff>>15); } #define treeShmptrUnsafe(pDb, iPtr) \ (&((u8*)((pDb)->apShm[(iPtr)>>15]))[(iPtr) & (LSM_SHM_CHUNK_SIZE-1)]) /* ** Return a pointer to the mapped memory location associated with *-shm ** file offset iPtr. */ static void *treeShmptr(lsm_db *pDb, u32 iPtr){ assert( (iPtr>>15)<pDb->nShm ); assert( pDb->apShm[iPtr>>15] ); |
︙ | |||
561 562 563 564 565 566 567 | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | - - - - + + + + + + + + + + - | } /* ** Return a pointer to the mapping of the TreeKey object that the cursor ** is pointing to. */ static TreeKey *csrGetKey(TreeCursor *pCsr, TreeBlob *pBlob, int *pRc){ |
︙ | |||
717 718 719 720 721 722 723 724 725 726 727 728 729 730 | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | + | u32 *piPtr, void *pKey, int nKey, /* Key data */ void *pVal, int nVal, /* Value data (or nVal<0 for delete) */ int *pRc ){ TreeKey *p; u32 iPtr; u32 iEnd; int nRem; u8 *a; int n; /* Allocate space for the TreeKey structure itself */ *piPtr = iPtr = treeShmalloc(pDb, 1, sizeof(TreeKey), pRc); p = treeShmptr(pDb, iPtr); |
︙ | |||
750 751 752 753 754 755 756 757 758 759 760 761 762 763 | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | + + + + + + + | memcpy(aAlloc, &a[n-nRem], nAlloc); nRem -= nAlloc; } a = pVal; n = nRem = nVal; pVal = 0; } iEnd = iPtr + sizeof(TreeKey) + nKey + LSM_MAX(0, nVal); if( (iPtr & ~(LSM_SHM_CHUNK_SIZE-1))!=(iEnd & ~(LSM_SHM_CHUNK_SIZE-1)) ){ p->flags = 0; }else{ p->flags = LSM_CONTIGUOUS; } if( *pRc ) return 0; #if 0 printf("store: %d %s\n", (int)iPtr, (char *)pKey); #endif return p; } |
︙ | |||
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 | + | int res; /* Result of seek operation on csr */ assert( nVal>=0 || pVal==0 ); assert_tree_looks_ok(LSM_OK, pTree); assert( flags==LSM_INSERT || flags==LSM_POINT_DELETE || flags==LSM_START_DELETE || flags==LSM_END_DELETE ); assert( (flags & LSM_CONTIGUOUS)==0 ); #if 0 dump_tree_contents(pDb, "before"); #endif if( p->iRoot ){ TreeKey *pRes; /* Key at end of seek operation */ treeCursorInit(pDb, 0, &csr); |
︙ | |||
1493 1494 1495 1496 1497 1498 1499 | 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 | + - + | }else{ memset(&csr, 0, sizeof(TreeCursor)); } /* Allocate and populate a new key-value pair structure */ pTreeKey = newTreeKey(pDb, &iTreeKey, pKey, nKey, pVal, nVal, &rc); if( rc!=LSM_OK ) return rc; assert( pTreeKey->flags==0 || pTreeKey->flags==LSM_CONTIGUOUS ); |
︙ | |||
1779 1780 1781 1782 1783 1784 1785 | 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 | - + | ){ int rc = LSM_OK; int bDone = 0; TreeRoot *p = &db->treehdr.root; TreeBlob blob = {0, 0}; /* The range must be sensible - that (key1 < key2). */ |
︙ | |||
1811 1812 1813 1814 1815 1816 1817 | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 | - + | /* If there is no such entry, or if it is greater than pKey2, then the ** tree now contains no keys in the range being deleted. In this case ** break out of the loop. */ bDone = 1; if( lsmTreeCursorValid(&csr) ){ lsmTreeCursorKey(&csr, 0, &pDel, &nDel); |
︙ | |||
1928 1929 1930 1931 1932 1933 1934 | 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 | - + | static int treeCsrCompare(TreeCursor *pCsr, void *pKey, int nKey){ TreeKey *p; int cmp = 0; int rc = LSM_OK; assert( pCsr->iNode>=0 ); p = csrGetKey(pCsr, &pCsr->blob, &rc); if( p ){ |
︙ | |||
1953 1954 1955 1956 1957 1958 1959 | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 | - - + - + + + - - - + + + + - - + + + + + + - - - - + + + + | ** ** * If the tree is empty, leave the cursor at EOF and set *pRes to -1. */ int lsmTreeCursorSeek(TreeCursor *pCsr, void *pKey, int nKey, int *pRes){ int rc = LSM_OK; /* Return code */ lsm_db *pDb = pCsr->pDb; TreeRoot *pRoot = pCsr->pRoot; |
︙ | |||
2088 2089 2090 2091 2092 2093 2094 | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 | - + | if( iCell<3 && pCsr->apTreeNode[pCsr->iNode]->aiKeyPtr[iCell] ) break; } } #ifndef NDEBUG if( pCsr->iNode>=0 ){ TreeKey *pK2 = csrGetKey(pCsr, &pCsr->blob, &rc); |
︙ | |||
2156 2157 2158 2159 2160 2161 2162 | 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 | - + | }while( (--pCsr->iNode)>=0 ); pCsr->aiCell[pCsr->iNode] = iCell; } #ifndef NDEBUG if( pCsr->iNode>=0 ){ TreeKey *pK2 = csrGetKey(pCsr, &pCsr->blob, &rc); |
︙ | |||
2210 2211 2212 2213 2214 2215 2216 | 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 | - + - + | return rc; } int lsmTreeCursorFlags(TreeCursor *pCsr){ int flags = 0; if( pCsr && pCsr->iNode>=0 ){ int rc = LSM_OK; |
︙ |
Changes to src/vdbe.c.
︙ | |||
2569 2570 2571 2572 2573 2574 2575 | 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 | - + | p->expired = 0; } break; } /* Opcode: VerifyCookie P1 P2 P3 * * ** |
︙ |