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

Run control and candidate in parallel or candidate async #2

Open
bobbyrenwick opened this issue Feb 16, 2016 · 6 comments
Open

Run control and candidate in parallel or candidate async #2

bobbyrenwick opened this issue Feb 16, 2016 · 6 comments

Comments

@bobbyrenwick
Copy link

When setting up an experiment, we often want to ensure that the user isn't adversely affected. In order to avoid possible slow downs in the candidate code from affecting the user, would it be possible to run the control and the candidate in parallel? Or better yet, run the candidate completely asynchronously?

I have spent a lot of time writing JavaScript recently so please forgive my lack of ideas on how to solve this problem in Python. Thanks for porting this to Python by the way!

@joealcorn
Copy link
Owner

True concurrency is not really doable in python because of the global interpreter lock. It could spawn a subprocess and run there but I don't fully know the implications of doing so, and it seems like it could be an undesirable side effect for some. Something to look into, but my gut feeling is not good.

Running it async could also affect the results of the experiment if the code accesses a shared resource like a database or cache that has now changed, so that's not really doable either.

In an ideal world it'd work this way but I think users of the library will have to accept correctness over performance whilst they run the experiment.

@thedrow
Copy link

thedrow commented Feb 21, 2016

You can provide an async=True argument that will indicate that the code will run in a thread.
If your application is already threaded and the control and/or candidate perform I/O or release the GIL that would help performance.

@meshy
Copy link

meshy commented Feb 21, 2016

If it's going down this path, what do we mean by "async"? Parallelism or concurrency?

@thedrow
Copy link

thedrow commented Feb 21, 2016

Concurrency. We don't want to use processes in 99% of the cases.

@shockwavemoto
Copy link

yeah i also agree that running it async could also affect the results of the experiment if the code accesses a shared resource like a database or cache that has now changed, so that's not really doable either.
but i don't think that is the solution here we should not use concurrency at all here. If you want to increase the perormance you can provide an async=True argument that will indicate that the code will run in a thread.
If your application is already threaded and the control and/or candidate perform I/O or release the GIL that would help performance.

@jheld
Copy link

jheld commented May 2, 2020

If you have a task queue, you may be able to run the candidate on a worker, passing (or pulling from cache etc) the user/param context to it. You can also give an expiration to ensure the backlog doesn't grow unbounded.

As far as recording purposes, that does pose some challenges, though still doable, but would be extra custom code.

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

6 participants