SQLite

Check-in [8660cda6f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the SHM VFS logic in os_unix.c so that it does not hold an exclusive lock n the mapped memory when also holding a CHECKPOINT lock. This improves concurrency between readers and checkpointers.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: 8660cda6f8ef43bd276897ef3b5fc2376b5684dc
User & Date: drh 2010-04-30 17:47:51.000
Context
2010-04-30
22:28
Merge in changes from the trunk. (check-in: 76bf0eee1f user: drh tags: wal)
17:47
Change the SHM VFS logic in os_unix.c so that it does not hold an exclusive lock n the mapped memory when also holding a CHECKPOINT lock. This improves concurrency between readers and checkpointers. (check-in: 8660cda6f8 user: drh tags: wal)
17:28
Remove some obsolete debugging parameters. (check-in: a012aed498 user: drh tags: wal)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
5136
5137
5138
5139
5140
5141
5142

5143


5144
5145
5146
5147
5148
5149
5150
  int *pNewMapSize,        /* Write new size of mapping here */
  void **ppBuf             /* Write mapping buffer origin here */
){
  unixShm *p = (unixShm*)pSharedMem;
  unixShmFile *pFile = p->pFile;
  int rc = SQLITE_OK;


  sqlite3_mutex_enter(pFile->mutexBuf);


  sqlite3_mutex_enter(pFile->mutex);
  if( pFile->szMap==0 || reqMapSize>pFile->szMap ){
    int actualSize;
    if( unixShmSize(pSharedMem, -1, &actualSize)==SQLITE_OK
     && reqMapSize<actualSize
    ){
      reqMapSize = actualSize;







>
|
>
>







5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
  int *pNewMapSize,        /* Write new size of mapping here */
  void **ppBuf             /* Write mapping buffer origin here */
){
  unixShm *p = (unixShm*)pSharedMem;
  unixShmFile *pFile = p->pFile;
  int rc = SQLITE_OK;

  if( p->lockState!=SQLITE_SHM_CHECKPOINT ){
    sqlite3_mutex_enter(pFile->mutexBuf);
    p->hasMutexBuf = 1;
  }
  sqlite3_mutex_enter(pFile->mutex);
  if( pFile->szMap==0 || reqMapSize>pFile->szMap ){
    int actualSize;
    if( unixShmSize(pSharedMem, -1, &actualSize)==SQLITE_OK
     && reqMapSize<actualSize
    ){
      reqMapSize = actualSize;
5164
5165
5166
5167
5168
5169
5170

5171
5172


5173
5174
5175
5176
5177
5178
5179

/*
** Release the lock held on the shared memory segment to that other
** threads are free to resize it if necessary.
*/
static int unixShmRelease(sqlite3_shm *pSharedMem){
  unixShm *p = (unixShm*)pSharedMem;

  unixShmFile *pFile = p->pFile;
  sqlite3_mutex_leave(pFile->mutexBuf);  


  return SQLITE_OK;
}

/*
** Symbolic names for LOCK states used for debugging.
*/
#ifdef SQLITE_DEBUG







>
|
|
>
>







5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185

/*
** Release the lock held on the shared memory segment to that other
** threads are free to resize it if necessary.
*/
static int unixShmRelease(sqlite3_shm *pSharedMem){
  unixShm *p = (unixShm*)pSharedMem;
  if( p->hasMutexBuf ){
    unixShmFile *pFile = p->pFile;
    sqlite3_mutex_leave(pFile->mutexBuf);
    p->hasMutexBuf = 0;
  }
  return SQLITE_OK;
}

/*
** Symbolic names for LOCK states used for debugging.
*/
#ifdef SQLITE_DEBUG