LexiFi/landmarks

Concurrency support (eg. Async, Lwt).

mefyl opened this issue · 1 comments

mefyl commented

Landmarks expects landmarks to be correctly nested, making it impossible to bench interleaved asynchronous code, for instance when using Lwt or Async.

(* This will not measure the request, only the creation of the monad which takes 0ms *)
let[@landmark] test () =
  let* response = http_request () in
  process_response response

(* This will probably crash in non toy examples as other threads will probably interleave incompatible enter/leaves *)
let[@landmark] test () =
  Landmarks.enter mark;
  let* response = http_request () in
  let res = process_response response in
  Landmarks.leave mark;
  res

Is it something we'd want to support in landmarks ? Has it already been looked into ?

I'm keen to try implementing it, but at the same time it seems to me it would require some convoluted way to register threads with landmarks and a bunch of lookup maps that may impact the program performances, which is never great for a bench tool.

nojb commented

@mlasson will have a more informed answer, but from a distance this seems like it would need a complete redesign of the library. I'm not sure this fits with its spirit, it being a relatively simple library.

Moreover, I'm not sure it is a good idea to pour energy on supporting "legacy" concurrency libraries such as Lwt and Async now that we have algebraic effects. Investigating whether Landmarks works in combination with effects may actually be a more forward-looking move.