aboutsummaryrefslogtreecommitdiff
path: root/freelist.go (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move code to src/ and tests/EuAndreh2024-10-251-252/+0
|
* Fix freelist.size calculation for large freelistsJosh Bleecher Snyder2016-12-231-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.
* Precalculate size of pending pgids in freelist.copyallJosh Bleecher Snyder2016-12-231-1/+1
| | | | This recovers the slight alloc regression in #636.
* Clean up after #636Josh Bleecher Snyder2016-12-231-12/+3
| | | | | freelist.lenall duplicated freelist.count. freelist.copyall and mergepgids docs had typos.
* Don't allocate huge slices to merge pgids in freelist.writeJosh Bleecher Snyder2016-12-201-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Lower number of allocation in freelist.reindex()Nikita Vetoshkin2016-09-051-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 {
* fix Go 1.7 pointer reference bugBen Johnson2016-08-181-6/+12
| | | | | | | | | | | | 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
* Merge sorted pgids rather than resorting everythingMartin Kobetic2015-06-161-7/+8
|
* Expand assertion statements.Ben Johnson2015-01-301-3/+10
| | | | | | This commit expands calls to _assert() that use variadic arguments. These calls require conversion to interface{} so there was a large number of calls to Go's internal convT2E() function. In some profiling this was taking over 20% of total runtime. I don't remember seeing this before Go 1.4 so perhaps something has changed.
* Allow freelist overflow.Ben Johnson2014-07-101-9/+26
| | | | | | | | | | | This commit is a backwards compatible change that allows the freelist to overflow the page.count (uint16). It works by checking if the overflow will occur and marking the page.count as 0xFFFF and setting the actual count to the first element of the freelist. This approach was used because it's backwards compatible and it doesn't make sense to change the data type of all page counts when only the freelist's page can overflow. Fixes #192.
* Clean up freelist reindex.Ben Johnson2014-07-101-11/+13
|
* Add freelist cache.Ben Johnson2014-06-301-37/+59
| | | | | | This commit adds a cache to the freelist which combines the available free pages and pending free pages in a single map. This was added to improve performance where freelist.isFree() was consuming 70% of CPU time for large freelists.
* Add DefaultOptions variable.Ben Johnson2014-06-221-7/+0
| | | | | | | | | This commit adds an explicit DefaultOptions variable for additional documentation. Open() can still be passed a nil options which will cause options to be change to the DefaultOptions variable. This change also allows options to be set globally for an application if more than one database is being opened in a process. This commit also moves all errors to errors.go so that the godoc groups them together.
* split the freelist page count stats to free and pendingMartin Kobetic2014-06-201-1/+11
|
* add freelist stats to db statsMartin Kobetic2014-06-171-1/+10
|
* Fix freelist rollback.Ben Johnson2014-06-131-1/+23
|
* Check for freelist overflow.Ben Johnson2014-06-131-1/+18
|
* Add freelist assertion on every free().Ben Johnson2014-05-291-26/+20
| | | | This commit performs a check on the freelist pages to ensure that a double free can never happen.
* Fix freelist allocate().Ben Johnson2014-05-191-2/+2
|
* Fix freelist allocation direction.Ben Johnson2014-05-191-18/+25
| | | | | | This commit fixes the freelist so that it frees from the beginning of the data file instead of the end. It also adds a fast path for pages which can be allocated from the first free pages and it includes read transaction stats.
* Add nested buckets.Ben Johnson2014-04-111-0/+25
| | | | | | | This commit adds the ability to create buckets inside of other buckets. It also replaces the buckets page with a root bucket. Fixes #56.
* Write freelist after each commit.Ben Johnson2014-03-311-0/+5
| | | | | Well, this is embarassing. Somehow the freelist was never getting written after each commit. This commit fixes that and fixes a small reporting issue with "bolt pages".
* Add 'bolt pages'.Ben Johnson2014-03-211-0/+17
|
* Rename Transaction to Tx.Ben Johnson2014-03-081-6/+6
| | | | | I changed the Transaction/RWTransaction types to Tx/RWTx, respectively. This makes the naming more consistent with other packages such as database/sql. The txnid is changed to txid as well.
* API Documentation.Ben Johnson2014-02-131-2/+2
|
* Add freelist.Ben Johnson2014-02-101-0/+94