diff options
author | Nikita Vetoshkin <nekto0n@yandex-team.ru> | 2016-09-05 14:04:40 +0500 |
---|---|---|
committer | Nikita Vetoshkin <nekto0n@yandex-team.ru> | 2016-09-05 14:04:40 +0500 |
commit | 3d34fbcbfb839e99a1255a78cfa344ad373e93f0 (patch) | |
tree | 19a14e9689b1b78c200a5c26acc0d41bfba6a179 | |
parent | Merge pull request #577 from bouk/patch-1 (diff) | |
download | dedo-3d34fbcbfb839e99a1255a78cfa344ad373e93f0.tar.gz dedo-3d34fbcbfb839e99a1255a78cfa344ad373e93f0.tar.xz |
Lower number of allocation in freelist.reindex()
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 {
-rw-r--r-- | freelist.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/freelist.go b/freelist.go index 1b7ba91..d32f6cd 100644 --- a/freelist.go +++ b/freelist.go @@ -236,7 +236,7 @@ func (f *freelist) reload(p *page) { // reindex rebuilds the free cache based on available and pending free lists. func (f *freelist) reindex() { - f.cache = make(map[pgid]bool) + f.cache = make(map[pgid]bool, len(f.ids)) for _, id := range f.ids { f.cache[id] = true } |