Skip to content

Commit

Permalink
Merge pull request #1966 from Expensify/main
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
chiragsalian authored Nov 19, 2024
2 parents 3360788 + efb26e9 commit 106dba6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 29 deletions.
5 changes: 4 additions & 1 deletion libstuff/SLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ static const set<string> PARAMS_WHITELIST = {
"status",
"step",
"cardData",
"field"
"field",
"timeDiff",
"currentTime",
"requestTimestamp"
};

string addLogParams(string&& message, const map<string, string>& params) {
Expand Down
74 changes: 47 additions & 27 deletions libstuff/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** 35aa893d4537d0b3605084a1f2f5529794e8.
** 2ba41da8c437e466c71f65d67a615293efb5.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
Expand Down Expand Up @@ -465,7 +465,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-11-13 14:42:32 35aa893d4537d0b3605084a1f2f5529794e82af59b8893053815d3fcb4719a27"
#define SQLITE_SOURCE_ID "2024-11-19 17:32:03 2ba41da8c437e466c71f65d67a615293efb5a2d9da9b6e9cbb7b296221d4104a"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down Expand Up @@ -17451,39 +17451,42 @@ SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr)

#define COMMIT_TIME_RELOCATE2_READUS 10
#define COMMIT_TIME_RELOCATE2_READCOUNT 11
#define COMMIT_TIME_RELOCATE2_ALLOCATEUS 12
#define COMMIT_TIME_RELOCATE2_RELOCATEUS 13
#define COMMIT_TIME_RELOCATE2_EXACTUS 12
#define COMMIT_TIME_RELOCATE2_ALLOCATEUS 13
#define COMMIT_TIME_RELOCATE2_RELOCATEUS 14

#define COMMIT_TIME_AFTER_FIXUNLOCKED 14
#define COMMIT_TIME_AFTER_FIXUNLOCKED 15

#define COMMIT_TIME_BEFORE_WALFRAMES 15
#define COMMIT_TIME_AFTER_CHANGECOUNTER 16
#define COMMIT_TIME_AFTER_RESTARTLOG 17
#define COMMIT_TIME_AFTER_WRITEHDR 18
#define COMMIT_TIME_BEFORE_WALFRAMES 16
#define COMMIT_TIME_AFTER_CHANGECOUNTER 17
#define COMMIT_TIME_AFTER_RESTARTLOG 18
#define COMMIT_TIME_AFTER_WRITEHDR 19

#define COMMIT_TIME_OSWRITE 19
#define COMMIT_TIME_OSWRITE 20

#define COMMIT_TIME_AFTER_WRITEFRAMES 20
#define COMMIT_TIME_AFTER_WRITEFRAMES 21

#define COMMIT_TIME_NFRAME 21
#define COMMIT_TIME_HASHMAPUS 22
#define COMMIT_TIME_NFRAME 22
#define COMMIT_TIME_HASHMAPUS 23

#define COMMIT_TIME_BEFORE_WALINDEX 23
#define COMMIT_TIME_AFTER_WALINDEX 24
#define COMMIT_TIME_AFTER_WALINDEXHDR 25
#define COMMIT_TIME_BEFORE_WALINDEX 24

#define COMMIT_TIME_WALFRAMESFLAGS 26
#define COMMIT_TIME_WALINDEX_HASHGETUS 25
#define COMMIT_TIME_WALINDEX_CLEANUPUS 26
#define COMMIT_TIME_WALINDEX_ENTRYUS 27

#define COMMIT_TIME_AFTER_WALFRAMES 27
#define COMMIT_TIME_AFTER_WALINDEX 28
#define COMMIT_TIME_AFTER_WALINDEXHDR 29
#define COMMIT_TIME_WALFRAMESFLAGS 30
#define COMMIT_TIME_AFTER_WALFRAMES 31
#define COMMIT_TIME_BEFORE_PHASETWO 32
#define COMMIT_TIME_AFTER_PHASETWO 33

#define COMMIT_TIME_BEFORE_PHASETWO 28
#define COMMIT_TIME_AFTER_PHASETWO 29
#define COMMIT_TIME_AFTER_VDBECOMMIT 34
#define COMMIT_TIME_AFTER_HALT 35
#define COMMIT_TIME_FINISH 36

#define COMMIT_TIME_AFTER_VDBECOMMIT 30
#define COMMIT_TIME_AFTER_HALT 31
#define COMMIT_TIME_FINISH 32

#define COMMIT_TIME_N 33
#define COMMIT_TIME_N 37

/* #define COMMIT_TIME_TIMEOUT (2*1000*1000) */
#define COMMIT_TIME_TIMEOUT (10*1000) /* 10ms threshold */
Expand Down Expand Up @@ -67538,6 +67541,7 @@ static int walIndexAppend(Wal *pWal, int iWal, u32 iFrame, u32 iPage){
int rc; /* Return code */
WalHashLoc sLoc; /* Wal-index hash table location */
u32 iExternal;
u64 t;

if( isWalMode2(pWal) ){
iExternal = walExternalEncode(iWal, iFrame);
Expand All @@ -67546,7 +67550,11 @@ static int walIndexAppend(Wal *pWal, int iWal, u32 iFrame, u32 iPage){
iExternal = iFrame;
}

if( pWal->aCommitTime ) t = sqlite3STimeNow();
rc = walHashGet(pWal, walFramePage(iExternal), &sLoc);
if( pWal->aCommitTime ){
pWal->aCommitTime[COMMIT_TIME_WALINDEX_HASHGETUS] += sqlite3STimeNow()-t;
}

/* Assuming the wal-index file was successfully mapped, populate the
** page number array and hash table entry.
Expand Down Expand Up @@ -67575,17 +67583,25 @@ static int walIndexAppend(Wal *pWal, int iWal, u32 iFrame, u32 iPage){
** the hash-table before writing any new entries.
*/
if( sLoc.aPgno[idx-1] ){
if( pWal->aCommitTime ) t = sqlite3STimeNow();
walCleanupHash(pWal);
assert( !sLoc.aPgno[idx-1] );
if( pWal->aCommitTime ){
pWal->aCommitTime[COMMIT_TIME_WALINDEX_CLEANUPUS]+=sqlite3STimeNow()-t;
}
}

/* Write the aPgno[] array entry and the hash-table slot. */
if( pWal->aCommitTime ) t = sqlite3STimeNow();
nCollide = idx;
for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
}
sLoc.aPgno[idx-1] = iPage;
AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx);
if( pWal->aCommitTime ){
pWal->aCommitTime[COMMIT_TIME_WALINDEX_ENTRYUS]+=sqlite3STimeNow()-t;
}

#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
/* Verify that the number of entries in the hash table exactly equals
Expand Down Expand Up @@ -77421,7 +77437,7 @@ static int btreeRelocateRange(
if( pBt->aCommitTime ) t1 = sqlite3STimeNow();
rc = allocateBtreePage(pBt, &pFree, &dummy, iPg, BTALLOC_EXACT);
if( pBt->aCommitTime ){
pBt->aCommitTime[COMMIT_TIME_RELOCATE2_ALLOCATEUS] += (sqlite3STimeNow() - t1);
pBt->aCommitTime[COMMIT_TIME_RELOCATE2_EXACTUS] += (sqlite3STimeNow() - t1);
}
if( pFree ){
assert( sqlite3PagerPageRefcount(pFree->pDbPage)==1 );
Expand Down Expand Up @@ -93340,6 +93356,10 @@ SQLITE_PRIVATE void sqlite3CommitTimeLog(u64 *aCommit){
|| ii==COMMIT_TIME_RELOCATE2_ALLOCATEUS
|| ii==COMMIT_TIME_RELOCATE2_RELOCATEUS
|| ii==COMMIT_TIME_HASHMAPUS
|| ii==COMMIT_TIME_RELOCATE2_EXACTUS
|| ii==COMMIT_TIME_WALINDEX_HASHGETUS
|| ii==COMMIT_TIME_WALINDEX_CLEANUPUS
|| ii==COMMIT_TIME_WALINDEX_ENTRYUS
){
iVal = (int)aCommit[ii];
zU = "us";
Expand Down Expand Up @@ -257773,7 +257793,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2024-11-13 14:42:32 35aa893d4537d0b3605084a1f2f5529794e82af59b8893053815d3fcb4719a27", -1, SQLITE_TRANSIENT);
sqlite3_result_text(pCtx, "fts5: 2024-11-19 17:32:03 2ba41da8c437e466c71f65d67a615293efb5a2d9da9b6e9cbb7b296221d4104a", -1, SQLITE_TRANSIENT);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion libstuff/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-11-13 14:42:32 35aa893d4537d0b3605084a1f2f5529794e82af59b8893053815d3fcb4719a27"
#define SQLITE_SOURCE_ID "2024-11-19 17:32:03 2ba41da8c437e466c71f65d67a615293efb5a2d9da9b6e9cbb7b296221d4104a"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down

0 comments on commit 106dba6

Please sign in to comment.