<div dir="ltr"><div dir="ltr">Hi Mohit,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 24, 2019 at 5:19 AM Mohit Agrawal &lt;<a href="mailto:moagrawa@redhat.com">moagrawa@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br>I have a query why do we take a lock at the time of doing an operation in a dictionary.I have observed in testing it seems there is no codepath where<br>  we are using the dictionary parallel. In theory, the dictionary flow is like one xlator put some data in a dictionary and pass to the next xlator and xlator  and originator xlator won&#39;t touch dictionary until the called xlator returns.<br><br>  To prove the same I have executed below test case<br>  1) I have changed all LOCK/UNLOCK macro with dictlock/dictunlock function in the dictionary code and call the LOCK/UNLOCK macros<br>  2) Create a 1x3 volume and mount the volume<br>  3) Run stap script on one of the node to measure dict lock contention to log the entry if more than one thread access the dictionary at the same time<br>  4) Run smallfile tool like below with multiple operations like create/append/cleanup<br>     /root/sync.sh; python /root/smallfile/smallfile_cli.py --operation &lt;op_name&gt; --threads 8 --file-size 64 --files 5000 --top /mnt/test  --host-set &quot;<a href="http://hp-m300-2.gsslab.pnq.redhat.com" target="_blank">hp-m300-2.gsslab.pnq.redhat.com</a>&quot;;<br>  <br>   I have not found any single thread that is trying to access the dictionary while dictlock is already held by some other thread.<br><br>  I have uploaded a patch(<a href="https://review.gluster.org/#/c/glusterfs/+/23603/" target="_blank">https://review.gluster.org/#/c/glusterfs/+/23603/</a>) after converting the if condition to false in dictlock/unlock and run the <div>  regression test suite.I am not getting major failures after removing the lock from a dictionary.<br><br>  Please share your view on the same if the dictionary is not consumed by multiple threads at the same time still we do need to take lock <div>  in the dictionary.<br>  Please share if I need to test something more to validate the same.<br></div></div></div></blockquote><div><br></div><div>That&#39;s very interesting. From a logical point of view I think that we shouldn&#39;t have two threads accessing the same dict at the same time. The only thing that locks guarantee is the internal integrity of the dict structure but, if we have concurrent access to the dict, one of the threads could see keys and/or values appearing/disappearing/changing spuriously, which surely could make things not work well. Apparently we don&#39;t have these issues.</div><div><br></div><div>If that&#39;s true, I think we should be able to completely get rid of the lock in dict structure.</div><div><br></div><div>This change is dangerous however, and it would need extensive testing. If any issue is found, probably we would need to fix that issue instead of adding locks again though.</div><div><br></div><div>Another important thing to do is to run some performance tests. If we really don&#39;t have contention in dict lock, the real cost of the lock is an atomic operation, which is not free but it&#39;s much cheaper than the kernel context that happens in case of contention. We would need to see the improvement to weight the benefits of this change.</div><div><br></div><div>Xavi</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>  <br><div>Regards,</div><div>Mohit Agrawal</div></div></div></div>
_______________________________________________<br>
<br>
Community Meeting Calendar:<br>
<br>
APAC Schedule -<br>
Every 2nd and 4th Tuesday at 11:30 AM IST<br>
Bridge: <a href="https://bluejeans.com/118564314" rel="noreferrer" target="_blank">https://bluejeans.com/118564314</a><br>
<br>
NA/EMEA Schedule -<br>
Every 1st and 3rd Tuesday at 01:00 PM EDT<br>
Bridge: <a href="https://bluejeans.com/118564314" rel="noreferrer" target="_blank">https://bluejeans.com/118564314</a><br>
<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="https://lists.gluster.org/mailman/listinfo/gluster-devel" rel="noreferrer" target="_blank">https://lists.gluster.org/mailman/listinfo/gluster-devel</a><br>
<br>
</blockquote></div></div>