Changeset 249729 in webkit


Ignore:
Timestamp:
Sep 10, 2019 12:42:30 PM (5 years ago)
Author:
sihui_liu@apple.com
Message:

IndexedDB: cache prepared SQLiteStatement in SQLiteIDBCursor
https://bugs.webkit.org/show_bug.cgi?id=201548

Reviewed by Alex Christensen.

This should be a performance improvement as we don't compile the same SQLiteStatement everytime it is used.

No new tests, no behavior change.

  • Modules/indexeddb/server/SQLiteIDBCursor.cpp:

(WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):

  • Modules/indexeddb/server/SQLiteIDBCursor.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249722 r249729  
     12019-09-10  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: cache prepared SQLiteStatement in SQLiteIDBCursor
     4        https://bugs.webkit.org/show_bug.cgi?id=201548
     5
     6        Reviewed by Alex Christensen.
     7
     8        This should be a performance improvement as we don't compile the same SQLiteStatement everytime it is used.
     9
     10        No new tests, no behavior change.
     11
     12        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
     13        (WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
     14        * Modules/indexeddb/server/SQLiteIDBCursor.h:
     15
    1162019-09-10  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp

    r248846 r249729  
    473473        }
    474474
    475         SQLiteStatement objectStoreStatement(m_statement->database(), "SELECT value FROM Records WHERE key = CAST(? AS TEXT) and objectStoreID = ?;");
    476 
    477         if (objectStoreStatement.prepare() != SQLITE_OK
    478             || objectStoreStatement.bindBlob(1, keyData.data(), keyData.size()) != SQLITE_OK
    479             || objectStoreStatement.bindInt64(2, m_objectStoreID) != SQLITE_OK) {
     475        if (!m_cachedObjectStoreStatement || m_cachedObjectStoreStatement->reset() != SQLITE_OK) {
     476            m_cachedObjectStoreStatement = makeUnique<SQLiteStatement>(m_statement->database(), "SELECT value FROM Records WHERE key = CAST(? AS TEXT) and objectStoreID = ?;");
     477            if (m_cachedObjectStoreStatement->prepare() != SQLITE_OK)
     478                m_cachedObjectStoreStatement = nullptr;
     479        }
     480
     481        if (!m_cachedObjectStoreStatement
     482            || m_cachedObjectStoreStatement->bindBlob(1, keyData.data(), keyData.size()) != SQLITE_OK
     483            || m_cachedObjectStoreStatement->bindInt64(2, m_objectStoreID) != SQLITE_OK) {
    480484            LOG_ERROR("Could not create index cursor statement into object store records (%i) '%s'", m_statement->database().lastError(), m_statement->database().lastErrorMsg());
    481485            markAsErrored(record);
     
    483487        }
    484488
    485         int result = objectStoreStatement.step();
     489        int result = m_cachedObjectStoreStatement->step();
    486490
    487491        if (result == SQLITE_ROW) {
    488             objectStoreStatement.getColumnBlobAsVector(0, keyData);
     492            m_cachedObjectStoreStatement->getColumnBlobAsVector(0, keyData);
    489493            record.record.value = makeUnique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)));
    490494        } else if (result == SQLITE_DONE) {
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h

    r244436 r249729  
    124124
    125125    std::unique_ptr<SQLiteStatement> m_statement;
     126    std::unique_ptr<SQLiteStatement> m_cachedObjectStoreStatement;
     127
    126128    bool m_statementNeedsReset { true };
    127129    int64_t m_boundID { 0 };
Note: See TracChangeset for help on using the changeset viewer.