Skip to content
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

ThreadManager: Improve waitable destruction #15472

Merged
merged 2 commits into from
Apr 10, 2022

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented Apr 9, 2022

I can't reproduce the crash with the stress test unfortunately (see #15470), but this change is a slight optimization.

This makes WaitFor(0) lock-free, and reduces property access at the end of WaitFor. Unfortunately, it's still accessing within the predicate, which could in theory be after the destructor. I thought about relocking afterward, but it doesn't really solve that case.

Instead, I changed the texture replacement to lock on releasing the waitable, and only release it on destruct. It'll remember it's triggered, so this just means the waitable objects live longer. But I think this most completely closes the destruct gap.

-[Unknown]

@unknownbrackets unknownbrackets added this to the v1.13.0 milestone Apr 9, 2022
@hrydgard
Copy link
Owner

hrydgard commented Apr 9, 2022

Thanks! Will try it tomorrow on the threadripper.

Surprised it didn't repro, did you try a debug build, which has some extra checking I think?

@unknownbrackets
Copy link
Collaborator Author

unknownbrackets commented Apr 9, 2022

Ah, I don't usually run things in debug (neither do the actions.) Does happen in debug and this does fix it (compared to not having the lock in the destructor OR in triggered cases.)

-[Unknown]

@hrydgard
Copy link
Owner

This is indeed slightly faster, and passes the test for me too, not very surprisingly. Nice.

@hrydgard hrydgard merged commit 8d1579a into hrydgard:master Apr 10, 2022
@unknownbrackets unknownbrackets deleted the waitable branch April 10, 2022 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants