Loading apct-tests/perftests/core/src/android/database/SQLiteDatabasePerfTest.java +0 −5 Original line number Diff line number Diff line Loading @@ -141,11 +141,6 @@ public class SQLiteDatabasePerfTest { } } Log.d("testSelectMemory", "cacheMissRate: " + mDatabase.getStatementCacheMissRate() + "Total Statements: " + mDatabase.getTotalPreparedStatements() + ". Misses: " + mDatabase.getTotalStatementCacheMisses()); // Make sure caching is working and our miss rate should definitely be less than 100% // however, we would expect this number to be actually closer to 0. assertTrue(mDatabase.getStatementCacheMissRate() < 1); Loading core/java/android/database/sqlite/SQLiteConnection.java +15 −5 Original line number Diff line number Diff line Loading @@ -1080,7 +1080,6 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen * Return a {@link #PreparedStatement}, possibly from the cache. */ private PreparedStatement acquirePreparedStatementLI(String sql) { ++mPool.mTotalPrepareStatements; PreparedStatement statement = mPreparedStatementCache.getStatement(sql); long seqNum = mPreparedStatementCache.getLastSeqNum(); Loading @@ -1105,7 +1104,6 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen skipCache = true; } } ++mPool.mTotalPrepareStatementCacheMiss; final long statementPtr = mPreparedStatementCache.createStatement(sql); seqNum = mPreparedStatementCache.getLastSeqNum(); try { Loading Loading @@ -1441,9 +1439,21 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen } else { label = mConfiguration.path + " (" + mConnectionId + ")"; } return new DbStats(label, pageCount, pageSize, lookaside, mPreparedStatementCache.hitCount(), mPreparedStatementCache.missCount(), mPreparedStatementCache.size(), false); DbStats dbStats = new DbStats(label, pageCount, pageSize, lookaside, 0, 0, 0, false); dbStats.addCacheStatsFrom(this); return dbStats; } int getPreparedStatementCacheHitCount() { return mPreparedStatementCache.hitCount(); } int getPreparedStatementCacheMissCount() { return mPreparedStatementCache.missCount(); } int getPreparedStatementCacheSize() { return mPreparedStatementCache.size(); } @Override Loading core/java/android/database/sqlite/SQLiteConnectionPool.java +22 −10 Original line number Diff line number Diff line Loading @@ -109,10 +109,6 @@ public final class SQLiteConnectionPool implements Closeable { new ArrayList<SQLiteConnection>(); private SQLiteConnection mAvailablePrimaryConnection; // Prepare statement cache statistics public int mTotalPrepareStatementCacheMiss = 0; public int mTotalPrepareStatements = 0; @GuardedBy("mLock") private IdleConnectionHandler mIdleConnectionHandler; Loading Loading @@ -528,9 +524,15 @@ public final class SQLiteConnectionPool implements Closeable { } // Global pool stats DbStats poolStats = new DbStats(mConfiguration.path, 0, 0, 0, mTotalPrepareStatements - mTotalPrepareStatementCacheMiss, mTotalPrepareStatementCacheMiss, mTotalPrepareStatements, true); DbStats poolStats = new DbStats(mConfiguration.path, 0, 0, 0, 0, 0, 0, true); if (mAvailablePrimaryConnection != null) { poolStats.addCacheStatsFrom(mAvailablePrimaryConnection); } for (SQLiteConnection connection : mAvailableNonPrimaryConnections) { poolStats.addCacheStatsFrom(connection); } dbStatsList.add(poolStats); } } Loading Loading @@ -1246,11 +1248,21 @@ public final class SQLiteConnectionPool implements Closeable { /** @hide */ @NeverCompile public double getStatementCacheMissRate() { if (mTotalPrepareStatements == 0) { // no statements executed thus no miss rate. int cacheHits = 0; int cacheMisses = 0; if (mAvailablePrimaryConnection != null) { cacheHits += mAvailablePrimaryConnection.getPreparedStatementCacheHitCount(); cacheMisses += mAvailablePrimaryConnection.getPreparedStatementCacheMissCount(); } for (SQLiteConnection connection : mAvailableNonPrimaryConnections) { cacheHits += connection.getPreparedStatementCacheHitCount(); cacheMisses += connection.getPreparedStatementCacheMissCount(); } if (cacheMisses == 0) { return 0; } return (double) mTotalPrepareStatementCacheMiss / (double) mTotalPrepareStatements; return (double) cacheMisses / (double) (cacheHits + cacheMisses); } public long getTotalStatementsTime() { Loading core/java/android/database/sqlite/SQLiteDatabase.java +0 −16 Original line number Diff line number Diff line Loading @@ -2725,22 +2725,6 @@ public final class SQLiteDatabase extends SQLiteClosable { return connectionPools; } /** @hide */ @NeverCompile public int getTotalPreparedStatements() { throwIfNotOpenLocked(); return mConnectionPoolLocked.mTotalPrepareStatements; } /** @hide */ @NeverCompile public int getTotalStatementCacheMisses() { throwIfNotOpenLocked(); return mConnectionPoolLocked.mTotalPrepareStatementCacheMiss; } /** * Dump detailed information about all open databases in the current process. * Used by bug report. Loading core/java/android/database/sqlite/SQLiteDebug.java +9 −3 Original line number Diff line number Diff line Loading @@ -182,11 +182,11 @@ public final class SQLiteDebug { public int lookaside; /** @hide */ final public int cacheHits; public int cacheHits; /** @hide */ final public int cacheMisses; public int cacheMisses; /** @hide */ final public int cacheSize; public int cacheSize; /** true if connection specific stats or whole connection pool if false */ public final boolean arePoolStats; Loading @@ -202,6 +202,12 @@ public final class SQLiteDebug { this.cacheSize = cachesize; this.arePoolStats = arePoolStats; } void addCacheStatsFrom(SQLiteConnection connection) { cacheHits += connection.getPreparedStatementCacheHitCount(); cacheMisses += connection.getPreparedStatementCacheMissCount(); cacheSize += connection.getPreparedStatementCacheSize(); } } /** Loading Loading
apct-tests/perftests/core/src/android/database/SQLiteDatabasePerfTest.java +0 −5 Original line number Diff line number Diff line Loading @@ -141,11 +141,6 @@ public class SQLiteDatabasePerfTest { } } Log.d("testSelectMemory", "cacheMissRate: " + mDatabase.getStatementCacheMissRate() + "Total Statements: " + mDatabase.getTotalPreparedStatements() + ". Misses: " + mDatabase.getTotalStatementCacheMisses()); // Make sure caching is working and our miss rate should definitely be less than 100% // however, we would expect this number to be actually closer to 0. assertTrue(mDatabase.getStatementCacheMissRate() < 1); Loading
core/java/android/database/sqlite/SQLiteConnection.java +15 −5 Original line number Diff line number Diff line Loading @@ -1080,7 +1080,6 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen * Return a {@link #PreparedStatement}, possibly from the cache. */ private PreparedStatement acquirePreparedStatementLI(String sql) { ++mPool.mTotalPrepareStatements; PreparedStatement statement = mPreparedStatementCache.getStatement(sql); long seqNum = mPreparedStatementCache.getLastSeqNum(); Loading @@ -1105,7 +1104,6 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen skipCache = true; } } ++mPool.mTotalPrepareStatementCacheMiss; final long statementPtr = mPreparedStatementCache.createStatement(sql); seqNum = mPreparedStatementCache.getLastSeqNum(); try { Loading Loading @@ -1441,9 +1439,21 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen } else { label = mConfiguration.path + " (" + mConnectionId + ")"; } return new DbStats(label, pageCount, pageSize, lookaside, mPreparedStatementCache.hitCount(), mPreparedStatementCache.missCount(), mPreparedStatementCache.size(), false); DbStats dbStats = new DbStats(label, pageCount, pageSize, lookaside, 0, 0, 0, false); dbStats.addCacheStatsFrom(this); return dbStats; } int getPreparedStatementCacheHitCount() { return mPreparedStatementCache.hitCount(); } int getPreparedStatementCacheMissCount() { return mPreparedStatementCache.missCount(); } int getPreparedStatementCacheSize() { return mPreparedStatementCache.size(); } @Override Loading
core/java/android/database/sqlite/SQLiteConnectionPool.java +22 −10 Original line number Diff line number Diff line Loading @@ -109,10 +109,6 @@ public final class SQLiteConnectionPool implements Closeable { new ArrayList<SQLiteConnection>(); private SQLiteConnection mAvailablePrimaryConnection; // Prepare statement cache statistics public int mTotalPrepareStatementCacheMiss = 0; public int mTotalPrepareStatements = 0; @GuardedBy("mLock") private IdleConnectionHandler mIdleConnectionHandler; Loading Loading @@ -528,9 +524,15 @@ public final class SQLiteConnectionPool implements Closeable { } // Global pool stats DbStats poolStats = new DbStats(mConfiguration.path, 0, 0, 0, mTotalPrepareStatements - mTotalPrepareStatementCacheMiss, mTotalPrepareStatementCacheMiss, mTotalPrepareStatements, true); DbStats poolStats = new DbStats(mConfiguration.path, 0, 0, 0, 0, 0, 0, true); if (mAvailablePrimaryConnection != null) { poolStats.addCacheStatsFrom(mAvailablePrimaryConnection); } for (SQLiteConnection connection : mAvailableNonPrimaryConnections) { poolStats.addCacheStatsFrom(connection); } dbStatsList.add(poolStats); } } Loading Loading @@ -1246,11 +1248,21 @@ public final class SQLiteConnectionPool implements Closeable { /** @hide */ @NeverCompile public double getStatementCacheMissRate() { if (mTotalPrepareStatements == 0) { // no statements executed thus no miss rate. int cacheHits = 0; int cacheMisses = 0; if (mAvailablePrimaryConnection != null) { cacheHits += mAvailablePrimaryConnection.getPreparedStatementCacheHitCount(); cacheMisses += mAvailablePrimaryConnection.getPreparedStatementCacheMissCount(); } for (SQLiteConnection connection : mAvailableNonPrimaryConnections) { cacheHits += connection.getPreparedStatementCacheHitCount(); cacheMisses += connection.getPreparedStatementCacheMissCount(); } if (cacheMisses == 0) { return 0; } return (double) mTotalPrepareStatementCacheMiss / (double) mTotalPrepareStatements; return (double) cacheMisses / (double) (cacheHits + cacheMisses); } public long getTotalStatementsTime() { Loading
core/java/android/database/sqlite/SQLiteDatabase.java +0 −16 Original line number Diff line number Diff line Loading @@ -2725,22 +2725,6 @@ public final class SQLiteDatabase extends SQLiteClosable { return connectionPools; } /** @hide */ @NeverCompile public int getTotalPreparedStatements() { throwIfNotOpenLocked(); return mConnectionPoolLocked.mTotalPrepareStatements; } /** @hide */ @NeverCompile public int getTotalStatementCacheMisses() { throwIfNotOpenLocked(); return mConnectionPoolLocked.mTotalPrepareStatementCacheMiss; } /** * Dump detailed information about all open databases in the current process. * Used by bug report. Loading
core/java/android/database/sqlite/SQLiteDebug.java +9 −3 Original line number Diff line number Diff line Loading @@ -182,11 +182,11 @@ public final class SQLiteDebug { public int lookaside; /** @hide */ final public int cacheHits; public int cacheHits; /** @hide */ final public int cacheMisses; public int cacheMisses; /** @hide */ final public int cacheSize; public int cacheSize; /** true if connection specific stats or whole connection pool if false */ public final boolean arePoolStats; Loading @@ -202,6 +202,12 @@ public final class SQLiteDebug { this.cacheSize = cachesize; this.arePoolStats = arePoolStats; } void addCacheStatsFrom(SQLiteConnection connection) { cacheHits += connection.getPreparedStatementCacheHitCount(); cacheMisses += connection.getPreparedStatementCacheMissCount(); cacheSize += connection.getPreparedStatementCacheSize(); } } /** Loading