-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
external: auto switch reader mode #46979
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #46979 +/- ##
================================================
- Coverage 73.0821% 72.7434% -0.3388%
================================================
Files 1336 1357 +21
Lines 398227 404816 +6589
================================================
+ Hits 291033 294477 +3444
- Misses 88451 91686 +3235
+ Partials 18743 18653 -90
Flags with carried forward coverage won't be shown. Click here to find out 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.
rest lgtm
@@ -178,6 +178,7 @@ func (r *byteReader) reload() error { | |||
to := r.useConcurrentReader.Load() | |||
now := r.useConcurrentReaderCurrent.Load() | |||
if to != now { | |||
logutil.BgLogger().Info("switch reader mode", zap.Bool("use concurrent mode", to)) |
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.
logutil.BgLogger().Info("switch reader mode", zap.Bool("use concurrent mode", to)) | |
logutil.Logger(r.ctx).Info("switch reader mode", zap.Bool("use concurrent mode", to)) |
writer := NewWriterBuilder(). | ||
SetPropKeysDistance(100). | ||
SetMemorySizeLimit(512*1024). | ||
Build(st, "testprefix", strconv.Itoa(0)) |
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.
Build(st, "testprefix", strconv.Itoa(0)) | |
Build(st, "testprefix", "0")) |
@@ -42,7 +42,6 @@ func newKVReader( | |||
} | |||
br, err := newByteReader(ctx, sr, bufSize, store, name, false) | |||
if err != nil { | |||
br.Close() |
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.
where do we Close now?
@@ -198,6 +202,23 @@ func (i *mergeIter[T, R]) next() bool { | |||
var zeroT T | |||
i.curr = zeroT | |||
if i.lastReaderIdx >= 0 { | |||
cnt, ok := i.checkHotPointMap[i.lastReaderIdx] | |||
if !ok { | |||
i.checkHotPointMap[i.lastReaderIdx] = 1 |
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.
we can rely on the zero value when map entry is not found, maybe
i.checkHotPointMap[i.lastReaderIdx] = i.checkHotPointMap[i.lastReaderIdx] + 1
if i.checkHotPointCnt == 1000 { | ||
i.checkHotPointCnt = 0 | ||
for idx, cnt := range i.checkHotPointMap { | ||
(*i.readers[idx]).setReadMode(cnt > 500) |
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 byteReader is not concurrently used, we don;t need atomic.Bool to represent useConcurrentReader
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.
Yes, #46924 works for it
/retest |
2 similar comments
/retest |
/retest |
curr T | ||
lastReaderIdx int | ||
err error | ||
checkHotPointMap map[int]int |
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.
Maybe rename to hotspotMap
?
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 didn't understand the meaning of this name at first glance too.
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lance6716, tangenta The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test unit-test |
@wjhuang2016: The specified target(s) for
Use 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 kubernetes/test-infra repository. |
/test check-dev |
@wjhuang2016: The specified target(s) for
Use 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 kubernetes/test-infra repository. |
/test check-dev |
@wjhuang2016: The specified target(s) for
Use 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 kubernetes/test-infra repository. |
@wjhuang2016: The following test failed, say
Full PR test history. Your PR dashboard. 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 kubernetes/test-infra repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #45719
Problem Summary:
Support switching read mode automatically so the speed does not degrade for the hot-point.
What is changed and how it works?
Record the file access stat, and switch reader mode if necessary.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.