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

Change pure calls to use the faster unsafeDupablePerformIO #117

Merged
merged 3 commits into from
Sep 20, 2020

Conversation

Ofenhed
Copy link
Contributor

@Ofenhed Ofenhed commented Sep 19, 2020

Changing from unsafePerformIO to unsafeDupablePerformIO removes the thread safety of pure functions calls, which means that expensive CPU core memory synchronization is not performed. This means that pure functions may be called more than once if called at the same time from multiple threads. This change is safe as long as the documentation is followed, since the documentation asserts that called functions are not allowed to have side effects.

This fixes overhead reported in #115.

This may allow the ioCall to be executed twice. This is safe as long as
the documentation is followed, since the called function is not allowed
to have side effects.
@bitonic
Copy link
Collaborator

bitonic commented Sep 20, 2020

@Ofenhed thanks a lot for the investigation and fix.

Could you amend the "BEWARE" comment for pure? Maybe something along the lines of

Also note that the function might be called multiple times, given that unsafeDupablePerformIO is used to call the provided C code.

@bitonic
Copy link
Collaborator

bitonic commented Sep 20, 2020

Actually, re-reading the comment for unsafeDupablePerformIO, I think an ever longer caveat is warranted, something like

Also note that the function might be called multiple times, given that unsafeDupablePerformIO is used to call the provided C code. Please refer to the documentation for unsafeDupabelPerformIO for more details. unsafeDupablePerformIO is used to ensure good performance using the threaded runtime.

@bitonic
Copy link
Collaborator

bitonic commented Sep 20, 2020

Oh and last request -- please link the issue above the code usage of unsafeDupablePerformIO, so that we remember why it's there :).

@Ofenhed
Copy link
Contributor Author

Ofenhed commented Sep 20, 2020

I mostly used your text. What do you think about it now?

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