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

A couple updates #1

Merged
merged 2 commits into from
May 25, 2017
Merged

Conversation

daveyarwood
Copy link

Hey @jgkamat,

I was playing around with the server code and ended up making a couple of changes to the client code too, based on top of your branch.

  • Updated JeroMQ dependency to 0.4.0 -- this is mainly for consistency with changes I'm making to the server (I updated the dependency there too), but JeroMQ 0.4.0 also includes some bug fixes and the ability to create a Poller whose resources are managed through the context.

  • I just pushed alda-server-clj 0.2.0, which has a "job ID" system to help solve Make worker status responses threadsafe alda-lang/alda-server-clj#8, i.e. the issues with requests happening out of sync, causing the worker to send back the wrong score and the client to display the wrong instruments in the REPL prompt. With the changes here, the client sends a job ID on every play/play-status request it makes, and ignores responses from the server if the job ID doesn't match.

  • I tweaked the ZMQ request-sending code a bit. It's almost the same as what you did with cleanupSocket(), but just written a little differently and incorporating the reusable Poller object. (Every time a socket is destroyed, we have to unregister it with the poller, and then when we create a new socket, we have to register it with the poller.)

  • I also bumped up the default retry parameters so that instead of making 3 requests and waiting 2.5 seconds in between each retry, we make 15 requests and wait 500 ms in between each retry. This should make it feel like we're getting responses faster because we're retrying more often.

Some things that still need to be improved:

  • We're still only sending one play request with a 3000 ms timeout, which is a limitation of the server. This is not great, because if the play request fails to get a response (e.g. if it takes more than 3000 ms for the worker to respond, or if there are network issues), then all we can do is print an error and the user has to try again manually. We can't retry automatically because we only want the score to play once.

    The new "job ID" system almost allows us to send multiple requests with the same job ID and not worry about the score playing more than once, but the problem is that the server distributes requests to multiple workers, and the job IDs aren't coordinated amongst the workers, so each worker will play the score once.

    I have some ideas on how to improve this -- I'll keep tinkering with it.

- use a Poller created via the context, so that polling resources are reaped
  when the context is closed

- reuse the same poller, so we aren't creating a new selector on every retry

- use the singleton pattern to eliminate the context and socket arguments

- rebuild the socket on each retry
I have a patch coming through in alda-server-clj that separates jobs by ID,
and ensures that the response a worker sends corresponds to the request it
received for that score. The worker sends back the same jobId in its
response, so the client can read that and ignore any responses that aren't for
the request it sent.
@jgkamat
Copy link
Owner

jgkamat commented May 25, 2017

Wow, this is very nice! I'll take a look at the server side code for this later, since this isn't going to master (and it LGTM) ill merge this right now! Nice =D

@jgkamat jgkamat merged commit 2ea681c into jgkamat:jay/repl-status May 25, 2017
@daveyarwood daveyarwood deleted the dave/repl-status branch June 30, 2017 02:30
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