Skip to content

Pass item indexes to ractor callbacks when requested - #380

Closed
OskarEichler wants to merge 4 commits into
grosser:masterfrom
OskarEichler:codex/pass-ractor-item-index
Closed

Pass item indexes to ractor callbacks when requested#380
OskarEichler wants to merge 4 commits into
grosser:masterfrom
OskarEichler:codex/pass-ractor-item-index

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Honor with_index when dispatching Ractor callbacks, including map_with_index and each_with_index.

Reproduction and verification

A callback def self.call(item, index); [item, index]; end used with Parallel.map_with_index(["a", "b"], in_ractors: 2, ractor: [Callback, :call]) currently raises ArgumentError because only item is passed. The candidate returns [["a", 0], ["b", 1]] and keeps start/finish hook indexing unchanged.

Three cases with one/two/three Ractors and finish callback evidence fail before/pass after. Twenty-nine existing Ractor examples pass with seven existing pending cases.

The combined installed-release candidate passes 800 model checks across direct, thread, process and Ractor modes. Existing selected suite: 165 examples, zero failures, nine pending, baseline and candidate on rbenv Ruby 4.0.6. Global process-name kill tests and the 200-process stress example were excluded for shared-host safety. SQLite examples use temporary databases. An external verification bundle uses already-installed dependencies; upstream Gemfile/lockfile/tests remain unchanged.

Runtime RuboCop passes. Full upstream RuboCop reports the same pre-existing RSpec/MatchWithSimpleRegex offense in spec/parallel_spec.rb:278 on both versions; no full green-lint claim. Gem packaging retains 2.1.0, Ruby >= 3.3, all four published paths and metadata, with no dependency changes.

Compatibility and limitations

Intentional correction: indexed Ractor calls supply the requested second argument. Non-indexed calls retain their one-argument contract. Direct mode with a Ractor-only callback is not addressed; Ruby 3 Ractor execution awaits upstream CI.

No tests were added or modified under the consuming repository's no-new-tests policy. Reproductions/model checks are external scratch scripts. No production operations or claim of complete concurrency/platform coverage.

@grosser grosser left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

good catch, never tried that

@grosser

grosser commented Aug 28, 2026

Copy link
Copy Markdown
Owner

replacing with #381

  • fixed ci
  • reused existing test

@grosser grosser closed this Aug 28, 2026
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