Skip to content

win7: load synch functions on demand #143598

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Jul 7, 2025

Currently, for Windows 7 only, we do a fun thing with pre-main initialisers to optimistically load some functions (used for park/unpark) which require Windows 8+. This means they're loaded even if unused and can mildly affect start up times (albeit not by much). More of an issue is that someone else's pre-main initialiser could run before our own (we've taken steps to mitigated that but it is just a mitigation). Also the code isn't tested by us (i.e. rust CI) any more so it's prone to bit rot. In any case, failure may not be noticed because if it does fail then the Windows 7 code will be used instead.

This PR changes it to load on demand instead. In the happy case this just means doing one load and two equality checks. In the sad case where we've not yet attempted to load the module, this will be slower. But it's a one time cost, usually taken in park (which is "slow" on account of waiting an indefinite period of time).

We could alternatively just use the Windows 7 synchronisation functions exclusively. The issue with that is they're undocumented and technically could be changed or removed at any point, albeit compatibility guarantees make this somewhat unlikely. Still, we should try to be well behaved.

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants