Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Seek() and Read() APIs for index/data files instead of mmap + share expensive seeker resources among seekers #1421

Merged
merged 69 commits into from
Mar 26, 2019
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1075ff2
wip
Jan 16, 2019
cadc0bf
refactor interfaces
Jan 16, 2019
bf00558
dont duplicate interfaces
Jan 16, 2019
94671d4
fix waitgroup.Done() bug
Jan 16, 2019
402cc75
delete commented out code
Jan 16, 2019
7299f4c
clean up buffer
Jan 16, 2019
a4bfb4e
re-enable test
Jan 16, 2019
988f67a
improve comment
Jan 16, 2019
a7db0c6
undo unrelated change
Jan 16, 2019
aa39a82
Refactor checked bytes usage
Jan 16, 2019
f906e72
dec ref before finalize
Jan 16, 2019
a98530a
return error if call decodeBytes without byte decoder stream
Jan 16, 2019
fc94cec
Add comment for error
Jan 16, 2019
f0e7c56
use constants for seek calls
Jan 16, 2019
1c4874c
fix bug
Jan 16, 2019
cb7883a
reorder initialization code
Jan 16, 2019
9954dbe
fix nil id check
Jan 16, 2019
1cec3bd
clarify comments
Jan 16, 2019
e9ff256
reorder functions
Jan 16, 2019
41c94d1
reduce per-seeker pointers
Jan 16, 2019
4a8ad41
fix clone bug
Jan 16, 2019
ad0ad99
pass resources to seeker constructor, pool them in manager, and fix tsts
Jan 16, 2019
f771974
dont alloc msgpack decoder in readInfo
Jan 16, 2019
32b52ae
use resources for index lookup
Jan 17, 2019
1ba61a2
refactor interfaces
Jan 17, 2019
b3ce53f
Finalize tags
Jan 17, 2019
0918515
add tags to conc test
Jan 17, 2019
bdf250c
improve retriever concurrency test
Jan 17, 2019
ea4301b
fix compilation issues
Jan 17, 2019
610032c
rename
Jan 17, 2019
f596eb4
remove broken test
Jan 17, 2019
15d575f
fix bug
Jan 17, 2019
7106c3e
propagate seek reader buffer size
Jan 17, 2019
782f19e
return tags to pool
Jan 17, 2019
0a8bcc3
add todo
Jan 17, 2019
7ddf71f
remove unused type and methods
Jan 17, 2019
ad32b41
mark retriever test as big
Jan 17, 2019
88c3595
reduce test memory usage
Jan 17, 2019
0f952f9
make sure to read full
Jan 17, 2019
a3abf41
fix panic
Jan 17, 2019
44f9878
add simple bytes pool
Jan 17, 2019
5a68c70
improve comment
Jan 17, 2019
a11d979
add test for bytes pool path
Jan 17, 2019
f0301d9
improve comment and rename var
Jan 17, 2019
1d72ed1
shift code around
Jan 17, 2019
b0d8728
remove unused field in struct
Jan 17, 2019
0b240be
remove newline
Jan 17, 2019
125b3d5
clarify comment
Jan 17, 2019
bc74b75
fix comment
Jan 17, 2019
3b79d64
remove comment
Jan 17, 2019
ae6958f
add periods
Jan 17, 2019
731bdf8
fix brkoen test
Jan 17, 2019
b32d2f0
dont call getResources twice
Jan 18, 2019
dd5e47e
remove unneeded var
Jan 18, 2019
0a7c670
check if bytesPool == nil
Jan 18, 2019
b694747
use standard object pool
Jan 18, 2019
a300168
handle reqs with errors in retriever
Jan 18, 2019
6a47e2f
Add unit tests and fix retreiver when seeke error
Jan 18, 2019
2981bf6
add better comment
Jan 30, 2019
be3cf15
refactor code to have less branching
Jan 30, 2019
ff07c0d
reuse decoder stream from resources instead of allocating in constructor
Jan 30, 2019
969e5f7
fix broken test
Jan 30, 2019
ac4d608
regen mocks
Mar 2, 2019
a27b620
fix compilation issue
Mar 22, 2019
accf7a7
remove unneeded errors
Mar 22, 2019
37c2950
remove unneeded syscall
Mar 22, 2019
273c035
add comment
Mar 22, 2019
0bd4d89
Merge branch 'master' into ra/no-mmap-files-v2
richardartoul Mar 26, 2019
f9ccb4f
Merge branch 'master' into ra/no-mmap-files-v2
richardartoul Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve comment and rename var
Richard Artoul committed Mar 22, 2019

Verified

This commit was signed with the committer’s verified signature.
abelsromero Abel Salgado Romero
commit f0301d93e41f78f7670b1ba9c14a94c428207408
29 changes: 17 additions & 12 deletions src/dbnode/persist/fs/seek.go
Original file line number Diff line number Diff line change
@@ -398,7 +398,11 @@ func (s *seeker) SeekIndexEntry(
return IndexEntry{}, errSeekIDNotFound
}

entry, err := resources.xmsgpackDecoder.DecodeIndexEntry(resources.bytesPool)
// Use the bytesPool on resources here because its designed for this express purpose
// and is much faster / cheaper than the checked bytes pool which has a lot of
// synchronization and is prone to allocation (due to being shared).
entry, err := resources.xmsgpackDecoder.DecodeIndexEntry(
resources.decodeIndexEntryBytesPool)
if err != nil {
// Should never happen, either something is really wrong with the code or
// the file on disk was corrupted.
@@ -413,7 +417,8 @@ func (s *seeker) SeekIndexEntry(
comparison := bytes.Compare(entry.ID, idBytes)
if comparison == 0 {
// If it's a match, we need to copy the tags into a checked bytes
// so they can be passed along.
// so they can be passed along. We use the "real" bytes pool here
// because we're passing ownership of the bytes to the entry / caller.
checkedBytes := s.opts.bytesPool.Get(len(entry.EncodedTags))
checkedBytes.IncRef()
checkedBytes.AppendAll(entry.EncodedTags)
@@ -427,15 +432,15 @@ func (s *seeker) SeekIndexEntry(

// Safe to return resources to the pool because ID will not be
// passed along and tags have been copied.
resources.bytesPool.Put(entry.ID)
resources.bytesPool.Put(entry.EncodedTags)
resources.decodeIndexEntryBytesPool.Put(entry.ID)
resources.decodeIndexEntryBytesPool.Put(entry.EncodedTags)

return indexEntry, nil
}

// No longer being used so we can return to the pool.
resources.bytesPool.Put(entry.ID)
resources.bytesPool.Put(entry.EncodedTags)
resources.decodeIndexEntryBytesPool.Put(entry.ID)
resources.decodeIndexEntryBytesPool.Put(entry.EncodedTags)

// We've scanned far enough through the index file to be sure that the ID
// we're looking for doesn't exist (because the index is sorted by ID)
@@ -535,18 +540,18 @@ type ReusableSeekerResources struct {
// well as ref counting that comes with the checked bytes pool. In addition,
// since the ReusableSeekerResources is only ever used by a single seeker at
// a time, we can size this pool such that it almost never has to allocate.
bytesPool pool.BytesPool
decodeIndexEntryBytesPool pool.BytesPool
}

// NewReusableSeekerResources creates a new ReusableSeekerResources.
func NewReusableSeekerResources(opts Options) ReusableSeekerResources {
seekReaderSize := opts.SeekReaderBufferSize()
return ReusableSeekerResources{
msgpackDecoder: msgpack.NewDecoder(nil),
xmsgpackDecoder: xmsgpack.NewDecoder(opts.DecodingOptions()),
fileDecoderStream: bufio.NewReaderSize(nil, seekReaderSize),
byteDecoderStream: xmsgpack.NewByteDecoderStream(nil),
bytesPool: newSimpleBytesPool(),
msgpackDecoder: msgpack.NewDecoder(nil),
xmsgpackDecoder: xmsgpack.NewDecoder(opts.DecodingOptions()),
fileDecoderStream: bufio.NewReaderSize(nil, seekReaderSize),
byteDecoderStream: xmsgpack.NewByteDecoderStream(nil),
decodeIndexEntryBytesPool: newSimpleBytesPool(),
}
}