Recent

Author Topic: About my scalable RWLock  (Read 5990 times)

aminer

  • Hero Member
  • *****
  • Posts: 956
About my scalable RWLock
« on: March 23, 2014, 07:55:48 pm »
Hello,

I have updated my scalable RWLock to 3.06, in this new
version i have optimized more scalable RWLockX and scalable LW_RWLockX..


Here is what have changed...


Before, the RWLock() method looked like this:


===
procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

event1.resetEvent;
event2.resetEvent;

FCount3^.fcount3:=1;

repeat;
  event2.setEvent;
  asm pause end;
  event2.resetEvent;
until nbr^.nbr=0;

for i:=0 to GetSystemThreadCount-1 do
 begin
   while (FCount1^.fcount1<>0)
    do
     begin
      //if mysleep=0 then sleep(0);
      //else sleep(1);
     end;
 end;

end;

===


To optimize it more you have to write it like this:

==

procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

repeat;
  event2.setEvent;
  asm pause end;
  event2.resetEvent;
until nbr^.nbr=0;

event1.resetEvent;
//event2.resetEvent;

FCount3^.fcount3:=1;



for i:=0 to GetSystemThreadCount-1 do
 begin
   while (FCount1^.fcount1<>0)
    do
     begin
      //if mysleep=0 then sleep(0);
      //else sleep(1);
     end;
 end;

end;

===


Since the repeat-until block is now located before FCount3^.fcount3:=1;
so this will give better parallelism to RWLockX and LW_RWLockX.


You can download all the variants of my scalable RWLock version 3.06 from:


http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.




aminer

  • Hero Member
  • *****
  • Posts: 956
About my scalable RWLock
« Reply #1 on: March 24, 2014, 09:51:27 pm »

Hello,

I have invented a scalable array based Lock that is fast
and scalable and that is better than the Anderson array based Lock cause in the Anderson array based Lock the number of threads can not go beyong the the array length, and i have invented an array based Lock
that eliminate this weakness of the Anderson array based Lock  without sacrificing the speed and efficiency, my scalable array based Lock works accross processes and threads.


I have benchmarked my new scalable array based Lock and i can tell you
that it is fast.

You can download my scalable array based Lock from

http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
Re: A scalable array based Lock
« Reply #2 on: March 24, 2014, 10:05:39 pm »
Hello,

I have read the following paper:

http://people.csail.mit.edu/nickolai/papers/boyd-wickizer-locks.pdf



You have to understand that the following paper is benchmarking with a small critical section, this is why the Ticket Spinlock with a proportional backoff is scaling, but as soon as the critical section becomes bigger the proportional backoff of the Ticket spinlock will not be able to play its role effectivly to reduce the cache-coherence traffic and the Ticket Spinlock will become none scalable, this why i have invented a new array based Lock that is fast and scalable, the cariables don't have to reside in a seperate cache-line inside my scalable array based Lock so this is why my scalable array based Lock will not take too much memory either and it's fast and scalable.

You can download my scalable array based Lock from:

http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: A scalable array based Lock
« Reply #3 on: March 24, 2014, 10:22:17 pm »

Hello,

Please download again my scalable array based Lock, i have just correct something and it's now running like a charm and it's fast
and scalable:


You can download my scalable array based Lock from:

http://pages.videotron.com/aminer/


Thank you,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
Re: A scalable array based Lock
« Reply #4 on: March 25, 2014, 12:13:25 am »
Hello,


I have just changed the Sleep(0) inside the Enter() method
by a "Pause" asm instruction, that's the correct way to do it.


Please download again my scalable array based Lock from:

http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
About my scalable RWLock
« Reply #5 on: April 12, 2014, 04:18:35 am »
Hello,


As you have noticed i have invented four variants of my scalable RWLock,
the ones that ends with an X in there names are starvation-free the
others are not..

Why i have decided to come with salable and starvation-free RWLocks,
cause you can have frequent reads and infrequent writes  but from time
to time you can have frequent writes, so i think it is important to have a scalable and starvation-free RWLock , this is why i have come up with two variants of scalable and starvation-free RWLocks. 

And as i told you before my lightweight variant and starvation-free
RWLock called LW_RWLockX scales even at 3% of writes, that's also very interresting to know...

And you have to know also that even if we are in a scenario with many more writes than 3% of writes and my scalable LW_RWLockX don't scale globally in the timing you have to know that LW_RWLockX will still be useful , cause even if it doen't scale globally in the timing ,  you have to understand that if from the time t1 to the time t2 there is writes and reads and from the time t2 to time t3 there is only reads, so even if the time from t1 to t2 will add more to the overall time cause there is writes threads, the perceived throughput from time t2 to t3 will be higher and the waiting time from t2 to t3 will be lower cause all my RWLocks will be scalable from t2 to t3 and this will make all my scalable RWLocks useful cause for example the database clients from internet or intranet waiting from t2 to t3 will be served more quickly and this is still useful and this will make my scalable RWLocks still useful even if it doesn't scale above 3% of writes.

I have updated my scalable RWLock to 3.06, in this new
version i have optimized more scalable RWLockX and scalable LW_RWLockX..

Here is what have changed...


Before, the RWLock() method looked like this:


===
procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

event1.resetEvent;
event2.resetEvent;

FCount3^.fcount3:=1;

repeat;
  event2.setEvent;
  asm pause end;
  event2.resetEvent;
until nbr^.nbr=0;

for i:=0 to GetSystemThreadCount-1 do
 begin
   while (FCount1^.fcount1<>0)
    do
     begin
      //if mysleep=0 then sleep(0);
      //else sleep(1);
     end;
 end;

end;

===


To optimize it more you have to write it like this:

==

procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

repeat;
  event2.setEvent;
  asm pause end;
  event2.resetEvent;
until nbr^.nbr=0;

event1.resetEvent;
//event2.resetEvent;

FCount3^.fcount3:=1;



for i:=0 to GetSystemThreadCount-1 do
 begin
   while (FCount1^.fcount1<>0)
    do
     begin
      //if mysleep=0 then sleep(0);
      //else sleep(1);
     end;
 end;

end;

===


Since the repeat-until block is now located before FCount3^.fcount3:=1;
so this will give better parallelism to my RWLockX and LW_RWLockX.


You can download all the variants of my scalable RWLock version 3.06 from:


http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
My scalable RWLock and benchmarks
« Reply #6 on: April 19, 2014, 09:28:53 pm »
Hello,


I have just benchmarked all the variants of my scalable RWLock
and i have noticed that my RWLockX has improved in version 3.06 ,
previously it was scaling at no more than 0.1% of writes, but now
it is scaling even at 0.6% of writes and that's a good improvement,
my LW_RWLocksX is scaling even at 3% of writes, so hope you will be happy with all the variants of my scalable RWLock, and if you want to port them to C++ or to other languages you are free to do it, but don't forget to put my author name.


You can download all the variants of my scalable RWLock version 3.06
from:

http://pages.videotron.com/aminer/


Thank you,
Amine Moulay Ramdane,.

 

 

TinyPortal © 2005-2018