This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch branch-4.6
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.6 by this push:
new 052dc9d Replaced synchronized with volatile read in BookieStatus
052dc9d is described below
commit 052dc9dc4dfa1eb4eeb06993f342078469192b18
Author: Matteo Merli <[email protected]>
AuthorDate: Wed Mar 14 12:11:11 2018 -0700
Replaced synchronized with volatile read in BookieStatus
`BookieStatus.isInReadOnlyMode()` is being called from IO threads at each
write request.
Having `synchronized` method is a major source of contention between all
these threads and caps the throughput and increases the latency.
Replacing here with a `volatile` variable read. This will have the same
exact behavior as today while removing the contention point.
I think we could eventually even do a "dirty" read of that variable to
further reduce the overhead of the volatile read.
Author: Matteo Merli <[email protected]>
Reviewers: Ivan Kelly <[email protected]>, Enrico Olivelli
<[email protected]>, Sijie Guo <[email protected]>
This closes #1259 from merlimat/bookie-status-contention
(cherry picked from commit e60085286f48c73ec779e45c84b4a76b2dc2da38)
Signed-off-by: Sijie Guo <[email protected]>
---
.../src/main/java/org/apache/bookkeeper/bookie/BookieStatus.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieStatus.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieStatus.java
index 560868a..59635c6 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieStatus.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieStatus.java
@@ -52,7 +52,7 @@ public class BookieStatus {
private int layoutVersion;
private long lastUpdateTime;
- private BookieMode bookieMode;
+ private volatile BookieMode bookieMode;
BookieStatus() {
@@ -61,11 +61,11 @@ public class BookieStatus {
this.lastUpdateTime = INVALID_UPDATE_TIME;
}
- private synchronized BookieMode getBookieMode() {
+ private BookieMode getBookieMode() {
return bookieMode;
}
- public synchronized boolean isInWritable() {
+ public boolean isInWritable() {
return bookieMode.equals(BookieMode.READ_WRITE);
}
@@ -78,7 +78,7 @@ public class BookieStatus {
return false;
}
- synchronized boolean isInReadOnlyMode() {
+ boolean isInReadOnlyMode() {
return bookieMode.equals(BookieMode.READ_ONLY);
}
--
To stop receiving notification emails like this one, please contact
[email protected].