aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-11-18 21:24:58 -0800
committerChris Lu <chris.lu@gmail.com>2018-11-18 21:24:58 -0800
commit469863f7f07e2e9396df99e510a13e6fe8685a1f (patch)
tree014738c0100e6128bc4092215daa371a7c1838f5
parentd2924c77483ba17807f3dc56b859fc1541969eae (diff)
downloadseaweedfs-469863f7f07e2e9396df99e510a13e6fe8685a1f.tar.xz
seaweedfs-469863f7f07e2e9396df99e510a13e6fe8685a1f.zip
merge interval now is quite faster with reusing slices
-rw-r--r--weed/filer2/filechunks.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go
index 27ff2f461..473aeb54e 100644
--- a/weed/filer2/filechunks.go
+++ b/weed/filer2/filechunks.go
@@ -109,7 +109,7 @@ var bufPool = sync.Pool{
},
}
-func mergeIntoVisibles(visibles []*visibleInterval, chunk *filer_pb.FileChunk) (newVisibles []*visibleInterval) {
+func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb.FileChunk, ) ([]*visibleInterval) {
newV := newVisibleInterval(
chunk.Offset,
@@ -160,7 +160,7 @@ func mergeIntoVisibles(visibles []*visibleInterval, chunk *filer_pb.FileChunk) (
}
}
- return
+ return newVisibles
}
func nonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []*visibleInterval) {
@@ -169,8 +169,12 @@ func nonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []*v
return chunks[i].Mtime < chunks[j].Mtime
})
+ var newVislbles []*visibleInterval
for _, chunk := range chunks {
- visibles = mergeIntoVisibles(visibles, chunk)
+ newVislbles = mergeIntoVisibles(visibles, newVislbles, chunk)
+ t := visibles[:0]
+ visibles = newVislbles
+ newVislbles = t
}
logPrintf("visibles", visibles)