diff options
author | zhaoqin <zhaoqin@chromium.org> | 2015-09-30 11:04:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-30 18:05:20 +0000 |
commit | 745e18c523846de216c2f2253beb4e8047f77e57 (patch) | |
tree | a8c43a082280c59e1a2abe79015d358db1b5f175 /sql/connection_unittest.cc | |
parent | 493d992af78670f99743bb5458c8d7b6019dbb72 (diff) | |
download | chromium_src-745e18c523846de216c2f2253beb4e8047f77e57.zip chromium_src-745e18c523846de216c2f2253beb4e8047f77e57.tar.gz chromium_src-745e18c523846de216c2f2253beb4e8047f77e57.tar.bz2 |
Revert of [sql] Use memory-mapped I/O for sql::Connection. (patchset #3 id:40001 of https://codereview.chromium.org/1368533003/ )
Reason for revert:
data race reported by TSan on sql/connection.cc
BUG=537681
Original issue's description:
> [sql] Use memory-mapped I/O for sql::Connection.
>
> sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
> memory-mapped I/O. Additionally instrument to flush dirty pages from
> the page cache after writes.
>
> [Relands https://crrev.com/9a1948a4d6d4,
> reverted at https://crrev.com/55c3216b15ce ]
>
> BUG=489784, 533682
>
> Committed: https://crrev.com/5c2f4e50d96d8b2ae0ae4a5c7d319e6be3b33bca
> Cr-Commit-Position: refs/heads/master@{#351344}
TBR=rmcilroy@chromium.org,pavely@chromium.org,shess@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=489784, 533682
Review URL: https://codereview.chromium.org/1375583003
Cr-Commit-Position: refs/heads/master@{#351596}
Diffstat (limited to 'sql/connection_unittest.cc')
-rw-r--r-- | sql/connection_unittest.cc | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc index 0038a1d..10a15a8 100644 --- a/sql/connection_unittest.cc +++ b/sql/connection_unittest.cc @@ -4,12 +4,10 @@ #include "base/bind.h" #include "base/files/file_util.h" -#include "base/files/memory_mapped_file.h" #include "base/files/scoped_file.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/metrics/statistics_recorder.h" -#include "base/strings/stringprintf.h" #include "base/test/histogram_tester.h" #include "sql/connection.h" #include "sql/correct_sql_test_base.h" @@ -1300,82 +1298,4 @@ TEST_F(SQLConnectionTest, TimeUpdateTransaction) { EXPECT_EQ(0, samples->sum()); } -// Make sure that OS file writes to a mmap'ed file are reflected in the memory -// mapping of a memory-mapped file. Normally SQLite writes to memory-mapped -// files using memcpy(), which should stay consistent. Our SQLite is slightly -// patched to mmap read only, then write using OS file writes. If the -// memory-mapped version doesn't reflect the OS file writes, SQLite's -// memory-mapped I/O should be disabled on this platform. -#if !defined(MOJO_APPTEST_IMPL) -TEST_F(SQLConnectionTest, MmapTest) { - // Skip the test for platforms which don't enable memory-mapped I/O in SQLite, - // or which don't even support the pragma. The former seems to apply to iOS, - // the latter to older iOS. - // TODO(shess): Disable test on iOS? Disable on USE_SYSTEM_SQLITE? - { - sql::Statement s(db().GetUniqueStatement("PRAGMA mmap_size")); - if (!s.Step() || !s.ColumnInt64(0)) - return; - } - - // The test re-uses the database file to make sure it's representative of a - // SQLite file, but will be storing incompatible data. - db().Close(); - - const uint32 kFlags = - base::File::FLAG_OPEN|base::File::FLAG_READ|base::File::FLAG_WRITE; - char buf[4096]; - - // Create a file with a block of '0', a block of '1', and a block of '2'. - { - base::File f(db_path(), kFlags); - ASSERT_TRUE(f.IsValid()); - memset(buf, '0', sizeof(buf)); - ASSERT_EQ(f.Write(0*sizeof(buf), buf, sizeof(buf)), (int)sizeof(buf)); - - memset(buf, '1', sizeof(buf)); - ASSERT_EQ(f.Write(1*sizeof(buf), buf, sizeof(buf)), (int)sizeof(buf)); - - memset(buf, '2', sizeof(buf)); - ASSERT_EQ(f.Write(2*sizeof(buf), buf, sizeof(buf)), (int)sizeof(buf)); - } - - // mmap the file and verify that everything looks right. - { - base::MemoryMappedFile m; - ASSERT_TRUE(m.Initialize(db_path())); - - memset(buf, '0', sizeof(buf)); - ASSERT_EQ(0, memcmp(buf, m.data() + 0*sizeof(buf), sizeof(buf))); - - memset(buf, '1', sizeof(buf)); - ASSERT_EQ(0, memcmp(buf, m.data() + 1*sizeof(buf), sizeof(buf))); - - memset(buf, '2', sizeof(buf)); - ASSERT_EQ(0, memcmp(buf, m.data() + 2*sizeof(buf), sizeof(buf))); - - // Scribble some '3' into the first page of the file, and verify that it - // looks the same in the memory mapping. - { - base::File f(db_path(), kFlags); - ASSERT_TRUE(f.IsValid()); - memset(buf, '3', sizeof(buf)); - ASSERT_EQ(f.Write(0*sizeof(buf), buf, sizeof(buf)), (int)sizeof(buf)); - } - ASSERT_EQ(0, memcmp(buf, m.data() + 0*sizeof(buf), sizeof(buf))); - - // Repeat with a single '4' in case page-sized blocks are different. - const size_t kOffset = 1*sizeof(buf) + 123; - ASSERT_NE('4', m.data()[kOffset]); - { - base::File f(db_path(), kFlags); - ASSERT_TRUE(f.IsValid()); - buf[0] = '4'; - ASSERT_EQ(f.Write(kOffset, buf, 1), 1); - } - ASSERT_EQ('4', m.data()[kOffset]); - } -} -#endif - } // namespace |