diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-30 08:01:41 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-30 08:01:41 -0600 |
commit | def455554b5607ec6ccd0af51d0dea5401003e93 (patch) | |
tree | 3c866e1b594f37ae317218b3ba94965592ae8646 /freelist_test.go | |
parent | Merge pull request #214 from Shopify/fix_stats_sub (diff) | |
download | dedo-def455554b5607ec6ccd0af51d0dea5401003e93.tar.gz dedo-def455554b5607ec6ccd0af51d0dea5401003e93.tar.xz |
Add freelist cache.
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.
Diffstat (limited to 'freelist_test.go')
-rw-r--r-- | freelist_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/freelist_test.go b/freelist_test.go index 5948f3b..24ce0f6 100644 --- a/freelist_test.go +++ b/freelist_test.go @@ -9,21 +9,21 @@ import ( // Ensure that a page is added to a transaction's freelist. func TestFreelist_free(t *testing.T) { - f := &freelist{pending: make(map[txid][]pgid)} + f := newFreelist() f.free(100, &page{id: 12}) assert.Equal(t, f.pending[100], []pgid{12}) } // Ensure that a page and its overflow is added to a transaction's freelist. func TestFreelist_free_overflow(t *testing.T) { - f := &freelist{pending: make(map[txid][]pgid)} + f := newFreelist() f.free(100, &page{id: 12, overflow: 3}) assert.Equal(t, f.pending[100], []pgid{12, 13, 14, 15}) } // Ensure that a transaction's free pages can be released. func TestFreelist_release(t *testing.T) { - f := &freelist{pending: make(map[txid][]pgid)} + f := newFreelist() f.free(100, &page{id: 12, overflow: 1}) f.free(100, &page{id: 9}) f.free(102, &page{id: 39}) @@ -64,7 +64,7 @@ func TestFreelist_read(t *testing.T) { ids[1] = 50 // Deserialize page into a freelist. - f := &freelist{pending: make(map[txid][]pgid)} + f := newFreelist() f.read(page) // Ensure that there are two page ids in the freelist. @@ -84,7 +84,7 @@ func TestFreelist_write(t *testing.T) { f.write(p) // Read the page back out. - f2 := &freelist{pending: make(map[txid][]pgid)} + f2 := newFreelist() f2.read(p) // Ensure that the freelist is correct. |