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

Make profile_tasks variable thread local to prevent race condition. #4

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

Conversation

dvicini
Copy link
Member

@dvicini dvicini commented Jul 28, 2023

The profile_tasksvariable is currently not thread local. This is in conflict with its use in drjit-core: There it is set within jitc_set_flags, which can be called from multiple threads. All the drjit-core flags are therefore thread local. This commit makes the profile_tasks variable thread local to be consistent with the way flags are handled in drjit-core.

@dvicini dvicini requested a review from wjakob July 28, 2023 14:12
@wjakob
Copy link
Member

wjakob commented Jul 29, 2023

Accessing TLS variables has a shockingly high cost on some OSes. I can look at this after getting back from vacation, but my gut feeling is that we don't want TLS reads in a perf-sensitive threading library.

@dvicini
Copy link
Member Author

dvicini commented Jul 29, 2023

I see, yes it's good to be cautious. We don't want to have a performance cost for this.

As you probably guessed, the reason I am fixing this is because our (latest) threading sanitizer caught the potential race condition in accessing this variable. I am always happy to push back fixes to the open source version, but only if they don't worsen the public code obviously :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants