aboutsummaryrefslogtreecommitdiff
path: root/db_test.go (unfollow)
Commit message (Collapse)AuthorFilesLines
2016-12-23Allow GC to reclaim completed transactionsJosh Bleecher Snyder1-1/+4
The existing append-based implementation left a hanging reference to the last tx. For example, if db.txs was: []*Tx{0x1, 0x2, 0x3, 0x4, 0x5} and we removed the second element, db.txs would now be: []*Tx{0x1, 0x3, 0x4, 0x5, 0x5}[:4] The garbage collector cannot reclaim anything anywhere in a slice, even pointers between its len and cap, because the len can always be extended up to the cap. This hanging reference to the Tx could last indefinitely, and since the Tx has a reference to user-provided functions, which could be closures, this bug could prevent arbitrary amounts of user garbage from being collected. Since db.txs is unordered anyway, switch to a simpler--and O(1) instead of O(n)--implementation. Swap the last element into the spot to be deleted, nil out the original last element, and shrink the slice.
2016-12-23Fix freelist.size calculation for large freelistsJosh Bleecher Snyder1-1/+6
freelist.size did not account for the extra fake freelist item used to hold the number of elements when the freelist is large.
2016-12-23Precalculate size of pending pgids in freelist.copyallJosh Bleecher Snyder1-1/+1
This recovers the slight alloc regression in #636.
2016-12-23Clean up after #636Josh Bleecher Snyder3-14/+5
freelist.lenall duplicated freelist.count. freelist.copyall and mergepgids docs had typos.
2016-12-21READMEBen Johnson1-0/+3
Add limitation about multiple processes opening databases concurrently.
2016-12-20Don't allocate huge slices to merge pgids in freelist.writeJosh Bleecher Snyder3-20/+49
Using a large (50gb) database with a read-write-delete heavy load, nearly 100% of allocated space came from freelists. 1/3 came from freelist.release, 1/3 from freelist.write, and 1/3 came from tx.allocate to make space for freelist.write. In the case of freelist.write, the newly allocated giant slice gets copied to the space prepared by tx.allocate and then discarded. To avoid this, add func mergepgids that accepts a destination slice, and use it in freelist.write. This has a mild negative impact on the existing benchmarks, but cuts allocated space in my real world db by over 30%. name old time/op new time/op delta _FreelistRelease10K-8 18.7µs ±10% 18.2µs ± 4% ~ (p=0.548 n=5+5) _FreelistRelease100K-8 233µs ± 5% 258µs ±20% ~ (p=0.151 n=5+5) _FreelistRelease1000K-8 3.34ms ± 8% 3.13ms ± 8% ~ (p=0.151 n=5+5) _FreelistRelease10000K-8 32.3ms ± 1% 32.2ms ± 7% ~ (p=0.690 n=5+5) DBBatchAutomatic-8 2.18ms ± 3% 2.19ms ± 4% ~ (p=0.421 n=5+5) DBBatchSingle-8 140ms ± 6% 140ms ± 4% ~ (p=0.841 n=5+5) DBBatchManual10x100-8 4.41ms ± 2% 4.37ms ± 3% ~ (p=0.548 n=5+5) name old alloc/op new alloc/op delta _FreelistRelease10K-8 82.5kB ± 0% 82.5kB ± 0% ~ (all samples are equal) _FreelistRelease100K-8 805kB ± 0% 805kB ± 0% ~ (all samples are equal) _FreelistRelease1000K-8 8.05MB ± 0% 8.05MB ± 0% ~ (all samples are equal) _FreelistRelease10000K-8 80.4MB ± 0% 80.4MB ± 0% ~ (p=1.000 n=5+5) DBBatchAutomatic-8 384kB ± 0% 384kB ± 0% ~ (p=0.095 n=5+5) DBBatchSingle-8 17.2MB ± 1% 17.2MB ± 1% ~ (p=0.310 n=5+5) DBBatchManual10x100-8 908kB ± 0% 902kB ± 1% ~ (p=0.730 n=4+5) name old allocs/op new allocs/op delta _FreelistRelease10K-8 5.00 ± 0% 5.00 ± 0% ~ (all samples are equal) _FreelistRelease100K-8 5.00 ± 0% 5.00 ± 0% ~ (all samples are equal) _FreelistRelease1000K-8 5.00 ± 0% 5.00 ± 0% ~ (all samples are equal) _FreelistRelease10000K-8 5.00 ± 0% 5.00 ± 0% ~ (all samples are equal) DBBatchAutomatic-8 10.2k ± 0% 10.2k ± 0% +0.07% (p=0.032 n=5+5) DBBatchSingle-8 58.6k ± 0% 59.6k ± 0% +1.70% (p=0.008 n=5+5) DBBatchManual10x100-8 6.02k ± 0% 6.03k ± 0% +0.17% (p=0.029 n=4+4)
2016-12-06Fix prefix scan exampleBjørn Erik Pedersen1-1/+1
The example is correct in isolation, but if people just copy the loop, it will go into infinite loop when given an empty byte slice.
2016-11-20Added BoltHold and Ironsmith to the projects listTim Shannon1-0/+2
2016-11-16replace unix implementation to be the same as solaris to fix an issue with ↵Ben Aldrich1-7/+17
glusterfs
2016-11-09Make wording a little less redundant.John C. Vernaleo1-2/+2
2016-11-08Add btcwallet and dcrwallet to projects using bolt.John C. Vernaleo1-0/+2
2016-11-04[ppc64] added missing variabletbe1-0/+3
The variable `brokenUnaligned` was missing for ppc64.
2016-10-31Fix return statement inside else block at the end of function and gofmt ↵nick2-3/+2
windows file Signed-off-by: nick <nicholasjamesrusso@gmail.com>
2016-10-28enhc: update example for nested bucketsJared Folkins1-0/+49
2016-10-18Add 'bolter' to the list of projects that use BoltHasit Mistry1-0/+1
[bolter](https://github.com/hasit/bolter) is a command-line app for viewing BoltDB file in your terminal using [tablewriter](https://github.com/olekukonko/tablewriter).
2016-10-07fix typo in README.mdDenis Andrejew1-1/+1
2016-10-05Add gopherpit to projects that use BoltJanoš Guljaš1-0/+1
2016-10-03Fix Stats.Sub() for Stats.TxN.Ben Johnson1-1/+1
The subtraction for `TxN` was previously transposed which caused the result to be a negative number. This change alters the order to return the correct (positive) result.
2016-09-13Update README.mdRoman Naumann1-0/+4
Add warning to README.md that keys and values in `ForEach()` are invalid outside of transaction.
2016-09-08READMEBen Johnson1-5/+5
Added note to README that the file format is fixed.
2016-09-05Minor bolt compact revisionsBen Johnson4-113/+196
2016-09-05Lower number of allocation in freelist.reindex()Nikita Vetoshkin1-1/+1
Here is a profile taken etcd. Before: 10924 10924 (flat, cum) 4.99% of Total . . 230: . . 231:// reindex rebuilds the free cache based on available and pending free lists. . . 232:func (f *freelist) reindex() { . . 233: f.cache = make(map[pgid]bool) . . 234: for _, id := range f.ids { 10924 10924 235: f.cache[id] = true . . 236: } . . 237: for _, pendingIDs := range f.pending { . . 238: for _, pendingID := range pendingIDs { . . 239: f.cache[pendingID] = true . . 240: } After: 1 1 (flat, cum) 0.0017% of Total . . 228: f.reindex() . . 229: } . . 230: . . 231:// reindex rebuilds the free cache based on available and pending free lists. . . 232:func (f *freelist) reindex() { 1 1 233: f.cache = make(map[pgid]bool, len(f.ids)) . . 234: for _, id := range f.ids { . . 235: f.cache[id] = true . . 236: } . . 237: for _, pendingIDs := range f.pending { . . 238: for _, pendingID := range pendingIDs {
2016-09-02Update README.mdMatt Joiner1-0/+1
Add anacrolix/torrent to users.
2016-08-18fix Go 1.7 pointer reference bugBen Johnson3-6/+23
This commit fixes a bug where page end-of-header pointers were being converted to byte slices even when the pointer did not point to allocated memory. This occurs with pages that have a `page.count` of zero. Note: This was not an issue in Go 1.6 but the new Go 1.7 SSA backend handles `nil` checks differently. See https://github.com/golang/go/issues/16772
2016-07-30Update description of project using BoltDBAsdine El Hrychy1-1/+1
2016-07-28bucket: correct broken unaligned load/store in armv5Lorenzo Stoakes7-1/+45
armv5 devices and older (i.e. <= arm9 generation) require addresses that are stored to and loaded from to to be 4-byte aligned. If this is not the case the lower 2 bits of the address are cleared and the load is performed in an unexpected order, including up to 3 bytes of data located prior to the address. Inlined buckets are stored after their key in a page and since there is no guarantee that the key will be of a length that is a multiple of 4, it is possible for unaligned load/stores to occur when they are cast back to bucket and page pointer types. The fix adds a new field to track whether the current architecture exhibits this issue, sets it on module load for ARM architectures, and then on bucket open, if this field is set and the address is unaligned, a byte-by-byte copy of the inlined bucket is performed. Ref: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html
2016-07-22Fix typo (Tx -> DB)Bouke van der Bijl1-1/+1
2016-07-17added a BoltDB related projectAvinash D'Silva1-0/+1
2016-06-17Fixes build error in README codeemersion1-1/+1
2016-06-16Remove skydb of the READMEIvan Fraixedes1-1/+0
I think that SkyDB is over, I could find any link to the project.
2016-06-12Added new project which is using BoldDBPankaj khairnar1-0/+1
2016-06-07READMEBen Johnson1-1/+1
2016-06-03Fixed typo in READMEJoe Farrell1-1/+1
2016-05-26Add MuLiFS to the list of projects using Bolt.Danko Miocevic1-0/+1
2016-05-18task#560 print leaf k/v with right valuestone13420061-2/+2
2016-05-04Add SimpleBolt and AlgernonAlexander F Rødseth1-0/+2
2016-04-24add additional meta page testsBen Johnson3-49/+71
2016-04-22move page pool to dbBen Johnson2-13/+20
2016-04-20db: fix recovery from unsynced metadataAleksa Sarai1-11/+38
Bolt stores the two latest transactions' metadata, but previously did not recover from validation failures in the latest by using the second latest. Fix this by correctly handling validation failures in db.go, as well as returning the metadata with highest txid which is also valid in DB.meta(). Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-04-07Wait to clear db.path until just before db.close returns.Chris Hines1-3/+3
The Windows version of funlock needs the db.path to delete the corresponding .lock file.
2016-03-25Update README.mdJoseph Spurrier1-0/+1
Added GoWebApp as a project that uses Bolt.
2016-03-25set slice capacityBen Johnson2-2/+42
This commit sets the capacity on slices returned from `Bucket.Get()` to match the slice length. Previously the capacity would be the size of the mmap max size. This does not cause any backwards compatibility issues, however, it does allow users to `append()` to the returned slice since that will cause Go to realloc a new slice on the heap. Fixes #544
2016-03-23remove badgeBen Johnson1-1/+1
Remove the Drone.IO badge while setting up new test infrastructure.
2016-03-22Add note about Go RFC3339Nano sortability to READMEEric Boren1-0/+2
RFC3339 is sortable, but RFC3339Nano is not, because it does not use a fixed number of digits after the decimal.
2016-03-21fix rebalance bugBen Johnson1-37/+0
This commit fixes a rare issue where a page can become accessible when it has already been freed. This occurs when the first two child pages of a parent both have deletions and the first page has 1 remaining children and the second page has 2 remaining children. During rebalancing the first page pulls an element from the second page and then the second page pulls the same element back from the first. The child page was not being freed properly. I resolved this issue by removing this part of the rebalancing. I made this choice for two reasons: 1. Moving a single item between pages has negligible benefit. The page will eventually be cleaned up when it reaches zero elements. 2. This is an infrequently executed branch of code which increases the likelihood of bugs occurring and it makes it more difficult to test properly. Fixes #348
2016-03-21fix strict modeBen Johnson1-2/+12
This commits fixes a timing bug where `DB.StrictMode` can panic before the goroutine reading the database can finish. If an error is found in strict mode then it now finishes reading the entire database before panicking.
2016-03-21Adding "lru" to list of projects using Bolt.Abhinav Ajgaonkar1-0/+1
2016-03-10use tx.meta during Tx.WriteTo()Ben Johnson2-6/+28
This commit changes `Tx.WriteTo()` to use the transaction's in-memory meta page instead of copying from the disk. This is needed because the transaction uses the size from its meta page but writes the current meta page on disk which may have allocated additional pages since the transaction started. Fixes #513
2016-03-05Update README.mdAsdine El Hrychy1-0/+1