-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve call_once performance by using InitOnceBeginInitialize / InitOnceComplete #688
Conversation
Co-Authored-By: Stephan T. Lavavej <[email protected]>
Co-Authored-By: Stephan T. Lavavej <[email protected]>
Co-Authored-By: Stephan T. Lavavej <[email protected]>
Co-Authored-By: Stephan T. Lavavej <[email protected]>
I have an idea that this change is not needed. |
Ah, forgot about ODR compatibility, when should coexist with an instance of old STL. Then the proposal in above comment is for vNext only. Let's proceed with this PR, and for proposed improvement we'll have #707 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unblocking my review.
@@ -397,13 +398,18 @@ set(STATIC_SOURCES | |||
${SOURCES_SATELLITE_CODECVT_IDS} | |||
) | |||
|
|||
add_library(std_init_once_begin_initialize OBJECT IMPORTED) | |||
add_library(std_init_once_complete OBJECT IMPORTED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbezault Why two object libraries instead of one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason. We could make them a single library and give it a nice logical name.
@BillyONeal has created Microsoft-internal MSVC-PR-246931 which needs a few Setup changes. |
@StephanTLavavej , does ready to merge status mean that it was (internally) confirmed that |
No, I missed that that was an open question - thanks for bringing it up! @BillyONeal, what's the status of that? |
To the best of my reading of the Windows sources the only failing condition for this API are invalid parameters. (Since Vista the kernel team understands that failure to allocate resources for a synchronization primitive is generally unrecoverable, and so they moved the resource allocation to the thread data structure rather than the lock data structure -- that's why SRWLOCK is a pointer) Whether they want to commit to that as in 'documented on MSDN' is another question, but I don't see what a user could hypothetically do to recover here. |
Fair enough. So, as you inspected sources, then practically I agree with current resolution not to throw on failures. And then possibly the same approach can be used for my (Though it still may be undesirable. For critical sections the behavior was explicitly documented that
Precondition failure is unrecoverable. |
To be clear, I'm satisfied with the current resolution of this in STL source. I'm not satisfied with Windows documentation maintenance quality, and with #705 resolution that seems to assume more serious approach to documentation usage that is being taken in practice for documentation maintenance. |
I know it stands for 'Compiled Hybrid Portable Executable', that it behaves like another CPU as far as the libraries team is concerned, and is in support of the x86-on-arm64 emulator that's part of Windows on aarch64, but I don't really know details. |
If it is x86 emulator then probably it should have x86 ABI, so it would be more logical to copy x86 object, the same as ARM64 is a copy of x64 |
The mangling is different, so copying it wouldn't work. I asked the chpe folks what to do here and this is what they said. |
@AlexGuteniev Thanks for your contribution! |
Hi Sorry for asking question about legacy Windows XP.
In case I compile binary statically linked with runtime those imports are present in final executable. Is it intentional or is it bug? |
XP support was deprecated in VS2017, and was dropped in VS2019 RTM. Despite lack of support, it might have "happened to work" because our runtime DLLs needed to still work, since the runtime DLLs are also shared with VS2015. Note that due to the termination of all SHA-1 root signing certificates, we won't be able to update the redist on XP at all, so you'll be seeing Vista dependencies there soon (#1194). I think we have slated to keep the latest redist that worked on XP around for 2015 and 2017 customers.
Right, because in this case the dependency comes from the import library rather than our DLLs.
VS2019 comes with an option to install the VS2017 compiler which still supported XP:
I think some folks have been pushing to set that release to Win7 but as far as I know Vista has most of the things we actually need. |
(Sorry, to clarify, when I said VS2019 above I mean "the v142 compilers first shipped in VS2019. The VS2019 IDE still supports targeting XP because it can natively use the v141_xp compiler.) |
I will be |
I would argue to target windows 8/8.1 minimum as the new C++20 synchronization stuff makes heavy use of WaitOnAddress, and Windows 7 is not in mainstream or extended support either. |
Given Windows 7’s popularity, it seems unlikely that we could drop targeting; I suppose we could ask. |
+1 on asking to target only Win8+ but also +1 on pessimism that that will fly. Server 2008 is still supported for a at least 3 more years if folks move their workloads into Azure. (see https://www.microsoft.com/en-us/cloud-platform/windows-server-2008 )
Most of that perf hammering is for the ConcRT stuff though -- for example std::mutex needing to be 10x as large as it needs to be. Given that we have the OK from the kernel folks to implement our own |
slightly more. GetProcAddress instead of IAT costs Control Flow Guard. plus may cost spurious AppVerifier stops on Vista. still reasonable price. |
Windows Vista does not have backported support for SHA2 codesigning certificates however Windows Server 2008 has. |
Implement #606