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

Improve recursive unfair lock #1742

Merged
merged 1 commit into from
Dec 10, 2019
Merged

Improve recursive unfair lock #1742

merged 1 commit into from
Dec 10, 2019

Conversation

Adlai-Holler
Copy link
Member

@Adlai-Holler Adlai-Holler commented Dec 9, 2019

  • Use relaxed memory since we don't need acquire/release. This'll make it faster.
  • Add a couple assertions and organize the code better.
  • In contested case, just lock instead of tryLock-fail-lock.
  • In recursive case, do not tryLock. Just notice it's recursive and be done.
  • In uncontested case, just lock instead of tryLock.

We never experimented with the current (HEAD) version of unfair lock, but this particular version showed benefits across the board and we launched it. Since CATransaction and @synchronized have both moved to unfair lock, there's a clear set of prior art to (try to) use unfair lock. @bolsinga cc #1741

- Use relaxed memory since we don't need acquire/release. This'll make it faster.
- Add a couple assertions and organize the code better.
- In contested case, just lock instead of tryLock-fail-lock.
- In recursive case, do not tryLock. Just notice it's recursive and be done.
- In uncontested case, just lock instead of tryLock.

PRESUBMIT=passed
BUG=137413265
R=maicki
CC=maxwang,rexhu,wiseoldduck,yt-elements-eng+cl
REQUIRED_REVIEW=1
DELTA=50 (14 added, 13 deleted, 23 changed)
DELTA_BY_EXTENSION=h=1,mm=36
OCL=278419008


P4 change: 278454084
@Adlai-Holler Adlai-Holler merged commit d688ce3 into master Dec 10, 2019
@Adlai-Holler Adlai-Holler deleted the AHImprovedUnfairLock branch December 10, 2019 21:51
bolsinga pushed a commit that referenced this pull request May 27, 2020
- Followup to #1742
- At Pinterest this shipped with D516974 in late 02/2020
- As discussed in #858 this is iOS10 or later, so the runtime `gMutex_unfair` check is still necessary for Texture.
rcancro pushed a commit to rcancro/Texture that referenced this pull request May 28, 2020
- Followup to TextureGroup#1742
- At Pinterest this shipped with D516974 in late 02/2020
- As discussed in TextureGroup#858 this is iOS10 or later, so the runtime `gMutex_unfair` check is still necessary for Texture.
piotrdebosz pushed a commit to getstoryteller/Texture that referenced this pull request Mar 1, 2021
- Followup to TextureGroup#1742
- At Pinterest this shipped with D516974 in late 02/2020
- As discussed in TextureGroup#858 this is iOS10 or later, so the runtime `gMutex_unfair` check is still necessary for Texture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants