[Bug 36692] New: Bad performance when combineng SetEvent / WaitForSingleObject for synchronizing worker threads
http://bugs.winehq.org/show_bug.cgi?id=36692 Bug ID: 36692 Summary: Bad performance when combineng SetEvent / WaitForSingleObject for synchronizing worker threads Product: Wine Version: 1.6.2 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs(a)winehq.org Reporter: milasudril(a)gmail.com In a 2d simulation program, each worker thread has its own pair of events. One event is used to signal master thread that the worker thread is ready. The other is used by the master thread to signal that the worker thread may continue. In Master thread: while(!m_stop) { auto proc_ptr=processors.begin(); while(proc_ptr!=processors.end()) { // Call SetEvent on "start" event object owned by the object pointed // to by proc_ptr proc_ptr->frameNext(); ++proc_ptr; } proc_ptr=processors.begin(); while(proc_ptr!=processors.end()) { // Call WaitForSingleObject on "ready" event object owned by // the object pointed to by proc_ptr proc_ptr->wait(); ++proc_ptr; } ++framecounter; } In worker thread: while(!m_stop) { // Wait for master thread signaling start event (Calls WaitForSingleObject) start.wait(); m_model->process(m_framecounter,m_buffers[0].first ,m_buffers[0].second,m_offset); swap(m_buffers[0],m_buffers[1]); // Signal master thread that we are ready for next frame (Calls SetEvent) ready.set(); } On Wine, the framerate is half of that on Windows 7 on the same machine Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz. Also there seems to be a huge different workload on differnt cores when running under Wine. I realize that SetEvent/WaitForSingleObject are heavy functions on Windows too as they need kernel assistance, so it might be hard to make it perform better. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 milasudril(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |milasudril(a)gmail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #1 from Bruno Jesus <00cpxxx(a)gmail.com> --- Please attach a source code sample that can reproduce the issue. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 Sebastian Lackner <sebastian(a)fds-team.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian(a)fds-team.de --- Comment #2 from Sebastian Lackner <sebastian(a)fds-team.de> --- I would like to point out the following wine-devel discussion about the same topic: http://www.winehq.org/pipermail/wine-devel/2014-April/104088.html Especially this comment by * Vincent Povirk, that exaplains why it is so difficult to optimize the speed of SetEvent/WaitForMultipleObjects: http://www.winehq.org/pipermail/wine-devel/2014-April/104090.html * and this comment by me, which explains the differences between the different sets of synchronization primitives: http://www.winehq.org/pipermail/wine-devel/2014-April/104092.html At my opinion its very difficult to optimize the speed of these specific functions, but as Bruno already wrote, some (minimal) test code would probably be useful - especially to measure how "bad" the performance really is compared to Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #3 from milasudril(a)gmail.com --- Created attachment 48735 --> http://bugs.winehq.org/attachment.cgi?id=48735 Sim2d app Here is Sim2d prerelease -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #4 from milasudril(a)gmail.com ---
At my opinion its very difficult to optimize the speed of these specific functions, but as Bruno already wrote, some (minimal) test code would probably be useful - especially to measure how "bad" the performance really is compared to Windows.
I guessed that they could be tricky. On Windows, I measure 200 kframes/s when using empty model code, and that is quite slow too. That is when the _virtual_ Sim2d::ModelState::process returns without processing its data block. For the Gray-Scott model I get 2kframes/s in Windows on 256x256 pixels. I will push the project to github when I have completed the remaining parts of the code: * Model parameter dialog * Initial condition loading * State matrix export * System state load * System state save The tool can be useful as benchmark. For example, it is possible to load different models, and set the size of problem domain. The only blocker for building a native Linux port is the gui wrapper, and this guy is tricky since different notions of the Window concept. Gui is not useful when running benchmarks though. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #5 from milasudril(a)gmail.com --- Just an idea: What about taking advantage of anonymous autoreset event? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #6 from Vincent Povirk <madewokherd(a)gmail.com> --- DuplicateHandle can still pull an anonymous event handle out of another process and start using it. So, you either need the server to be able to tell the process that controls a handle that it's being moved into the server, or you need a more efficient way of doing this that works across processes. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #7 from milasudril(a)gmail.com --- (In reply to Vincent Povirk from comment #6)
DuplicateHandle can still pull an anonymous event handle out of another process and start using it.
So, you either need the server to be able to tell the process that controls a handle that it's being moved into the server, or you need a more efficient way of doing this that works across processes.
What about letting DuplicateHandle change the behaviour of the event functions. If an event is created with CreateEvent(NULL,0,0,NULL); set vtable pointers associated with the event so they point to an implementation like pevents. When something is done that this implementation cannot do (DuplicateHandle, I guess WaitForMultipleObjects too since that function can take an hetrogenous array of waitable objects), switch to current implementation. This implies that all tricky functions need to copy the state of the event and create it inside wineserver. A drawback is that there will probably be a need for a mutex when this transfer is done. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 milasudril(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #8 from milasudril(a)gmail.com --- The entire Sim2d is now on my Github -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #9 from Bruno Jesus <00cpxxx(a)gmail.com> --- (In reply to milasudril from comment #8)
The entire Sim2d is now on my Github
Please add the link of your github to the URL field and add the download tag. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 milasudril(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://github.com/milasudr | |il/sim2d -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #10 from milasudril(a)gmail.com --- (In reply to Bruno Jesus from comment #9)
(In reply to milasudril from comment #8)
The entire Sim2d is now on my Github
Please add the link of your github to the URL field and add the download tag.
Done. I also added benchmark app without UI. Hope the build system does not complicate things. For me it works well. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #11 from Austin English <austinenglish(a)gmail.com> --- This is your friendly reminder that there has been no bug activity for over a year. Is this still an issue in current (1.7.51 or newer) wine? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Chris Cochran <chris.cochran.protoncore(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chris.cochran.protoncore(a)gm | |ail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #12 from Alexandre Julliard <julliard(a)winehq.org> --- *** Bug 39521 has been marked as a duplicate of this bug. *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #13 from Chris Cochran <chris.cochran.protoncore(a)gmail.com> --- Created attachment 52673 --> https://bugs.winehq.org/attachment.cgi?id=52673 ZIP file containing bug test program and testing notes Enclosed is test software to demonstrate Bug 36692, as requested yesterday by Alexandre Julliard. All the necessary binaries and usage instructions are included in the ZIP. I am the author of all material being submitted and certify that it is harmless and safe to run on all systems. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #14 from Chris Cochran <chris.cochran.protoncore(a)gmail.com> --- See my additional comments in Bug 39521 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Zebediah Figura <z.figura12(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Summary|Bad performance when |Many multi-threaded |combineng SetEvent / |applications have poor |WaitForSingleObject for |performance due to heavy |synchronizing worker |use of synchronization |threads |primitives CC| |z.figura12(a)gmail.com Component|kernel32 |wineserver Keywords| |performance Status|UNCONFIRMED |STAGED Staged patchset| |https://github.com/wine-sta | |ging/wine-staging/tree/mast | |er/patches/eventfd_synchron | |ization --- Comment #15 from Zebediah Figura <z.figura12(a)gmail.com> --- I have written a large set of patches that optimize synchronization primitives by reimplementing them on top of Linux's eventfd primitives. This patch set has shown a significant improvement in a fair number of applications, especially heavily multi-threaded games. Per the request of the head Wine-Staging maintainer, Alistair Leslie-Hughes, I've added the patch set to Staging. It is not enabled by default, but can be enabled by setting the WINEESYNC environment variable to a non-zero value. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Anastasius Focht <focht(a)gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |focht(a)gmx.net -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Zebediah Figura <z.figura12(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|STAGED |NEW --- Comment #16 from Zebediah Figura <z.figura12(a)gmail.com> --- Currently the wine-staging "eventfd_synchronization" patch set is disabled. Due to the current and ongoing work in ntdll.so, it will need significant work to rebase. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Anya <animegirl(a)stronzi.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |animegirl(a)stronzi.org -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Gijs Vermeulen <gijsvrm(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |winter.snowfall23(a)gmail.com --- Comment #17 from Gijs Vermeulen <gijsvrm(a)gmail.com> --- *** Bug 49331 has been marked as a duplicate of this bug. *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Gijs Vermeulen <gijsvrm(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shtetldik(a)gmail.com --- Comment #18 from Gijs Vermeulen <gijsvrm(a)gmail.com> --- *** Bug 49337 has been marked as a duplicate of this bug. *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 rtentser(a)yandex.ru changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rtentser(a)yandex.ru -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 --- Comment #19 from Anya <animegirl(a)stronzi.org> --- https://github.com/wine-staging/wine-staging/blob/master/patches/eventfd_syn... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 soredake <broaden_acid002(a)simplelogin.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|broaden_acid002(a)simplelogin | |.com | -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, patch, source, | |testcase -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |austinenglish(a)gmail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=36692 Ken Sharp <imwellcushtymelike(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |csumushu(a)126.com --- Comment #20 from Ken Sharp <imwellcushtymelike(a)gmail.com> --- *** Bug 56985 has been marked as a duplicate of this bug. *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (2)
-
wine-bugs@winehq.org -
WineHQ Bugzilla