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

stats: reduce stats collecor's lock contention #9233

Merged
merged 2 commits into from
Feb 25, 2019

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Jan 31, 2019

What problem does this PR solve?

We will create a session stats collector for each session and link them into a list. So when there are many sessions, it will take longer to loop the list, and holding the list head's lock during the whole process will block other operations, like NewSessionStatsCollector.

What is changed and how it works?

When looping the list, only holds the lock of necessary stats collector, that is the previous one and current. So it will only holds at most two locks at the same time.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • None

@alivxxx alivxxx added type/enhancement The issue or PR belongs to an enhancement. component/statistics labels Jan 31, 2019
@codecov-io
Copy link

codecov-io commented Jan 31, 2019

Codecov Report

Merging #9233 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #9233      +/-   ##
=========================================
- Coverage    67.3%   67.3%   -0.01%     
=========================================
  Files         373     373              
  Lines       78449   78441       -8     
=========================================
- Hits        52803   52795       -8     
+ Misses      20911   20910       -1     
- Partials     4735    4736       +1
Impacted Files Coverage Δ
statistics/update.go 83.69% <100%> (-0.28%) ⬇️
ddl/session_pool.go 82.75% <0%> (-10.35%) ⬇️
ddl/delete_range.go 78.83% <0%> (-0.53%) ⬇️
store/tikv/scan.go 77.31% <0%> (+3.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f80e401...13c3179. Read the comment docs.

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@winoros winoros added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 19, 2019
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 25, 2019
@zz-jason
Copy link
Member

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants