Sqlite experts, I am running Sqlite version 3.4.1. I ran some performance tests and observed that sqlite sometimes consumes more CPU than normal (I am using same dataset, all inserts and recreating new database for each test). Tried running oprofiile and got the following result. The function 'syncJournal' is taking around 60% of total Sqlite's CPU usage.
1. Is this normal behaviour? If not, is there a known fix for this? 2. Are there any tunables that can be used to ease the issue? PS: My database is pretty small. I am setting max_page_count=896 and page_size = 512 (Max database size = 3.5MB). Thanks in advance. ******** OPANNOTATE output ****************** :static int syncJournal(Pager *pPager){ /* syncJournal total: 2815 23.5034 */ : PgHdr *pPg; : int rc = SQLITE_OK; : : /* Sync the journal before modifying the main database : ** (assuming there is a journal and it needs to be synced.) : */ : if( pPager->needSync ){ : if( !pPager->tempFile ){ : assert( pPager->journalOpen ); : /* assert( !pPager->noSync ); // noSync might be set if synchronous : ** was turned off after the transaction was started. Ticket #615 */ :#ifndef NDEBUG : { : /* Make sure the pPager->nRec counter we are keeping agrees : ** with the nRec computed from the size of the journal file. : */ : i64 jSz; : rc = sqlite3OsFileSize(pPager->jfd, &jSz); : if( rc!=0 ) return rc; : assert( pPager->journalOff==jSz ); : } :#endif : { : /* Write the nRec value into the journal file header. If in : ** full-synchronous mode, sync the journal first. This ensures that : ** all data has really hit the disk before nRec is updated to mark : ** it as a candidate for rollback. : */ 2 0.0167 : if( pPager->fullSync ){ : PAGERTRACE2("SYNC journal of %d\n", PAGERID(pPager)); : IOTRACE(("JSYNC %p\n", pPager)) 7 0.0584 : rc = sqlite3OsSync(pPager->jfd, 0); 1 0.0083 : if( rc!=0 ) return rc; : } 1 0.0083 : rc = sqlite3OsSeek(pPager->jfd, : pPager->journalHdr + sizeof(aJournalMagic)); : if( rc ) return rc; : IOTRACE(("JHDR %p %lld %d\n", pPager, : pPager->journalHdr + sizeof(aJournalMagic), 4)) 1 0.0083 : rc = write32bits(pPager->jfd, pPager->nRec); : if( rc ) return rc; : : rc = sqlite3OsSeek(pPager->jfd, pPager->journalOff); : if( rc ) return rc; : } : PAGERTRACE2("SYNC journal of %d\n", PAGERID(pPager)); : IOTRACE(("JSYNC %p\n", pPager)) 1 0.0083 : rc = sqlite3OsSync(pPager->jfd, pPager->full_fsync); 4 0.0334 : if( rc!=0 ) return rc; : pPager->journalStarted = 1; : } : pPager->needSync = 0; : : /* Erase the needSync flag from every page. : */ 2716 22.6768 : for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ 79 0.6596 : pPg->needSync = 0; : } 2 0.0167 : pPager->pFirstSynced = pPager->pFirst; : } :#ifndef NDEBUG : /* If the Pager.needSync flag is clear then the PgHdr.needSync : ** flag must also be clear for all pages. Verify that this : ** invariant is true. : */ : else{ : for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ : assert( pPg->needSync==0 ); : } : assert( pPager->pFirstSynced==pPager->pFirst ); : } :#endif : : return rc; 1 0.0083 :} ********************************************************** ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------