mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
index: let indexmap.Each iterate in allocation order
Iterating through the indexmap according to the bucket order has the problem that all indexEntries are accessed in random order which is rather cache inefficient. As we already keep a list of all allocated blocks, just iterate through it. This allows iterating through a batch of indexEntries without random memory accesses. In addition, the packID will likely remain similar across multiple blobs as all blobs of a pack file are added as a single batch.
This commit is contained in:
parent
f1c388c623
commit
fc05e35a08
@ -54,13 +54,10 @@ func (m *indexMap) add(id restic.ID, packIdx int, offset, length uint32, uncompr
|
||||
|
||||
// foreach calls fn for all entries in the map, until fn returns false.
|
||||
func (m *indexMap) foreach(fn func(*indexEntry) bool) {
|
||||
for _, ei := range m.buckets {
|
||||
for ei != 0 {
|
||||
e := m.resolve(ei)
|
||||
if !fn(e) {
|
||||
return
|
||||
}
|
||||
ei = e.next
|
||||
blockCount := m.blockList.Size()
|
||||
for i := uint(1); i < blockCount; i++ {
|
||||
if !fn(m.resolve(i)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user