Skip to content

Avoid a temporary array when dequeuing groups - #24

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/avoid-group-slice-allocation
Open

Avoid a temporary array when dequeuing groups#24
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/avoid-group-slice-allocation

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Use Array#delete_at when dequeuing one group instead of creating a one-element slice and extracting its first item. Group selection and break decisions are unchanged.

Verification

  • rbenv Ruby 4.0.6: existing rake test, 35 tests / 54 assertions, passes before/after.
  • External deterministic queue corpus: 28,512 ordering/flag checks; 2,000 generated formatter outputs remain byte-identical.
  • 10,000 dequeues: 20,000 → 10,000 Ruby allocations. A 20-call formatting workload changes 72,522 → 72,502 allocations; the allocation benefit depends on the number of groups actually dequeued.
  • Timings varied around 2ms for dequeue and 10ms for the formatter workload. No reliable speedup or application-throughput improvement is claimed.
  • No repository tests added/modified under the contributor's task constraint. Other Ruby engines/versions were not executed locally.

Breaking-change notes

None expected. delete_at(i) returns the same selected group as slice!(i, 1).first for the valid indices produced by this loop.

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.

1 participant