Non-unique process names in observer

4 views
Skip to first unread message

Roger Lipscombe

unread,
Jun 9, 2021, 8:13:40 AMJun 9
to erlang-questions
In Erlang, a process can have a registered name, but it must be unique
and must be an atom.

In the http://erlang.org/pipermail/erlang-questions/2021-May/100972.html
thread, it was suggested that processes should have non-unique names
associated with them, making debugging easier.

Lukas pointed out that adding more information to the PID term was a
lot of work, but suggested extending proc_lib to add further metadata
that could be displayed by observer.

This morning, using observer, I found myself looking at a large
supervision tree with nothing but PIDs.

So I did some digging around to see what might be involved. If I get
time (I probably won't), I might put together a PR, but this'll be
useful for anyone else thinking about implementing it.

Observer gets the display name for its processes here:
https://github.com/erlang/otp/blob/OTP-24.0.2/lib/runtime_tools/src/appmon_info.erl#L708-L714;
it'd be relatively simple to get the process dictionary and look up
'$process_label' (better naming suggestions are welcome).

Adding that functionality to proc_lib, on the other hand... Well.

proc_lib offers *21* different ways to start a process, and only
spawn_opt/{2,3,4,5} allows specifying extra options, which is where
you'd probably want to put that label. I'm uncomfortable with adding
it to the spawn_option() type.

For OTP's built-in behaviours, you'd need to define an extra option to
be passed to gen_server:start_link, gen_statem:start_link, etc. That
would be less complicated (because they already take options), but is
still a chunk of work.

In the short term, I think the easiest option might be to make the
changes to observer, document it appropriately, and then just
encourage library authors to put('$process_label', MyLabel) wherever
it seems sensible.

Thoughts?

Cheers,
Roger.

Roger Lipscombe

unread,
Jul 9, 2021, 4:55:31 AMJul 9
to erlang-questions
On Wed, 9 Jun 2021 at 13:13, Roger Lipscombe <ro...@differentpla.net> wrote:
[snip]
> Lukas pointed out that adding more information to the PID term was a
> lot of work, but suggested extending proc_lib to add further metadata
> that could be displayed by observer.

[snip]
> In the short term, I think the easiest option might be to make the
> changes to observer, document it appropriately, and then just
> encourage library authors to put('$process_label', MyLabel) wherever
> it seems sensible.

https://github.com/erlang/otp/pull/5039

Nathan Long

unread,
Jul 30, 2021, 9:44:23 AMJul 30
to Roger Lipscombe, erlang-questions
I missed this thread and started trying to implement this myself, but you've gotten further, so I'll leave it to you. I agree that the proc_lib piece is by far the hardest, and I think it's a clever idea to put that off and see if the idea gains enough momentum to have more explicit support.

Thanks for working on this! I'm excited to see how it goes.
Reply all
Reply to author
Forward
0 new messages