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

Upgrade queue mechanism, to return more buffers #3

Merged
merged 5 commits into from
Apr 11, 2024

Conversation

FelonEkonom
Copy link
Member

@FelonEkonom FelonEkonom commented Apr 5, 2024

@FelonEkonom FelonEkonom marked this pull request as draft April 5, 2024 13:05
@FelonEkonom FelonEkonom force-pushed the stop-storing-available-buffers branch 2 times, most recently from 4a08198 to 970b60b Compare April 8, 2024 15:55
@FelonEkonom FelonEkonom force-pushed the stop-storing-available-buffers branch from 970b60b to deb504e Compare April 9, 2024 09:34
@FelonEkonom FelonEkonom force-pushed the stop-storing-available-buffers branch from 1ac3cdf to 2c01685 Compare April 9, 2024 12:43
@FelonEkonom FelonEkonom changed the title Stop storing available buffers Upgrade queue mechanism, to return more buffers Apr 9, 2024
@FelonEkonom FelonEkonom marked this pull request as ready for review April 9, 2024 12:44
@FelonEkonom FelonEkonom requested a review from mat-hek April 9, 2024 12:44
Comment on lines 282 to 283
An item that is not a buffer is considered available if all buffers from the same pad,
which are newer than the item are available.
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
An item that is not a buffer is considered available if all buffers from the same pad,
which are newer than the item are available.
An item other than a buffer is considered available if all newer buffers on the same pad are available.

{actions, timestamp_queue} = actions_after_popping_buffer(timestamp_queue, pad_ref)
{actions ++ actions_acc, timestamp_queue}
end)
defp do_pop_batch(%__MODULE__{} = timestamp_queue, actions_acc \\ [], items_acc \\ []) do
Copy link
Member

Choose a reason for hiding this comment

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

I'd avoid default values in recursive functions, as it's easy to reset an accumulator by accident

|> do_pop()
end
end
|> do_pop_batch(actions_acc, items_acc)
Copy link
Member

Choose a reason for hiding this comment

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

This makes the flow harder to follow, can we return the accumulators here to do_pop_batch instead, so that each function only calls itself recursively?

Comment on lines 208 to 214
first_item_on_awaiting_pad_qex? =
pad_ref in timestamp_queue.awaiting_pads and pad_queue != nil and pad_queue.qex == Qex.new()

timestamp_queue
|> put_in([:pad_queues, pad_ref], new_pad_queue())
|> Map.update!(:pads_heap, &Heap.push(&1, {priority, pad_ref}))
if first_item_on_awaiting_pad_qex? or not is_map_key(timestamp_queue.pad_queues, pad_ref) do
priority =
case item do
{:buffer, buffer} when first_item_on_awaiting_pad_qex? ->
Copy link
Member

Choose a reason for hiding this comment

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

These conditions are hard to read, can you try to refactor that?

@FelonEkonom FelonEkonom requested a review from mat-hek April 10, 2024 12:18
@FelonEkonom FelonEkonom merged commit c0696a5 into master Apr 11, 2024
3 checks passed
@FelonEkonom FelonEkonom deleted the stop-storing-available-buffers branch April 11, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants