mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Performance optimization to the lookaside-memory disabling mechanism.
FossilOrigin-Name: 17ce1c49cb0ed6fdd8c7c33431bc2afa217f1092c99b8dd608890a8e7aec7fb1
This commit is contained in:
@@ -1271,10 +1271,17 @@ struct Schema {
|
||||
** is shared by multiple database connections. Therefore, while parsing
|
||||
** schema information, the Lookaside.bEnabled flag is cleared so that
|
||||
** lookaside allocations are not used to construct the schema objects.
|
||||
**
|
||||
** New lookaside allocations are only allowed if bDisable==0. When
|
||||
** bDisable is greater than zero, sz is set to zero which effectively
|
||||
** disables lookaside without adding a new test for the bDisable flag
|
||||
** in a performance-critical path. sz should be set by to szTrue whenever
|
||||
** bDisable changes back to zero.
|
||||
*/
|
||||
struct Lookaside {
|
||||
u32 bDisable; /* Only operate the lookaside when zero */
|
||||
u16 sz; /* Size of each buffer in bytes */
|
||||
u16 szTrue; /* True value of sz, even if disabled */
|
||||
u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
|
||||
u32 nSlot; /* Number of lookaside slots allocated */
|
||||
u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */
|
||||
@@ -1287,6 +1294,10 @@ struct LookasideSlot {
|
||||
LookasideSlot *pNext; /* Next buffer in the list of free buffers */
|
||||
};
|
||||
|
||||
#define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0
|
||||
#define EnableLookaside db->lookaside.bDisable--;\
|
||||
db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue
|
||||
|
||||
/*
|
||||
** A hash table for built-in function definitions. (Application-defined
|
||||
** functions use a regular table table from hash.h.)
|
||||
|
||||
Reference in New Issue
Block a user