-
Notifications
You must be signed in to change notification settings - Fork 44
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
Do you have any interest in the mcf thread model? #117
Comments
I am familiar with the mcfgthread library, and if GCC supports this via If it requires major changes to GCC's source code it's best to take it up with its developers. When supported and given the right instructions I al willing to try such built. However https://winlibs.com/ aims to distribute a stable version, do to make it into my releases I will need some confirmation that it is indeed stable. |
I did send a patch years ago but it seemed that there wasn't much interest in Windows targets. I can try sending it again though.
Patches are available in the mcfgthread repository 1. There is one patch for GCC itself and another for the CRT. In order to replace the CRT, it is necessary to build GCC in a normal procedure for cross-compiling:
Yes that's my concern too. Can't say much at the moment; I maintain a number of unit tests 2 but I need some information about integration with larger projects. Footnotes |
winlibs will be sticking to what GCC officially supports, so I'm closing this ticket. |
I contacted Jonathan Yong and he said he will commit my patch for the mcf thread model in a few days if there are no further comments. The mcf thread model will probably be available since GCC 13. Thanks for you work all the same. |
I will keep an eye out for that in GCC 13, thanks! |
GCC 13 bootstrapped and uploaded to https://gcc-mcf.lhmouse.com/. The MCF thread model is part of GCC 13 and does not require a separate patch any longer. |
I will start building GCC snapshot 13-20221030 now. Any new parameters I should pay attention to regarding the MCF thread model? |
It may take a while, my first attempts failed with errors like |
|
It's because there are too many symbols to be exported from a DLL. If you get such errors when building GCC, try disabling plugins: msys2/MINGW-packages@9501ee2#diff-cf683a120abf18dd9f774ea5df77137d01e19f359f7cb40c1fc152355cde7b80R205 |
No, it was actually symbols exported from an EXE. Got past it for now with: sed -i.bak "s/--export-all-symbols/--discard-all/" gcc/configure |
Hmm, that didn't work. Apparently there really are files called I will try without those and see if the compiler is functional... |
Now I tried to build with
|
Which version are you using? 'gthr_libobjc.h' only got added recently. Maybe you can try build and install https://github.com/lhmouse/mcfgthread/releases/tag/v1.3-ga.1 first. |
Sorry, was on 1.2-ga.1, didn't realize there was a newer release. I will try 1.3-ga.1 now... |
Build in progress now. Took me some time to figure out I also need to distribute |
Of course. BTW how do you distribute other libraries, such as winpthreads? |
winpthreads comes with mingw-w64, the only special library I had to add manually was libdl. In the meantime I also noticed I need to distribute the entire |
Compilation feels slower, is that possible? Next issue:
Will try again without jit support for now... |
libgccjit doesn't build as it references pthread directly. I think it would be feasible to replace those |
Can you test if it does what you expect (e.g. speed/performance)? |
Thank you. I thought I had composited some tests about |
This program creates 4 threads, then sends a ping request (with a mutex and condvar) to a random one of them, waits for its response, and repeats this 1,000,000 times. I tried compiling and running this on my Core i7-11700 machine with Windows 10 21H2. With the MSYS2 GCC 12 with posix thread model, it completed in ~5.3 seconds. With your GCC 13 build with mcf thread model, it completed in ~5.1 seconds. This may not be a good comparison, but you can try it yourself, with different parameters. |
I have started the discussion about use of |
@lhmouse, what is your opinion of Eric Botcazou solution? You might want to take a look at this topic. |
I have no objection on improving the |
Finally. |
Greetings, and thank you for maintaining winlibs.
Following this discussion 1 in MSYS2, it has been acknowledged that winpthreads, which is required by the posix thread model, is slow.
There used to be deadlocks around condition variables, which got fixed by 2. Although the commit could have evaded deadlocks, I think it is a serious mistake in the design of the condition variable of winpthreads.
Basing on these facts, I think it is a good time to migrate to the mcf thread model. This requires the mcfgthread library 3 notwithstanding, we may gain considerable advantages over the posix and win32 thread models:
std::mutex
,std::condition_variable
,std::once_flag
, and finally,std::thread
.constexpr
initializer, and require no cleanup function, just like on Linux.CRITICAL_SECTION
, and being competitive with even the nativeSRWLOCK
andCONDITION_VARIABLE
.__cxa_*
APIs that conform to the Itanium ABI can be utilized to get proper per-thread cleanup 4.Footnotes
https://github.com/msys2/MINGW-packages/discussions/13259 ↩
https://github.com/mingw-w64/mingw-w64/commit/330025c54b85512d54b6960fad07498365c8fee3 ↩
https://github.com/lhmouse/mcfgthread ↩
https://github.com/msys2/MINGW-packages/issues/2519 ↩
The text was updated successfully, but these errors were encountered: