-
Notifications
You must be signed in to change notification settings - Fork 461
WIP [dbnode] Refactor posting list operations to be lazily evaluated and zero copy #2791
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
Open
robskillington
wants to merge
119
commits into
master
Choose a base branch
from
r/reduce-index-query-allocs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
f97ec5f
[dbnode] Reduce index query allocations
robskillington 00462c1
Merge branch 'master' into r/reduce-index-query-allocs
robskillington 17b7398
Use new LRU cache and instrument
robskillington a6f05a7
Revert go.mod
robskillington c8683af
Use read only bitmap by default in FST segment
robskillington a0f1801
Implement read only bitmap for close to zero alloc operations on post…
robskillington 5208869
Add tests
robskillington a76c6c4
Fix tests
robskillington 9592410
Fix few issues
robskillington a0ce92f
Fix multi segments builder
robskillington 6786415
Fix fieldsAndTermsIter
robskillington dd58315
Fix checker
robskillington cfac389
Merge branch 'master' into r/reduce-index-query-allocs
arnikola fd8e4e5
Fix multi-intersect searches that start with empty posting lists
robskillington f2688e0
Refactor read only bitmap range to own datastructure
robskillington c1fbb80
Add ability for RO postings lists to be enabled by env var
robskillington e1b5360
Merge branch 'master' into r/reduce-index-query-allocs
robskillington 861fcdf
Fix integration test kickoff
robskillington 6396865
Fix multi bitmap iterator and also implement field filtering for aggr…
robskillington 8d74ee1
Fix field filtering based on restrict by tags query
robskillington 8da22f2
Close iterator just once
robskillington 4ea2ec6
Fix integration test
robskillington dbf3148
Add pooling of regexp searcher and multi bitmap iterators
robskillington 339b4e7
Cache loaded vellum FST structs and reuse readers
robskillington 91afefa
Add generated map types
robskillington 8d989e2
Fix unlock
robskillington 9160bd4
Merge branch 'master' into r/reduce-index-query-allocs
robskillington 2108f7c
Merge branch 'master' into r/reduce-index-query-allocs
arnikola 7a2683a
Merge branch 'master' into r/reduce-index-query-allocs
arnikola ee07598
Reuse containers used for mutable postings lists
robskillington 0805169
Merge branch 'r/reduce-index-query-allocs' of github.com:m3db/m3 into…
robskillington d0cc13f
Apply capacity fix
robskillington fd2af0c
Add concurrency for queries with lost of segments and pool postings l…
robskillington 099ecd7
Merge branch 'master' into r/reduce-index-query-allocs
robskillington d82a47d
Use separate pools for querying segments separately
robskillington e113d5b
Fix build
robskillington 9d61cb2
Wire up new series index backoff to runtime options
robskillington dd38ead
[dbnode] Refactor wide query path (#2826)
arnikola a3bd18a
[dbnode] Introduce Aggregator type (#2840)
linasm 3b5c0ff
[coordinator] Set default namespace tag to avoid colliding with commo…
robskillington 24d79f8
Merge branch 'master' into r/reduce-index-query-allocs
robskillington 567dd45
Add read through caching of searches to segments (including foreground)
robskillington 3f46cfa
Merge branch 'r/reduce-index-query-allocs' of github.com:m3db/m3 into…
robskillington 31d5816
Fix typo
robskillington 7da3dd5
Set postings list pooling
robskillington 1084aa8
Propagate postings list cache
robskillington 03203b7
Use independent postings list cache for searches
robskillington 36a1690
Use concurrent cache and striped context finalizers
robskillington 0af1add
Use const for array size
robskillington a41e893
Remove test unsafe
robskillington ef5dd15
Rename to slot index
robskillington 7f50c75
Add more realtime stats to number of mutable segments
robskillington 8beb1a1
Reduce contention for add documents and query cache key building
robskillington 6057969
Only acquire lock during stats update/read
robskillington 4af3aba
Fix race with statsNoLock
robskillington 178f02f
Always lock even if using non-concurrent builder
robskillington ccf9035
Force cold writes enabled
robskillington 0483b50
Force cold writes enabled
robskillington 2bbf6ba
Use fast IntersectsAny code path for aggregate queries
robskillington 09eeb3b
Merge branch 'r/reduce-index-query-allocs' of github.com:m3db/m3 into…
robskillington 4dbe593
Remove field not present for storage options
robskillington 4cb4029
Fix non readonly postings
robskillington 0b4db71
Fix non readonly postings
robskillington f668a84
Fix intersect array
robskillington a8eaf9a
Add in-memory block index block to replace per time window block, pha…
robskillington 78eaa8b
Create the in memory block earlier
robskillington 5f93d0c
Avoid indexing already indexed timeseries
robskillington 7ce03c0
Add instrumentation
robskillington 416dbfc
Fix build
robskillington 71d54ca
Always query the in-memory block
robskillington 95ca25f
Only run a compaction on a background segment if active block starts …
robskillington 9fd2d4e
Don't require acquiring other locks from maybeBackgroundCompactWithLock
robskillington e98f77e
Add parallel background compaction
robskillington 9857326
Add wg.done()
robskillington 23e5ff2
Allocate number of background compactors
robskillington 23f6548
Use up to num cpu / 2 for background compaction threads
robskillington 1fb1850
Use num CPU minus one for background compactors
robskillington a333625
Cast num CPU minus one to int
robskillington ecbd20e
Use default compaction level of 0-500k
robskillington fe9eab3
Sort largest to smallest segments when using multi segments builder
robskillington d41284d
Use maps solely for determining existence for compaction purposes or not
robskillington e969766
Use indexedBloomFilterByTimeLock lock
robskillington c25a7bc
Fix cast to interface
robskillington 976bf85
Allocation indexedSnapshot at creation
robskillington 6284b7b
Fix build
robskillington 0aed2f5
Allocate backgroundCompactIndexedSnapshot when creating mutable segments
robskillington b961dea
Remove lock acquiring to check indexed snapshot
robskillington 16a1c54
Call NotifySealedBlocks out of lock and only do the full check of whe…
robskillington 193c4f3
Separate GCing background segments from foreground segments
robskillington cdd8795
Use separate number of compactors per type of background compaction
robskillington 5eb19b6
Alloc GC segments each background GC segment run, also do not mutate …
robskillington ccb3035
Reduce insert lock contention by spreading over many queues per CPU
robskillington de3ce9a
4x the queues per CPU core
robskillington 834efa6
Use series lookup as source of truth for if indexed or not and if sho…
robskillington 3699014
Only run background GC when sealed blocks updated
robskillington 4934faf
Remove purge expired series warning
robskillington 55632a9
Use o(1) lookup for negative offsets for postings IDs in multisegment…
robskillington 3b8c1d0
Load term FSTs up front to avoid slow queries during compactions
robskillington 1c86639
Fix CI tests
robskillington 33590cc
Always consider the in-memory block
robskillington 6a0aa10
Filter instead of shrink slice
robskillington 9421bae
Only decrement readerwrite count if marking as success
robskillington daed491
Always re-resolve entry when checking if should GC series
robskillington 3bc3b81
Merge commit 'e0bc12aeda246f2c39852d44ddb59a11cb3d9d31' into r/reduce…
robskillington 3de1690
Avoid index block ticking while holding index write lock
robskillington da1aeb4
Rerun cached searches when replacing background segments to avoid nee…
robskillington 0738d68
Add concurrent execution of cached searches
robskillington 1f8a510
Initialize worker pool
robskillington 9cf50ee
Reuse cached postings when populating cached searches
robskillington e151cbc
Fix search query proto
robskillington b886052
Fix missing postings for registry value
robskillington a867722
Add a postings cache TTL of 15min, also sort conjunction query for de…
robskillington b8f4d82
Fix build
robskillington 34a8594
Restore simple LRU cache for accuracy when compacting segments
robskillington 61e6185
Shard postings list cache
robskillington 5e03570
Fix reconstructed searches not being executed
robskillington 734d67f
Do not pool multi-bitmap iterators
robskillington 43c0026
Add test for populate worker
robskillington 6379d0b
If tag name is a graphite tag then do not allocate each time
robskillington File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) 2020 Uber Technologies, Inc. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
|
|
||
| package ingest | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/uber-go/tally" | ||
| ) | ||
|
|
||
| // LatencyBuckets are a set of latency buckets useful for measuring latencies. | ||
| type LatencyBuckets struct { | ||
| WriteLatencyBuckets tally.DurationBuckets | ||
| IngestLatencyBuckets tally.DurationBuckets | ||
| } | ||
|
|
||
| // NewLatencyBuckets returns write and ingest latency buckets useful for | ||
| // measuring ingest latency (i.e. time from datapoint/sample created to time | ||
| // ingested) and write latency (i.e. time from received a sample from remote | ||
| // source to completion of that write locally). | ||
| func NewLatencyBuckets() (LatencyBuckets, error) { | ||
| upTo1sBuckets, err := tally.LinearDurationBuckets(0, 100*time.Millisecond, 10) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
|
|
||
| upTo10sBuckets, err := tally.LinearDurationBuckets(time.Second, 500*time.Millisecond, 18) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
|
|
||
| upTo60sBuckets, err := tally.LinearDurationBuckets(10*time.Second, 5*time.Second, 11) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
|
|
||
| upTo60mBuckets, err := tally.LinearDurationBuckets(0, 5*time.Minute, 12) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
| upTo60mBuckets = upTo60mBuckets[1:] // Remove the first 0s to get 5 min aligned buckets | ||
|
|
||
| upTo6hBuckets, err := tally.LinearDurationBuckets(time.Hour, 30*time.Minute, 12) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
|
|
||
| upTo24hBuckets, err := tally.LinearDurationBuckets(6*time.Hour, time.Hour, 19) | ||
| if err != nil { | ||
| return LatencyBuckets{}, err | ||
| } | ||
| upTo24hBuckets = upTo24hBuckets[1:] // Remove the first 6h to get 1 hour aligned buckets | ||
|
robskillington marked this conversation as resolved.
|
||
|
|
||
| var writeLatencyBuckets tally.DurationBuckets | ||
| writeLatencyBuckets = append(writeLatencyBuckets, upTo1sBuckets...) | ||
| writeLatencyBuckets = append(writeLatencyBuckets, upTo10sBuckets...) | ||
| writeLatencyBuckets = append(writeLatencyBuckets, upTo60sBuckets...) | ||
| writeLatencyBuckets = append(writeLatencyBuckets, upTo60mBuckets...) | ||
|
|
||
| var ingestLatencyBuckets tally.DurationBuckets | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo1sBuckets...) | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo10sBuckets...) | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo60sBuckets...) | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo60mBuckets...) | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo6hBuckets...) | ||
| ingestLatencyBuckets = append(ingestLatencyBuckets, upTo24hBuckets...) | ||
|
|
||
| return LatencyBuckets{ | ||
| WriteLatencyBuckets: writeLatencyBuckets, | ||
| IngestLatencyBuckets: ingestLatencyBuckets, | ||
| }, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) 2020 Uber Technologies, Inc. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
|
|
||
| package ingest | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestLatencyBuckets(t *testing.T) { | ||
| buckets, err := NewLatencyBuckets() | ||
| require.NoError(t, err) | ||
|
|
||
| // NB(r): Bucket length is tested just to sanity check how many buckets we are creating | ||
| require.Equal(t, 50, len(buckets.WriteLatencyBuckets.AsDurations())) | ||
|
|
||
| // NB(r): Bucket values are tested to sanity check they look right | ||
| expected := "[0s 100ms 200ms 300ms 400ms 500ms 600ms 700ms 800ms 900ms 1s 1.5s 2s 2.5s 3s 3.5s 4s 4.5s 5s 5.5s 6s 6.5s 7s 7.5s 8s 8.5s 9s 9.5s 10s 15s 20s 25s 30s 35s 40s 45s 50s 55s 1m0s 5m0s 10m0s 15m0s 20m0s 25m0s 30m0s 35m0s 40m0s 45m0s 50m0s 55m0s]" | ||
| actual := fmt.Sprintf("%v", buckets.WriteLatencyBuckets.AsDurations()) | ||
| require.Equal(t, expected, actual) | ||
|
|
||
| // NB(r): Bucket length is tested just to sanity check how many buckets we are creating | ||
| require.Equal(t, 80, len(buckets.IngestLatencyBuckets.AsDurations())) | ||
|
|
||
| // NB(r): Bucket values are tested to sanity check they look right | ||
| expected = "[0s 100ms 200ms 300ms 400ms 500ms 600ms 700ms 800ms 900ms 1s 1.5s 2s 2.5s 3s 3.5s 4s 4.5s 5s 5.5s 6s 6.5s 7s 7.5s 8s 8.5s 9s 9.5s 10s 15s 20s 25s 30s 35s 40s 45s 50s 55s 1m0s 5m0s 10m0s 15m0s 20m0s 25m0s 30m0s 35m0s 40m0s 45m0s 50m0s 55m0s 1h0m0s 1h30m0s 2h0m0s 2h30m0s 3h0m0s 3h30m0s 4h0m0s 4h30m0s 5h0m0s 5h30m0s 6h0m0s 6h30m0s 7h0m0s 8h0m0s 9h0m0s 10h0m0s 11h0m0s 12h0m0s 13h0m0s 14h0m0s 15h0m0s 16h0m0s 17h0m0s 18h0m0s 19h0m0s 20h0m0s 21h0m0s 22h0m0s 23h0m0s 24h0m0s]" | ||
|
robskillington marked this conversation as resolved.
|
||
| actual = fmt.Sprintf("%v", buckets.IngestLatencyBuckets.AsDurations()) | ||
| require.Equal(t, expected, actual) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.