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
Analyze if spinlocks have any benefit and remove them if not #1996
Comments
With commit ac248c8, spinlocks were made to be enabled on multi core systems only, so not sure if we need to remove them. |
Thanks, Ravi for the input. The concern is why we need to use spin_locks when the job can be done using mutex.
ex: aws_init() in cloudsync, doing dict_get holding a priv->spin_lock. Not sure why we need spin_lock in such instances. Mostly in our code, we use spin_lock where the processing time is high. Please give your opinion further |
@VHariharmath-rh I agree that mutexes are better than spinlocks in general. I was only saying that if you run tests on a multi core system (which is pretty much all machines), it already uses mutexes (because of the above patch). So I was wondering how you were planning to analyse the performance difference. |
According to the patch, on multicore systems, the spin_locks are used by default, Am I missing anything?
With these changes, I collect the numbers running fio. |
Ah sorry, my bad. I got it mixed up. The steps makes sense. |
If we can also remove this use_spinlocks variable and just normally ifdef the code, that'd be nice. I'm sure in debug mode it is calling this variable, I don't know about release. I don't see the value in that. |
If I understand correctly, |
I'd start with a simple ifdef instead of consulting a variable. |
The variable libglusterfs/src/locking.c
|
Are you sure? glusterfs/libglusterfs/src/locking.c Line 20 in 2d8c88d
|
Glusterfs currently support spinlocks and mutexes. It's not quite understandable that if spinlocks have any advantage on user mode when running more threads than cores regularly and threads themselves don't run at high priority. If they don't really provide any benefit, we should remove them and simplify locking macros. The concern is why we need to use spin_locks when the job can be done using mutex. The places where we used spin_locks 1. do not share the context with interrupts 2. priority is not a problem 3. the code under spin_lock is going to take more time than the context switch 4. the code may go to sleep Next, use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: gluster#1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
Yes, @mykaul. I did not find anywhere in the code |
use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: gluster#1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: gluster#1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: gluster#1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: gluster#1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
* locks: remove ununsed conditional switch to spin_lock code use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: #1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com> * locks: remove unused conditional switch to spin_lock code use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: #1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com> * locks: remove unused conditional switch to spin_lock code use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Fixes: #1996 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com>
use of spin_locks is depend on the variable use_spinlocks but the same is commented in the current code base through https://review.gluster.org/#/c/glusterfs/+/14763/. So it is of no use to have conditional switching to spin_lock or mutex. Removing the dead code as part of the patch Backport of: > Upstream-patch: gluster#2007 > Fixes: gluster#1996 > Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 > Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com> BUG: 1925425 Change-Id: Ib005dd86969ce33d3409164ef3e1011bb3169129 Signed-off-by: Vinayakswami Hariharmath <vharihar@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/244965 Tested-by: RHGS Build Bot <nigelb@redhat.com> Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
Glusterfs currently support spinlocks and mutexes. It's not quite understandable to that if spinlocks have any advantage on user mode when running more threads than cores regularly and threads themselves don't run at high priority. If they don't really provide any benefit, we should remove them and simplify locking macros.
The text was updated successfully, but these errors were encountered: