-
Notifications
You must be signed in to change notification settings - Fork 102
linghtning/backend: optimize local writer concurrency and memory usage #753
Conversation
9f34e01
to
0f2442c
Compare
/merge |
@kennytm: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
Huh. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
pkg/lightning/backend/local/local.go
Outdated
@@ -434,7 +820,7 @@ func NewLocalBackend( | |||
g glue.Glue, | |||
maxOpenFiles int, | |||
) (backend.Backend, error) { | |||
localFile := cfg.SortedKVDir | |||
File := cfg.SortedKVDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why rename the variable. as least use a lower case name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be done by the IDE when I refactor the LocalFile
struct..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂😂😂
pkg/lightning/backend/local/local.go
Outdated
@@ -628,27 +1036,62 @@ func (local *local) openEngineDB(engineUUID uuid.UUID, readOnly bool) (*pebble.D | |||
// set threshold to half of the max open files to avoid trigger compaction | |||
L0CompactionThreshold: math.MaxInt32, | |||
L0StopWritesThreshold: math.MaxInt32, | |||
LBaseMaxBytes: 16 << 40, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LBaseMaxBytes: 16 << 40, | |
LBaseMaxBytes: 16 * units.TiB, |
pkg/lightning/backend/local/local.go
Outdated
// 16GB | ||
TargetFileSize: 16 << 30, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 16GB | |
TargetFileSize: 16 << 30, | |
TargetFileSize: 16 * units.GiB, |
pkg/lightning/backend/local/local.go
Outdated
iter, err := reader.NewIter([]byte{'t'}, []byte{'u'}) | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
key, val := iter.SeekGE([]byte{'t'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 seems unnecessary to restrict the range. we don't store non-t
prefixed stuff in the SST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glorv (line 2748 is included)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I supposed the NewIter
must receive a not empty bound, but found we can just pass nil, nil
instead. 😂
pkg/lightning/restore/restore.go
Outdated
compactionLowerThreshold = 512 << 20 // 512M | ||
compactionUpperThreshold = 32 << 30 // 32GB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compactionLowerThreshold = 512 << 20 // 512M | |
compactionUpperThreshold = 32 << 30 // 32GB | |
compactionLowerThreshold = 512 * units.MiB | |
compactionUpperThreshold = 32 * units.GiB |
I add the |
@glorv see above 😅 |
/run-all-tests |
/lgtm |
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 1dff359
|
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-4.0 in PR #1074 |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-5.0 in PR #1075 |
What problem does this PR solve?
Optimize local writer performance and memory usage.
What is changed and how it works?
Optimize local writer by:
Bench result:
The benchmark tests were run on a 40core machine with an NVME disk. and based on the following three data and table schema:
order_line
table with 3 indexes. Thus each row generates 4 kvs.order_line
table with 3 indexes. Thus each row generates 8 kvs.Bench Result:
Check List
Tests
Code changes
Side effects
Related changes
Release Note