Skip to content

Commit

Permalink
Remove distributed session delegation in order to clean up proc.ml (#…
Browse files Browse the repository at this point in the history
…1172)

Channels are not innately suited to distributed computation because of the 'distributed delegation' problem which arises when sending channels over channels: if we send endpoint A over endpoint B, then we don't know where to route any messages to endpoint A.

Before, there was a ton of complex code which may or may not have worked, which attempted to implement a version of the distributed delegation algorithm described in the original Session Java paper. This significantly complicated the distributed sessions runtime in proc.ml and jslib.js.

In practice, we only really delegate from server to client, which does not require any special treatment. None of our present code sends session endpoints from client to other client, or client to server. Therefore, all of this spaghetti code is actually redundant. This patch removes all the distributed delegation code and therefore vastly streamlines the distributed session runtime. Attempting to do distributed delegation from client to server, or client to other client, will now result in a runtime error.

In future we may want to re-enable a form of this. I think the easiest way of doing this would be to explicitly allow the creation of "remote channels" whose buffers reside on the server with sends / receives requiring a remote call -- we would then only need to do name passing.
  • Loading branch information
SimonJF authored Jun 26, 2023
1 parent 19abc4a commit 32f8ade
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 509 deletions.
4 changes: 2 additions & 2 deletions core/evalir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ struct
Debug.print ("sending: " ^ Value.string_of_value v ^ " to channel: " ^ Value.string_of_value chan);
let unboxed_chan = Value.unbox_channel chan in
let outp = Session.send_port unboxed_chan in
Session.send_from_local v outp >>= fun res ->
Session.send_from_server v outp >>= fun res ->
begin
match res with
| SendOK -> apply_cont cont env chan
Expand Down Expand Up @@ -993,7 +993,7 @@ struct
Debug.print ("selecting: " ^ name ^ " from: " ^ Value.string_of_value chan);
let ch = Value.unbox_channel chan in
let (outp, _inp) = ch in
Session.send_from_local (Value.box_variant name (Value.box_unit ())) outp >>= fun _ ->
Session.send_from_server (Value.box_variant name (Value.box_unit ())) outp >>= fun _ ->
OptionUtils.opt_iter Proc.awaken (Session.unblock outp);
apply_cont cont env chan
| Choice (v, cases) ->
Expand Down
Loading

0 comments on commit 32f8ade

Please sign in to comment.