Skip to content

Commit

Permalink
Some inspects
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Feb 6, 2024
1 parent 9018e3c commit 054606a
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion benchmark/metric/in_progress_memory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Benchmark.Metric.InProgressMemory do

if cumulative_memory > cumulative_memory_ref * (1 + @tolerance_factor),
do:
raise(
IO.warn(
"The memory performance has got worse! For test case: #{inspect(test_case, pretty: true)}
the cumulative memory used to be: #{cumulative_memory_ref} MB and now it is: #{cumulative_memory} MB"
)
Expand Down
4 changes: 3 additions & 1 deletion benchmark/metric/message_queues_length.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule Benchmark.Metric.MessageQueuesLength do
@tolerance_factor 0.5
@sampling_period 100

require Membrane.Logger

@impl true
def assert(queues_lengths, queues_lengths_ref, test_case) do
cumulative_queues_length = integrate(queues_lengths)
Expand All @@ -12,7 +14,7 @@ defmodule Benchmark.Metric.MessageQueuesLength do
if cumulative_queues_length >
cumulative_queues_length_ref * (1 + @tolerance_factor),
do:
raise(
IO.warn(
"The cumulative queues length has got worse! For test case: #{inspect(test_case, pretty: true)}
the cumulative queues length to be: #{cumulative_queues_length_ref} and now it is: #{cumulative_queues_length}"
)
Expand Down
6 changes: 3 additions & 3 deletions benchmark/metric/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ defmodule Benchmark.Metric.Time do

@impl true
def assert(time, time_ref, test_case) do
if time > time_ref * (1 + @tolerance_factor),
do:
raise(
if time > time_ref * (1 + @tolerance_factor) do
IO.warn(
"The time performance has got worse! For test case: #{inspect(test_case, pretty: true)} the test
used to take: #{time_ref} ms and now it takes: #{time} ms"
)
end

:ok
end
Expand Down
58 changes: 29 additions & 29 deletions benchmark/run.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,43 +61,43 @@ defmodule Benchmark.Run do
require Membrane.Pad

@test_cases [
linear: [
reductions: 1_000,
max_random: 1,
number_of_filters: 10,
number_of_buffers: 500_000,
buffer_size: 1
],
linear: [
reductions: 1_000,
max_random: 1,
number_of_filters: 100,
number_of_buffers: 50_000,
buffer_size: 1
],
linear: [
reductions: 1_000,
max_random: 5,
number_of_filters: 10,
number_of_buffers: 50_000,
buffer_size: 1
],
# linear: [
# reductions: 1_000,
# max_random: 1,
# number_of_filters: 10,
# number_of_buffers: 500_000,
# buffer_size: 1
# ],
# linear: [
# reductions: 1_000,
# max_random: 1,
# number_of_filters: 100,
# number_of_buffers: 50_000,
# buffer_size: 1
# ],
# linear: [
# reductions: 1_000,
# max_random: 5,
# number_of_filters: 10,
# number_of_buffers: 50_000,
# buffer_size: 1
# ],
with_branches: [
struct: [{1, 3}, {3, 2}, {2, 1}],
reductions: 100,
number_of_buffers: 50_000,
buffer_size: 1,
max_random: 1
],
with_branches: [
struct: [{1, 2}, {1, 2}, {2, 1}, {2, 1}],
reductions: 100,
number_of_buffers: 500_000,
buffer_size: 1,
max_random: 10
# ],
# with_branches: [
# struct: [{1, 2}, {1, 2}, {2, 1}, {2, 1}],
# reductions: 100,
# number_of_buffers: 500_000,
# buffer_size: 1,
# max_random: 10
]
]
@how_many_tries 5
@how_many_tries 3
# [ms]
@test_timeout 300_000
# the greater the factor is, the more unevenly distributed by the dispatcher will the buffers be
Expand Down
11 changes: 11 additions & 0 deletions benchmark/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo "FEATURE BRANCH"
git checkout queue-buffers-when-auto-demand-is-low-v2
MIX_ENV=benchmark mix do deps.get, deps.compile --force --all, run benchmark/run.exs feature_branch_results

echo "MASTER BRANCH"
git checkout master
MIX_ENV=benchmark mix do deps.get, deps.compile --force --all, run benchmark/run.exs master_results

MIX_ENV=benchmark mix run benchmark/compare.exs feature_branch_results master_results

git checkout queue-buffers-when-auto-demand-is-low-v2
Binary file added feature_branch
Binary file not shown.
Binary file added feature_branch_results
Binary file not shown.
1 change: 1 addition & 0 deletions lib/membrane/core/element/buffer_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ defmodule Membrane.Core.Element.BufferController do
raise "cannot execute handle_buffer callback for an awaiting input pad"
end

state = Map.update!(state, :unqueued_buffers, & &1 + 1)
state = exec_buffer_callback(pad_ref, buffers, state)
AutoFlowUtils.auto_adjust_atomic_demand(pad_ref, state)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ defmodule Membrane.Core.Element.DemandController.AutoFlowUtils do
|> case do
{{:value, {:buffer, buffer}}, popped_queue} ->
state = PadModel.set_data!(state, pad_ref, :auto_flow_queue, popped_queue)
state = Map.update!(state, :queued_buffers, & &1 + 1)
state = BufferController.exec_buffer_callback(pad_ref, [buffer], state)
pop_stream_formats_and_events(pad_ref, state)

Expand Down
2 changes: 2 additions & 0 deletions lib/membrane/core/element/event_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ defmodule Membrane.Core.Element.EventController do
state
)

IO.inspect({state.name, state.queued_buffers, state.unqueued_buffers}, label: "STATS")

Message.send(
state.parent_pid,
:stream_management_event,
Expand Down
4 changes: 3 additions & 1 deletion lib/membrane/core/element/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ defmodule Membrane.Core.Element.State do
:playback_queue,
:pads_data,
:satisfied_auto_output_pads,
:awaiting_auto_input_pads
:awaiting_auto_input_pads,
queued_buffers: 0,
unqueued_buffers: 0
]
end
Binary file added master_branch
Binary file not shown.
Binary file added master_results
Binary file not shown.

0 comments on commit 054606a

Please sign in to comment.