0
0
Fork 0

Merge pull request #730 from abhinavdangeti/scorch-master

Do not account mmap'ed part of zap segments in MemoryUsed
This commit is contained in:
Abhinav Dangeti 2018-01-09 09:56:24 -08:00 committed by GitHub
commit 9c73d37987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -410,13 +410,15 @@ func (s *Scorch) AddEligibleForRemoval(epoch uint64) {
func (s *Scorch) MemoryUsed() uint64 {
var memUsed uint64
s.rootLock.RLock()
for _, segmentSnapshot := range s.root.segment {
memUsed += 8 /* size of id -> uint64 */ +
segmentSnapshot.segment.SizeInBytes()
if segmentSnapshot.deleted != nil {
memUsed += segmentSnapshot.deleted.GetSizeInBytes()
if s.root != nil {
for _, segmentSnapshot := range s.root.segment {
memUsed += 8 /* size of id -> uint64 */ +
segmentSnapshot.segment.SizeInBytes()
if segmentSnapshot.deleted != nil {
memUsed += segmentSnapshot.deleted.GetSizeInBytes()
}
memUsed += segmentSnapshot.cachedDocs.sizeInBytes()
}
memUsed += segmentSnapshot.cachedDocs.sizeInBytes()
}
s.rootLock.RUnlock()
return memUsed

View File

@ -105,7 +105,8 @@ func (s *Segment) SizeInBytes() uint64 {
// 8 /* size of fieldsIndexOffset -> uint64 */
sizeOfUints := 36
sizeInBytes := len(s.mm) + len(s.path) + sizeOfUints
// Do not include the mmap'ed part
sizeInBytes := len(s.path) + sizeOfUints
for k, _ := range s.fieldsMap {
sizeInBytes += len(k) + 2 /* size of uint16 */