Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard #571

Merged
merged 17 commits into from
Jul 14, 2023
Merged

Dashboard #571

merged 17 commits into from
Jul 14, 2023

Conversation

mat-hek
Copy link
Member

@mat-hek mat-hek commented Jun 27, 2023

Adds functionality needed for https://github.com/membraneframework/membrane_kino_dashboard

TODO:

  • add more metrics
    • atomic demand
    • auto demand
    • input buffer

@mat-hek mat-hek added the no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md label Jun 27, 2023
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
test/membrane/core/element_test.exs Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
# observer if enabled by setting `unsafely_name_processes_for_observer: :components`
# in config.exs.
defp setup_process_local_observability(config, opts) do
utility_name = Map.get(opts, :utility_name)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
utility_name = Map.get(opts, :utility_name)
utility_name = Map.get(opts, :utility_name, "")


removed_links =
Enum.map(removed_links, fn link ->
link |> Map.take([:from, :to, :output, :input]) |> Map.put(:entity, :link)
Copy link
Member

Choose a reason for hiding this comment

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

but link.entity == :link because of line 429


@impl true
def handle_info({:graph, graph_update}, state) do
{action, graph_entries, graph_updates, state} = handle_graph_update(graph_update, state)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of updating value of state.graph sometimes in handle_graph_update and sometimes in handle_info, do it in only one place (IMO handle_graph_update is a good idea)

{unquote(metric), unquote(opts)[:component_path] || ComponentPath.get(),
unquote(opts)[:pad]}

[{_key, value} | _default] = :ets.lookup(ets, key) ++ [{nil, unquote(init)}]
Copy link
Member

Choose a reason for hiding this comment

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

Getting metric value from ETS is slow, since we start ETS only with write_concurrency: true flag. Getting last value of metric from process dictionary would be better

lib/membrane/core/observer.ex Outdated Show resolved Hide resolved
Comment on lines 142 to 144
register_name_for_observer(
:"##{unique_prefix}#{name_str}#{component_type_suffix}#{utility_name}"
)
Copy link
Member

Choose a reason for hiding this comment

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

IMO creating a new atom each time we spawn a component, is not a good idea. Where do we use this atom again?

Copy link
Member

Choose a reason for hiding this comment

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

Even if in some cases it is necessary, let's create it only when it will be used by register_name_for_observer/1

@mat-hek mat-hek force-pushed the dashboard branch 14 times, most recently from e8effb0 to e79772f Compare July 7, 2023 10:35
@@ -92,7 +92,7 @@ defmodule Membrane.Core.Bin do
log_metadata: options.log_metadata
}

Membrane.Core.Observability.setup(observability_config)
Membrane.Core.Stalker.register_component(options.stalker, observability_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

The name has exceeded all my expectations xD

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still open to better propositions :D

Comment on lines 47 to 48
total_buffers_metric: :atomics.atomics_ref(),
demand_metric: :atomics.atomics_ref()
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be better to have a "single reference" to some "metrics struct" that would encapsulate these two references?

lib/membrane/core/element/input_queue.ex Show resolved Hide resolved
@@ -46,7 +47,8 @@ defmodule Membrane.Core.Element.InputQueue do
:atomic_demand,
:inbound_metric,
:outbound_metric,
:linked_output_ref
:pad_ref,
:size_metric
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have inbound_metric and outbound_metric which describe the units used by particular pads, and size_metric which is used by our metrics mechanism.. Even though they are not connected, they are named similarly. I believe we need to think about some better namespacing in that case.

lib/membrane/core/stalker.ex Show resolved Hide resolved
lib/membrane/core/element/buffer_controller.ex Outdated Show resolved Hide resolved
lib/membrane/core/element/pad_controller.ex Show resolved Hide resolved
lib/membrane/core/stalker.ex Show resolved Hide resolved
Copy link
Contributor

@varsill varsill left a comment

Choose a reason for hiding this comment

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

I have left some two small things to consider, but generally: LGTM 🥇

@@ -44,8 +44,7 @@ defmodule Membrane.Core.Child.PadModel do
auto_demand_size: pos_integer() | nil,
associated_pads: [Pad.ref()] | nil,
sticky_events: [Membrane.Event.t()],
total_buffers_metric: :atomics.atomics_ref(),
demand_metric: :atomics.atomics_ref()
metrics: %{atom => :atomics.atomics_ref()}
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be better to have stalker_metrics here?

@@ -37,7 +37,8 @@ defmodule Membrane.Core.Element.InputQueue do
inbound_metric: module(),
outbound_metric: module(),
pad_ref: Pad.ref(),
atomic_demand: AtomicDemand.t()
atomic_demand: AtomicDemand.t(),
stalker_metrics: map()
Copy link
Contributor

Choose a reason for hiding this comment

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

[NIT] How about:

Suggested change
stalker_metrics: map()
stalker_metrics: %{atom() => any()}
```?

@mat-hek mat-hek merged commit 1f3c9bd into master Jul 14, 2023
1 check passed
@mat-hek mat-hek deleted the dashboard branch July 14, 2023 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants