perf: remove atomic ordering constraints
This commit is contained in:
parent
fae0b13a6d
commit
fae07fc045
12
src/main.rs
12
src/main.rs
|
@ -503,7 +503,7 @@ fn main() -> Result<()> {
|
|||
let mut random_bytes = [0; 16];
|
||||
let mut random_hex = [0; 32];
|
||||
let mut first = true;
|
||||
while !found.load(Ordering::SeqCst) {
|
||||
while !found.load(Ordering::Relaxed) {
|
||||
let mut append = None;
|
||||
let mut header = MaybeUninit::uninit();
|
||||
if !signing {
|
||||
|
@ -518,7 +518,7 @@ fn main() -> Result<()> {
|
|||
Some(Cow::from(random))
|
||||
}
|
||||
Method::Counter => {
|
||||
let count = counter.fetch_add(1, Ordering::SeqCst) + 1;
|
||||
let count = counter.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
Some(Cow::from(count_buffer.format(count)))
|
||||
}
|
||||
_ => None,
|
||||
|
@ -526,8 +526,8 @@ fn main() -> Result<()> {
|
|||
|
||||
if matches!(method, Method::Increment | Method::Decrement) {
|
||||
let timestamp = match method {
|
||||
Method::Decrement => timestamp.fetch_sub(1, Ordering::SeqCst) - 1,
|
||||
Method::Increment => timestamp.fetch_add(1, Ordering::SeqCst) + 1,
|
||||
Method::Decrement => timestamp.fetch_sub(1, Ordering::Relaxed) - 1,
|
||||
Method::Increment => timestamp.fetch_add(1, Ordering::Relaxed) + 1,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
@ -539,7 +539,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
if method == Method::Header {
|
||||
let count = counter.fetch_add(1, Ordering::SeqCst) + 1;
|
||||
let count = counter.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
if first {
|
||||
header_lines.insert(committer_idx + 1, String::with_capacity(16));
|
||||
first = false;
|
||||
|
@ -645,7 +645,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
found.store(true, Ordering::SeqCst);
|
||||
found.store(true, Ordering::Relaxed);
|
||||
let message = match append {
|
||||
Some(append) => Cow::from(format!("{message}\n{append}\n")),
|
||||
None => Cow::from(&message),
|
||||
|
|
Loading…
Reference in New Issue