summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Increase leveldb version to 1.19.v1.19cmumford2016-08-112-2/+2
| | | | | | ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129930720
* A zippy change broke test assumptions about the size of compressed output.sanjay2016-07-061-6/+14
| | | | | | | Fix the tests by allowing more slop in zippy's behavior. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123432472
* fix problems in LevelDB's caching codem3b2016-07-062-35/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: LevelDB uses a cache (util/cache.h, util/cache.cc) of (key,value) pairs for two purposes: - a cache of (table, file handle) pairs - a cache of blocks The cache places the (key,value) pairs in a reference-counted wrapper. When it returns a value, it returns a reference to this wrapper. When the client has finished using the reference and its enclosed (key,value), it calls Release() to decrement the reference count. Each (key,value) pair has an associated resource usage. The cache maintains the sum of the usages of the elements it holds, and removes values as needed to keep the sum below a capacity threshold. It maintains an LRU list so that it will remove the least-recently used elements first. The max_open_files option to LevelDB sets the size of the cache of (table, file handle) pairs. The option is not used in any other way. The observed behaviour: If LevelDB at any time used more file handles concurrently than the cache size set via max_open_files, it attempted to reduce the number by evicting entries from the table cache. This could happen most easily during compaction, and if max_open_files was low. Because the handles were in use, their reference count did not drop to zero, and so the usage sum in the cache was not modified by the evictions. Subsequent Insert() calls returned valid handles, but their entries were immediately evicted from the cache, which though empty still acted as though full. As a result, there was effectively no caching, and the number of open file handles rose []ly until it hit system-imposed limits and the process died. If one set max_open_files lower, the cache was more likely to exhibit this beahviour, and cause the process to run out of file descriptors. That is, max_open_files acted in almost exactly the opposite manner from what was intended. The problems: 1. The cache kept all elements on its LRU list eligible for capacity eviction---even those with outstanding references from clients. This was ineffective in reducing resource consumption because there was an outstanding reference, guaranteeing that the items remained. A secondary issue was that there is no guarantee that these in-use items will be the last things reached in the LRU chain, which actually recorded "least-recently requested" rather than "least-recently used". 2. The sum of usages was decremented not when a (key,value) was evicted from the cache, but when its reference count went to zero. Thus, when things were removed from the cache, either by garbage collection or via Erase(), the usage sum was not necessarily decreased. This allowed the cache to act as though full when it was in fact not, reducing caching effectiveness, and leading to more resources being consumed---the opposite of what the evictions were intended to achieve. 3. (minor) The cache's clients insert items into it by first looking up the key, and inserting only if no value is found. Although the cache has an internal lock, the clients use no locking to ensure atomicity of the Lookup/Insert pair. (see table/table.cc: block_cache->Insert() and db/table_cache.cc: cache_->Insert()). Thus, if two threads Insert() at about the same time, they can both Lookup(), find nothing, and both Insert(). The second Insert() would evict the first value, leaving each thread with a handle on its own version of the data, and with the second version in the cache. It would be better if both threads ended up with a handle on the same (key,value) pair, which implies it must be the first item inserted. This suggests that Insert() should not replace an existing value. This can be made safe with current usage inside LeveDB itself, but this is not easy to change first because Cache is a public interface, so to change the semantics of an existing call might break things, second because Cache is an abstract virtual class, so adding a new abstract virtual method may break other implementations, and third, the new method "insert without replacing" cannot be implemented in terms of the existing methods, so cannot be implemented with a non-abstract default. But fortunately, the effects of this issue are minor, so this issue is not fixed by this change. The changes: The assumption in the fixes is that it is always better to cache entries unless removal from the cache would lead to deallocation. Cache entries now have an "in_cache" boolean indicating whether the cache has a reference on the entry. The only ways that this can become false without the entry being passed to its "deleter" are via Erase(), via Insert() when an element with a duplicate key is inserted, or on destruction of the cache. The cache now keeps two linked lists instead of one. All items in the cache are in one list or the other, and never both. Items still referenced by clients but erased from the cache are in neither list. The lists are: - in-use: contains the items currently referenced by clients, in no particular order. (This list is used for invariant checking. If we removed the check, elements that would otherwise be on this list could be left as disconnected singleton lists.) - LRU: contains the items not currently referenced by clients, in LRU order A new internal Ref() method increments the reference count. If incrementing from 1 to 2 for an item in the cache, it is moved from the LRU list to the in-use list. The Unref() call now moves things from the in-use list to the LRU list if the reference count falls to 1, and the item is in the cache. It no longer adjusts the usage sum. The usage sum now reflects only what is in the cache, rather than including still-referenced items that have been evicted. The LRU_Append() now takes a "list" parameter so that it can be used to append either to the LRU list or the in-use list. Lookup() is modified to use the new Ref() call, rather than adjusting the reference count and LRU chain directly. Insert() eviction code is also modified to adjust the usage sum and the in_cache boolean of the evicted elements. Some LevelDB tests assume that there will be no caching whatsoever if the cache size is set to zero, so this is handled as a special case. A new private method FinishErase() is factored out with the common code from where items are removed from the cache. Erase() is modified to adjust the usage sum and the in_cache boolean of the erased elements, and to use FinishErase(). Prune() is modified to use FinishErase() also, and to make use of the fact that the lru_ list now contains only items with reference count 1. - EvictionPolicy is modified to test that an entry with an outstanding handle is not evicted. This test fails with the old cache.cc. - A new test case UseExceedsCacheSize verifies that even when the cache is overfull of entries with outstanding handles, none are evicted. This test fails with the old cache.cc, and is the key issue that causes file descriptors to run out when the cache size is set too small. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123247237
* Fix LevelDB build when asserts are enabled in release builds. (#367)John Abd-El-Malek2016-04-151-2/+1
| | | | | | | | | | * Fix LevelDB build when asserts are enabled in release builds. BUG=https://bugs.chromium.org/p/chromium/issues/detail?id=603166 * fix * Add comment
* Change std::uint64_t to uint64_t (#354)Nicholas Westlake2016-04-121-2/+2
| | | -This fixes compile errors with default setup on RHEL 6 systems.
* This CL fixes a bug encountered when reading records from leveldb files that ↵mjwiacek2016-03-312-12/+40
| | | | | | | | | | | | | | | | | | | have been split, as in a [] input task split. Detailed description: Suppose an input split is generated between two leveldb record blocks and the preceding block ends with null padding. A reader that previously read at least 1 record within the first block (before encountering the padding) upon trying to read the next record, will successfully and correctly read the next logical record from the subsequent block, but will return a last record offset pointing to the padding in the first block. When this happened in a [], it resulted in duplicate records being handled at what appeared to be different offsets that were separated by only a few bytes. This behavior is only observed when at least 1 record was read from the first block before encountering the padding. If the initial offset for a reader was within the padding, the correct record offset would be reported, namely the offset within the second block. The tests failed to catch this scenario/bug, because each read test only read a single record with an initial offset. This CL adds an explicit test case for this scenario, and modifies the test structure to read all remaining records in the test case after an initial offset is specified. Thus an initial offset that jumps to record #3, with 5 total records in the test file, will result in reading 2 records, and validating the offset of each of them in order to pass successfully. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115338487
* Deleted redundant null ptr check prior to delete.cmumford2016-03-311-1/+1
| | | | | | | Fixes issue #338. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=113439460
* Merge pull request #348 from randomascii/masterChris Mumford2016-02-241-1/+1
|\ | | | | Fix signed/unsigned mismatch on VC++ builds
| * Fix signed/unsigned mismatch on VC++ buildsBruce Dawson2016-02-191-1/+1
|/
* Putting build artifacts in subdirectory.cmumford2016-01-293-145/+326
| | | | | | | | | | | | | | | | | | | 1. Object files, libraries, and compiled executables are put into subdirectories. 2. The shared library is linked from individual object files. This provides for greater parallelism on large desktops while at the same time making for easier builds on small (i.e. embedded) systems. Fixes issue #279. 3. One program, db_bench, is compiled using the shared library. 4. The source file for "leveldbutil" was renamed from leveldb_main.cc to leveldbutil.cc. This provides for simpler makefile rules. 5. Because all targets placed the library (libleveldb.a) at the top level, the last platform built (desktop/device) always overwrote any prior artifact. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=113407013
* Merge pull request #329 from ralphtheninja/travis-badgeChris Mumford2016-01-151-0/+2
|\ | | | | Add travis build badge to README
| * add travis build badgeLars-Magnus Skog2016-01-151-0/+2
|/
* Merge pull request #328 from cmumford/masterChris Mumford2016-01-141-0/+13
|\ | | | | Added a Travis CI build file.
| * Added a Travis CI build file.Chris Mumford2016-01-141-0/+13
|/ | | | | This allows for continuous integration builds by travis-ci.org. More information at https://docs.travis-ci.com/user/languages/cpp
* Merge pull request #284 from ideawu/masterChris Mumford2016-01-121-1/+2
|\ | | | | log compaction output file's level along with number
| * fix indentideawu2015-04-201-1/+1
| |
| * log compaction output file's level along with numberideawu2015-04-201-1/+2
| |
* | Merge pull request #317 from falvojr/patch-1Chris Mumford2016-01-121-1/+1
|\ \ | | | | | | Update README.md
| * | Update README.mdVenilton FalvoJr2015-11-231-1/+1
| |/
* | Merge pull request #272 from vapier/masterChris Mumford2016-01-121-0/+9
|\ \ | | | | | | Fix Android/MIPS build.
| * | Fix Android/MIPS build.David Turner2014-12-171-0/+9
| |/ | | | | | | | | port/atomic_pointer.h was missing an implementation for MemoryBarrier() for this platform.
* | Added a contributors section to README.mdcmumford2016-01-041-0/+31
| | | | | | | | | | | | | | | | | | In preparation for accepting GitHub pull requests this new README section outlines the general criteria that the leveldb project owners will use when accepting external (and internal) project contributions. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111349899
* | Merge pull request #275 from paulirish/patch-1Chris Mumford2015-12-091-1/+3
|\ \ | | | | | | readme: improved documentation link
| * | documentation. improved linkPaul Irish2015-02-171-1/+3
| | |
| * | readme: improved documentation linkPaul Irish2015-01-101-1/+1
| |/ | | | | | | This replaces htmlpreview with [rawgit](http://rawgit.com/). rawgit is faster and doesnt use JS to render the page, making it SEO friendly.
* | Resolve race when getting approximate-memory-usage propertyssid2015-12-093-12/+9
| | | | | | | | | | | | | | | | | | | | | | The write operations in the table happens without holding the mutex lock, but concurrent writes are avoided using "writers_" queue. The Arena::MemoryUsage could access the blocks when write happens. So, the memory usage is cached in atomic word and can be loaded from any thread safely. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=107573379
* | Only compiling TrimSpace on linux.cmumford2015-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | Incorporated change by zmodem at https://github.com/google/leveldb/pull/310 to fix issue #310. This change will only build TrimSace on linux to avoid unused function warning/error. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=105323419
* | Including atomic_pointer.h in port_posixcmumford2015-12-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent CL (104348226) created the port_posix library, but omitted: port/atomic_pointer.h. And when: [] test third_party/leveldb:all was run this error was reported: //third_party/leveldb:port_posix does not depend on a module exporting 'third_party/leveldb/port/atomic_pointer.h' ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=105243399
* | Let LevelDB use xcrun to determine Xcode.app path instead of using a ↵ndmatthews2015-12-091-8/+6
| | | | | | | | | | | | | | | | | | hardcoded path. This allows build agents to select from multiple Xcode installations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=104859097
* | Add "approximate-memory-usage" property to leveldb::DB::GetPropertyssid2015-12-095-1/+42
| | | | | | | | | | | | | | | | | | The approximate RAM usage of the database is calculated from the memory allocated for write buffers and the block cache. This is to give an estimate of memory usage to leveldb clients. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=104222307
* | Add leveldb::Cache::Prunetzik2015-12-093-0/+39
| | | | | | | | | | | | | | | | Prune() drops on-memory read cache of the database, so that the client can relief its memory shortage. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=101335710
* | Fix size_t/int comparison/conversion issues in leveldb.pkasting2015-12-093-4/+5
| | | | | | | | | | | | | | | | | | The create function took |num_keys| as an int, but callers and implementers wanted it to function as a size_t (e.g. passing std::vector::size() in, passing it to vector constructors as a size arg, indexing containers by it, etc.). This resulted in implicit conversions between the two types as well as warnings (found with Chromium's external copy of these sources, built with MSVC) about signed vs. unsigned comparisons. The leveldb sources were already widely using size_t elsewhere, e.g. for key and filter lengths, so using size_t here is not inconsistent with the existing code. However, it does change the public C API. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=101074871
* | Added leveldb::Status::IsInvalidArgument() method.cmumford2015-12-091-0/+3
| | | | | | | | | | | | | | | | All other Status::Code enum values have an Is**() method with the one exception of InvalidArgument. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=97166441
* | Suppress error reporting after seeking but before a valid First or Full ↵Mike Wiacek2015-12-093-7/+45
| | | | | | | | | | | | record is encountered. Fix a spelling mistake.
* | include <assert> -> <cassert>Chris Mumford2015-12-091-1/+1
| | | | | | | | Fixes reported public issue #280.
* | Will not reuse manifest if reuse_logs options is false.Chris Mumford2015-08-111-0/+3
| | | | | | | | | | | | | | Prior implementation would always try to reuse the manifest, even if reuse_logs was false (the default). This was missed because the stock Env::NewAppendableFile implementation returns false forcing the creation of a new log.
* | LevelDB now attempts to reuse the preceding MANIFEST and log file when ↵Sanjay Ghemawat2015-08-1122-155/+707
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-opened. (Based on a suggestion by cmumford.) "open" benchmark on my workstation speeds up significantly since we can now avoid three fdatasync calls and a compaction per open: Before: ~80000 microseconds After: ~130 microseconds Details: (1) Added Options::reuse_logs (currently defaults to false) to control new behavior. The intention is to change the default to true after some baking. (2) Added Env::NewAppendableFile() whose default implementation returns a not-supported error. (3) VersionSet::Recovery attempts to reuse the MANIFEST from which it is recovering. (4) DBImpl recovery attempts to reuse the last log file and memtable. (5) db_test.cc now tests a new configuration that sets reuse_logs to true. (6) fault_injection_test also tests a reuse_logs==true config. (7) Added a new recovery_test.
* Add benchmark that measures cost of repeatedly opening the database.Sanjay Ghemawat2014-12-111-1/+14
|
* Move header guard below copyright banner.Chris Mumford2014-12-111-4/+4
|
* Clean up layering of storage/leveldb/...Chris Mumford2014-12-113-0/+5
| | | | | With these changes, this package should be properly cleaned up and not require any further changes.
* Added a new fault injection test.Chris Mumford2014-12-112-0/+546
| | | | | This test is intended to ensure leveldb properly detects and recovers from faults - specifically unwritten file data lost as a result of a system reset.
* Add arm64 support to leveldb.Chris Mumford2014-12-111-0/+10
|
* Fixed incorrect comment wording for Iterator::Seek.Chris Mumford2014-12-111-1/+1
|
* Deleted old README file.Chris Mumford2014-12-111-51/+0
| | | | README was superseded by README.md and should have been deleted in 803d692.
* Release 1.18v1.18Chris Mumford2014-09-1640-282/+602
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
* Release LevelDB 1.17v1.171.17Chris Mumford2014-05-014-21/+8
| | | | | | | | | | | | | | | | | - Cleanup: delete unused IntSetToString It was added in http://cr/19491949 (and was referenced at the time). The last reference was removed in http://cr/19507363. This fixes warning/error with pre-release crosstoolv18: 'std::string leveldb::{anonymous}::IntSetToString(const std::set<long unsigned int>&)' defined but not used [-Werror=unused-function] - Added arm64 and and armv7s to IOS build as suggested on leveldb mailing list. - Changed local variable type from int to size_t This eliminates compiler warning/error and resolves https://code.google.com/p/leveldb/issues/detail?id=140
* Release LevelDB 1.16v1.16David Grogan2014-02-106-17/+52
| | | | | | | - Make Log::Reader not report a corruption when the last record in a log file is truncated. - Fix issue 224: variable created but not utilized. - Remove comment that referenced a removed feature.
* Release LevelDB 1.15v1.15David Grogan2013-12-1022-361/+320
| | | | | | | | | | | | | | | | | | | - switched from mmap based writing to simpler stdio based writing. Has a minor impact (0.5 microseconds) on microbenchmarks for asynchronous writes. Synchronous writes speed up from 30ms to 10ms on linux/ext4. Should be much more reliable on diverse platforms. - compaction errors now immediately put the database into a read-only mode (until it is re-opened). As a downside, a disk going out of space and then space being created will require a re-open to recover from, whereas previously that would happen automatically. On the plus side, many corruption possibilities go away. - force the DB to enter an error-state so that all future writes fail when a synchronous log write succeeds but the sync fails. - repair now regenerates sstables that exhibit problems - fix issue 218 - Use native memory barriers on OSX - fix issue 212 - QNX build is broken - fix build on iOS with xcode 5 - make tests compile and pass on windows
* Release LevelDB 1.14v1.14David Grogan2013-09-1913-13/+137
| | | | | | | | | | | Fix issues 200, 201 Also, * Fix link to bigtable paper in docs. * New sstables will have the file extension .ldb. .sst files will continue to be recognized. * When building for iOS, use xcrun to execute the compiler. This may affect issue 177.
* LevelDB 1.13v1.13David Grogan2013-08-2113-67/+363
| | | | | | | | | | | | Fix issues 77, 87, 182, 190. Additionally, fix the bug described in https://groups.google.com/d/msg/leveldb/yL6h1mAOc20/vLU64RylIdMJ where a large contiguous keyspace of deleted data was not getting compacted. Also fix a bug where options.max_open_files was not getting clamped properly.