[ 
https://issues.apache.org/jira/browse/RATIS-2042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17829752#comment-17829752
 ] 

Janus Chow commented on RATIS-2042:
-----------------------------------

Most of the time, the value should be the same.

 

GPT gives the following explaination: "The consumption of 
{{AtomicReference.set}} is generally lower than that of "first comparing 
whether the contents are equal and then setting" because it simply sets the 
value without involving any additional condition checks or synchronization 
blocks. In contrast, comparing before setting involves extra steps, which could 
lead to higher overhead, especially when the contents are frequently equal."

> Prevent unnecessary updates on FollowerInfoImpl#peer
> ----------------------------------------------------
>
>                 Key: RATIS-2042
>                 URL: https://issues.apache.org/jira/browse/RATIS-2042
>             Project: Ratis
>          Issue Type: Improvement
>            Reporter: Janus Chow
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> FollowerInfoImpl#getPeer() will always update peer now, we should only update 
> it when it's changed.
>  
> Since `AtomicReference.set()` has minimal performance overhead, will keep the 
> original implementation then.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to