-
Notifications
You must be signed in to change notification settings - Fork 33
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
Reentrant caching? #56
Comments
JPL now aims to support multi threads (with much help from Jan), although it didn't originally, and I didn't review the (various) caching :-/ Couldn't we mutex just the jpl_assert? or am I missing something. Also, any caching was speculative, and not demonstrably compute-saving... |
Yeah, I guess this would be also a form of caching:
In the above a race condition might appear that two or more could also use a if-then-else check instead, i.e. a conditional needs to add a cache entry or not. Problem is how to box it data arguments of the item you want to update. |
This issue has been mentioned on SWI-Prolog. There might be relevant details there: https://swi-prolog.discourse.group/t/global-variables-and-threads/2519/5 |
Is JPL supposed to be multi-threaded capabel, i.e. reentrant? Because this code doesn’t work as a cache: There might be race conditions where two or more jpl_iref_type_cache/2 are asserted. A reentrant cache is a little bit more difficult to implement and needs a mutex.
One way to do it, is as follows. But it has the drawback that time is spent inside the mutx by ‘jpl_object_to_class/2’ etc… Using destructive operations which would be also seen through facts, this can be even done outside of the mutex, and would be faster. So this is only an imperfect sketch:
Maybe alternatively an elegant approach could be using SWI-Prolog shared tabling.
The text was updated successfully, but these errors were encountered: