Is it possible in Kino to sort the displayed messages by render_seq_trace chronologically?

Hello Community!

I’m writing my bachelor’s thesis on visualizing distributed protocols using Elixir, and I’ve run into the problem that the built-in Kino render_seq_trace function doesn’t display the messages in their actual order. Does anyone know how to fix this? I only learned Elixir two months ago and need a practical solution quickly.

Help would be great :slight_smile:

Hey there :waving_hand:

It’s been a while since I wrote the original version of the trace function, but if I recall correctly it should be sorting messages by their monotonic timestamp (kino/lib/kino/process.ex at 7fe0aae1329d90015e8d76aed46daeaa65b76c2f · livebook-dev/kino · GitHub). Do you have a reproducible issue where messages are being rendered out of order?

defmodule Test do
  def func() do
    receive do
      {:message, pid} ->
        send(pid, {:back, self()})
        receive do
          {:back, _pid} -> :ok
        end
    end
  end
  
  
  def execute() do
    p1 = spawn(fn -> func() end)
    p2 = spawn(fn -> func() end)
    send(p1, {:message, p2})
    send(p2, {:message, p1})
    receive do
      _ -> :ok
    after
      100 -> :timeout
    end
  end
end

Kino.Process.render_seq_trace(fn -> Test.execute() end)

I know the receive in the end is not doing anything but without the :back messages are not being displayed at all. That’s another weird phenomenon. Every time I run this code I get a different order in the diagram.

I can’t upload images but e.g. the messages are shown before the SPAWN.

Thanks for sending that snippet over. I’m currently away from my machine…but I can possibly play around with this in the next couple of days!

Thank you very much!

I also have a related question: Is it intended that, for GenServers, the server responses generated by call are not displayed in seq_trace?

Update: If you use strict monotonic timestamp instead it works fine