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

Implement exponential backoff in spinlock #2391

Closed
wants to merge 2 commits into from

Conversation

Nicoshev
Copy link
Contributor

Summary:
Implement exponential backoff in spinlocks runniong on ARM, as suggested by: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/multi-threaded-applications-arm

We have noticed throughput almost doubles, on the 32 and 64 thread-count cases within the small locks benchmark.

In the below results, 'Sum' is throughput:

before:

------- folly::MicroSpinLock 32 threads
Sum: 67853388 Mean: 942408 stddev: 108821
Lock time stats in us: mean 3 stddev 63 max 17020
------- folly::MicroSpinLock 64 threads
Sum: 28845120 Mean: 400626 stddev: 61624
Lock time stats in us: mean 9 stddev 149 max 30879

after:

------- folly::MicroSpinLock 32 threads
Sum: 116020339 Mean: 1611393 stddev: 27242
Lock time stats in us: mean 1 stddev 3 max 8394
------- folly::MicroSpinLock 64 threads
Sum: 54264302 Mean: 753670 stddev: 30988
Lock time stats in us: mean 4 stddev 3 max 12924

Reviewed By: Gownta

Differential Revision: D70250664

Summary:

SB (Speculation Barrier) is a modern barrier, mandatory from armv8.5a.
It achieves the same result as issuing DSB+ISB, but without having the cpu drop its instruction pipeline.

We have noticed 20% to 30% increased throughput, on the 16, 32 and 64 thread-count case within the small locks benchmark.

In the below results, 'Sum' is throughput:

before:

------- folly::MicroSpinLock 16 threads
Sum: 130891978 Mean: 1817944 stddev: 147111
Lock time stats in us: mean 1 stddev 33 max 14937
------- folly::MicroSpinLock 32 threads
Sum: 54681548 Mean: 759465 stddev: 105588
Lock time stats in us: mean 5 stddev 78 max 35925
------- folly::MicroSpinLock 64 threads
Sum: 24013546 Mean: 333521 stddev: 90571
Lock time stats in us: mean 11 stddev 179 max 90498

after:

------- folly::MicroSpinLock 16 threads
Sum: 169135465 Mean: 2349103 stddev: 227369
Lock time stats in us: mean 1 stddev 25 max 8463
------- folly::MicroSpinLock 32 threads
Sum: 67853388 Mean: 942408 stddev: 108821
Lock time stats in us: mean 3 stddev 63 max 17020
------- folly::MicroSpinLock 64 threads
Sum: 28845120 Mean: 400626 stddev: 61624
Lock time stats in us: mean 9 stddev 149 max 30879

Reviewed By: Gownta

Differential Revision: D70250662
Summary:
Implement exponential backoff in spinlocks runniong on ARM, as suggested by: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/multi-threaded-applications-arm

We have noticed throughput almost doubles, on the 32 and 64 thread-count cases within the small locks benchmark.

In the below results, 'Sum' is throughput:

before:

------- folly::MicroSpinLock 32 threads
Sum: 67853388 Mean: 942408 stddev: 108821
Lock time stats in us: mean 3 stddev 63 max 17020
------- folly::MicroSpinLock 64 threads
Sum: 28845120 Mean: 400626 stddev: 61624
Lock time stats in us: mean 9 stddev 149 max 30879

after:

------- folly::MicroSpinLock 32 threads
Sum: 116020339 Mean: 1611393 stddev: 27242
Lock time stats in us: mean 1 stddev 3 max 8394
------- folly::MicroSpinLock 64 threads
Sum: 54264302 Mean: 753670 stddev: 30988
Lock time stats in us: mean 4 stddev 3 max 12924

Reviewed By: Gownta

Differential Revision: D70250664
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D70250664

Nicoshev added a commit to Nicoshev/hhvm that referenced this pull request Feb 26, 2025
Summary:
X-link: facebook/folly#2391

Implement exponential backoff in spinlocks runniong on ARM, as suggested by: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/multi-threaded-applications-arm

We have noticed throughput almost doubles, on the 32 and 64 thread-count cases within the small locks benchmark.

In the below results, 'Sum' is throughput:

before:

------- folly::MicroSpinLock 32 threads
Sum: 67853388 Mean: 942408 stddev: 108821
Lock time stats in us: mean 3 stddev 63 max 17020
------- folly::MicroSpinLock 64 threads
Sum: 28845120 Mean: 400626 stddev: 61624
Lock time stats in us: mean 9 stddev 149 max 30879

after:

------- folly::MicroSpinLock 32 threads
Sum: 116020339 Mean: 1611393 stddev: 27242
Lock time stats in us: mean 1 stddev 3 max 8394
------- folly::MicroSpinLock 64 threads
Sum: 54264302 Mean: 753670 stddev: 30988
Lock time stats in us: mean 4 stddev 3 max 12924

Reviewed By: Gownta

Differential Revision: D70250664
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 48940bb.

facebook-github-bot pushed a commit to facebook/hhvm that referenced this pull request Feb 27, 2025
Summary:
Pull Request resolved: #9592

X-link: facebook/folly#2391

Implement exponential backoff in spinlocks runniong on ARM, as suggested by: https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/multi-threaded-applications-arm

We have noticed throughput almost doubles, on the 32 and 64 thread-count cases within the small locks benchmark.

In the below results, 'Sum' is throughput:

before:

------- folly::MicroSpinLock 32 threads
Sum: 67853388 Mean: 942408 stddev: 108821
Lock time stats in us: mean 3 stddev 63 max 17020
------- folly::MicroSpinLock 64 threads
Sum: 28845120 Mean: 400626 stddev: 61624
Lock time stats in us: mean 9 stddev 149 max 30879

after:

------- folly::MicroSpinLock 32 threads
Sum: 116020339 Mean: 1611393 stddev: 27242
Lock time stats in us: mean 1 stddev 3 max 8394
------- folly::MicroSpinLock 64 threads
Sum: 54264302 Mean: 753670 stddev: 30988
Lock time stats in us: mean 4 stddev 3 max 12924

Reviewed By: Gownta

Differential Revision: D70250664

fbshipit-source-id: 7277fee05b451dafb5e8d61240efd138636b4684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants