Skip to content

fix: Allow to display events on devices - #1019

Open
speeddragon wants to merge 1 commit into
edgefrom
fix/hb_print_device
Open

fix: Allow to display events on devices#1019
speeddragon wants to merge 1 commit into
edgefrom
fix/hb_print_device

Conversation

@speeddragon

@speeddragon speeddragon commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Since the restructuring of devices (#915), setting a device name in HB_PRINT stopped working. Eg HB_PRINT=dev_manifest.

This PR gets the device name from HB_PRINT and finds the device name that is used inside the BEAM.
The format is device@version. Eg manifest@1.0.

Comment thread src/core/device/hb_device_name.erl Outdated
case is_generated(Module) of
true ->
Key = {?MODULE, source, Module},
case persistent_term:get(Key, undefined) of

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must the agents try to solve every problem in Erlang by the introduction of yet-another-adhoc persistent_term cache? 😂

Can you see any other ways to solve this? We could at minimum at least do this in hb_device's load flow where we have the existing name@ver -> module caching?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even before asking the agent, this solution came to mind. Other options would be ETS or adding it to Opts. ETS is 20% slow than persistant_term and modifying Opts doesn't feel like a good solution.

Agree, the persistant_term should be done on module load and not on an event call, which can be subject to concurrency.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ets vs persistent_term point is interesting. Should we benchmark persistent_term against ets for hb_store_volatile? We use it a ton.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think persistent_term is a good candidate where too much writing is needed, because it triggers underlying code on each write. I asked an agent to run a benchmark.

On this machine, tuned ETS achieved roughly 13.6M parallel writes/s versus 387K for persistent_term. persistent_term remained competitive for parallel reads.

@speeddragon
speeddragon marked this pull request as ready for review July 16, 2026 11:46
@speeddragon
speeddragon force-pushed the fix/hb_print_device branch 2 times, most recently from a5a71d0 to 5e07202 Compare July 28, 2026 00:56
@speeddragon

speeddragon commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Updated the PR to follow device@version format and change only hb_opts file.
Also in this PR there is a fix for calling default_message_with_env and default_message.
Changing erlang:get to persistent_term:get, since erlang:get only applies to a single process, not the whole VM. This means this was calling for every request.

@speeddragon
speeddragon force-pushed the fix/hb_print_device branch from 5e07202 to 5c47d6d Compare July 28, 2026 01:08
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