This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: An update on my mutex-based event signaling object from last year


Hi,

Just a quick note.
The library was made available at
https://github.com/oleh-derevenko/mutexgear for pre-release preview.
The major features include:
* The "Toggle" and "Wheel" objects (event notification synchronization
primitives)
* Completion group of objects (operation completion wait primitives/queues)
* The "RWLock" object (a read-write lock with writer priority and
process-shared use option).
All these are based on muteces and C11 atomics only (custom atomic
types/functions can be provided with defines and that will make the
sources C99 compatible).

An RWLock test project (in C++) is included. No auto-generated
makefiles for now, sorry. Only a minimal hand-written makefile is
included: you may need to tune some switches inside.
For Ubuntu make with
CC=gcc CXX="g++ -std=c++11" LD="g++ -std=c++11" make test
For Windows, there is a VS2017 solution but you'll have to install
LLVM and "LLVM Compiler Toolchain" IDE extension.

Your commentaries and suggestions are welcome.

On Sun, May 12, 2019 at 1:19 PM Oleh Derevenko <oleh.derevenko@gmail.com> wrote:
>
> Hi,
>
> Some of you may remember me from a year ago coming up with a patented
> method of signaling/waiting even synchronization with muteces. Here I
> am with an update.
>
> As for present, I'm not ready with my library yet but recently, with
> aid of my patented object, I was able to implement rwlock based solely
> on muteces. It's a starting implementation as for now and I have some
> ideas for improvements to be considered yet but I already made some
> performance test and would be eager to share results of these with
> you.
>
> What I have:
> * a rwlock implementation providing rdlock/rdunlock and
> wrlock/wrunlock (at present I have not yet considered whether or not
> adding try-locks will be possible -- I would like to finish with the
> object core first, the try-locks are of low importance);
> * a support for writer priority on lock (readers attempting to acquire
> the object hold on to let writers ahead whenever there are writers
> waiting at the time of the read lock attempt)
> * mutex-only implementation implies full priority inheritance in all
> directions as well as other possible benefits.
>
> The method of testing:
> On each target platform the native implementation of rwlock was
> selected for comparison. For both the native and my implementation
> separately and sequentially, several predefined sets of threads were
> started some some of the threads designated as "the writers" and the
> rest as "the readers". The threads would hold on at a barrier for
> start. Whenever all the threads were ready the main thread would
> release the barrier and every thread would do a million lock-unlock
> calls of its designated type without delays. Also, every thread was
> provided a sufficient memory buffer and a global atomic integer as a
> sequence generator. Immediately after each lock and immediately before
> each unlock (those were the two immediately following calls since
> there were no delays, but nevertheless...) every thread would
> atomically increment the generator and save its sequence number into
> its buffer. After the million lock-unlocks threads would hold on at
> another barrier for exit. When all the threads would have finished the
> main thread would release the exit barrier to let the threads exit.
> Then the main thread would combine lock-unlock sequences from
> individual threads' buffers and save the merged global lock-unlock
> order map into a text file for review. Also, the overall time that
> would be required for the threads between the barriers was measured.
>
> Here are the test summaries (Sys=the native object; MG=my
> implementation; duration given in seconds):
> Ubuntu 4.4.0-146-generic x86_64, GCC 5.4.0, x86_64, Intel Core i7
> 4790, libpthread pthread_rwlock_t vs. MG based on pthread_mutex_t
> ----------------------------------------------
> Testing                      1 Writer: (Sys/MG= 0.039/ 0.028): success
> Testing                     4 Writers: (Sys/MG= 1.324/ 0.484): success
> Testing                     8 Writers: (Sys/MG= 3.839/ 1.230): success
> Testing                    16 Writers: (Sys/MG= 8.546/ 2.530): success
> Testing                      1 Reader: (Sys/MG= 0.038/ 0.072): success
> Testing                     4 Readers: (Sys/MG= 0.537/ 1.161): success
> Testing                     8 Readers: (Sys/MG= 1.282/ 2.639): success
> Testing                    16 Readers: (Sys/MG= 2.627/ 5.444): success
> Testing            1 Writer, 1 Reader: (Sys/MG= 0.427/ 0.243): success
> Testing           1 Writer, 4 Readers: (Sys/MG= 0.692/ 1.320): success
> Testing           1 Writer, 8 Readers: (Sys/MG= 1.347/ 2.700): success
> Testing          1 Writer, 16 Readers: (Sys/MG= 2.711/ 5.575): success
> Testing          4 Writers, 4 Readers: (Sys/MG= 1.926/ 1.518): success
> Testing          4 Writers, 8 Readers: (Sys/MG= 2.581/ 2.935): success
> Testing         4 Writers, 16 Readers: (Sys/MG= 4.017/ 5.908): success
> Testing         4 Writers, 32 Readers: (Sys/MG= 6.751/11.744): success
> Testing          8 Writers, 8 Readers: (Sys/MG= 5.014/ 3.484): success
> Testing         8 Writers, 16 Readers: (Sys/MG= 6.482/ 6.338): success
> Testing         8 Writers, 32 Readers: (Sys/MG= 8.998/12.113): success
> Testing         8 Writers, 64 Readers: (Sys/MG=15.437/24.930): success
> Testing        16 Writers, 16 Readers: (Sys/MG=10.652/ 7.938): success
> Testing        16 Writers, 32 Readers: (Sys/MG=13.630/13.632): success
> Testing        16 Writers, 64 Readers: (Sys/MG=19.716/25.771): success
> Testing       16 Writers, 128 Readers: (Sys/MG=31.496/49.544): success
> ----------------------------------------------
>
> QNX 7.0.3 x86, GCC 5.4.0, x86, Intel Core i7 (1.5 GHz, 2 Cores, HT
> off), libpthread pthread_rwlock_t vs. MG based on pthread_mutex_t
> ----------------------------------------------
> Testing                      1 Writer: (Sys/MG= 0.190/ 0.103): success
> Testing                     4 Writers: (Sys/MG=35.989/12.782): success
> Testing                     8 Writers: (Sys/MG=81.235/26.269): success
> Testing                    16 Writers: (Sys/MG=162.550/52.519): success
> Testing                      1 Reader: (Sys/MG= 0.187/ 0.218): success
> Testing                     4 Readers: (Sys/MG=26.194/26.102): success
> Testing                     8 Readers: (Sys/MG=53.067/53.229): success
> Testing                    16 Readers: (Sys/MG=106.350/106.898): success
> Testing            1 Writer, 1 Reader: (Sys/MG= 7.429/10.611): success
> Testing           1 Writer, 4 Readers: (Sys/MG=41.714/32.904): success
> Testing           1 Writer, 8 Readers: (Sys/MG=76.635/69.848): success
> Testing          1 Writer, 16 Readers: (Sys/MG=145.137/143.714): success
> Testing          4 Writers, 4 Readers: (Sys/MG=78.157/62.003): success
> Testing          4 Writers, 8 Readers: (Sys/MG=119.179/101.400): success
> Testing         4 Writers, 16 Readers: (Sys/MG=203.953/159.533): success
> Testing         4 Writers, 32 Readers: (Sys/MG=369.356/269.563): success
> Testing          8 Writers, 8 Readers: (Sys/MG=159.795/106.549): success
> Testing         8 Writers, 16 Readers: (Sys/MG=244.563/179.302): success
> Testing         8 Writers, 32 Readers: (Sys/MG=419.073/297.643): success
> Testing         8 Writers, 64 Readers: (Sys/MG=748.366/516.440): success
> Testing        16 Writers, 16 Readers: (Sys/MG=327.305/191.965): success
> Testing        16 Writers, 32 Readers: (Sys/MG=502.784/321.928): success
> Testing        16 Writers, 64 Readers: (Sys/MG=826.430/595.178): success
> Testing       16 Writers, 128 Readers: (Sys/MG=1490.659/1012.941): success
> ----------------------------------------------
>
> Windows 10 x64, MSVC2017_Clang_c2, x86, Intel Core i7 3610QM, Win32
> API SRWLock vs. MG based on CRITICAL_SECTION
> ----------------------------------------------
> Testing                      1 Writer: (Sys/MG= 0.031/ 0.046): success
> Testing                     4 Writers: (Sys/MG= 0.156/ 0.906): success
> Testing                     8 Writers: (Sys/MG= 0.343/ 2.203): success
> Testing                    16 Writers: (Sys/MG= 0.671/ 5.609): success
> Testing                      1 Reader: (Sys/MG= 0.031/ 0.078): success
> Testing                     4 Readers: (Sys/MG= 0.156/ 1.687): success
> Testing                     8 Readers: (Sys/MG= 0.499/ 4.781): success
> Testing                    16 Readers: (Sys/MG= 1.171/10.812): success
> Testing            1 Writer, 1 Reader: (Sys/MG= 0.078/ 0.203): success
> Testing           1 Writer, 4 Readers: (Sys/MG= 0.218/ 1.828): success
> Testing           1 Writer, 8 Readers: (Sys/MG= 0.531/ 5.031): success
> Testing          1 Writer, 16 Readers: (Sys/MG= 1.078/10.905): success
> Testing          4 Writers, 4 Readers: (Sys/MG= 0.328/ 2.796): success
> Testing          4 Writers, 8 Readers: (Sys/MG= 0.640/ 5.390): success
> Testing         4 Writers, 16 Readers: (Sys/MG= 1.031/11.546): success
> Testing         4 Writers, 32 Readers: (Sys/MG= 2.249/23.592): success
> Testing          8 Writers, 8 Readers: (Sys/MG= 0.687/ 6.937): success
> Testing         8 Writers, 16 Readers: (Sys/MG= 1.015/13.093): success
> Testing         8 Writers, 32 Readers: (Sys/MG= 1.828/25.921): success
> Testing         8 Writers, 64 Readers: (Sys/MG= 3.593/50.201): success
> Testing        16 Writers, 16 Readers: (Sys/MG= 1.390/17.140): success
> Testing        16 Writers, 32 Readers: (Sys/MG= 2.171/29.077): success
> Testing        16 Writers, 64 Readers: (Sys/MG= 3.812/53.763): success
> Testing       16 Writers, 128 Readers: (Sys/MG= 7.280/103.559): success
> ----------------------------------------------
>
> The lock-unlock sequence maps can be viewed by path
> /open?id=1xvviERa2pOQ4PJU77KuxPYj6r5sSv2Fe at the Google Drive
> website. There the threads were coded with a character and a hex
> digit. The readers were coded as "A", "B", ... The writers were coded
> as "S". The first character in caps coded a lock operation, the
> respective character in low coded an unlock.
>
> The source code is not available for public yet (I need to finish with
> some parts, such as implementation improvements, build system, source
> commentaries... as well as some organizational moments). Later I plan
> to release it under the GPL and as a commercial library.
>
> --
> Oleh Derevenko
> -- Skype with underscore



-- 

Oleh Derevenko

-- Skype with underscore


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]