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

Same compiled expression evaluated on different objects in parallel #23

Open
LekhaSahdev opened this issue Apr 12, 2018 · 3 comments
Open

Comments

@LekhaSahdev
Copy link

LekhaSahdev commented Apr 12, 2018

We have certain complicated expressions to be evaluated per object parallely. For the compiled expression the owner is within the expression. Hence when we by run the same expression in parallel on different objects multi threading issues occur and result of one gets attached to another. Can you provide an override for evaluate wherein the same compiled expression i can evaluate on multiple objects

@LekhaSahdev LekhaSahdev changed the title Same compiled expression evaluated on different objects in parallel - We have certain complicated expressions to be evaluated per object parallely. For the compiled expression the owner is within the expression. Hence when we by run the same expression in parallel on different objects multi threading issues occur and result of one gets attached to another. Can you provide an override for evaluate wherein the same compiled expression i can evaluate on multiple objects Same compiled expression evaluated on different objects in parallel Apr 12, 2018
@mparlak
Copy link
Owner

mparlak commented Apr 13, 2018

can not you run the same formula in parallel?

@LekhaSahdev
Copy link
Author

The objects on which it has to be run are dynamically generated based on client input. So we wont know precisely how many objects will get generated per expression.

@hunkydoryrepair
Copy link
Contributor

hunkydoryrepair commented Mar 19, 2021

One solution to this would be to make the Owner object a ThreadLocal object. Needs to happen in the expression code but that would be a breaking change because you would not be able to set the owner object in one thread and evaluate in another. You really need a separate expression for each thread as you are basically overwriting the data in the singularity. I think the request should be to be able to clone an expression without needing to recompile it, then you could clone the expression (hopefully a trivial task) and set a new Owner object on it to evaluate.

I realize it has been a few years, but since this issue is still flagged as OPEN and has no posts on how to deal with it, here is the solution.

IExpression has a Clone method. So, for each thread, clone the expression, set owner, and Evaluate.

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

No branches or pull requests

3 participants