Repository navigation
Conversation
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1415.
multiprocessing.Queuepickles items on its feeder thread. When an output cannot be pickled, that thread prints an error and drops the element, while the caller sees normal iteration over a truncated dataset.The worker now pickles each output tuple with
ForkingPicklerbefore enqueueing it. If this fails, it releases the shared memory allocated for that output and sends the error after the preceding elements, following the existing transform-error path.A small
__reduce__wrapper carries the pickled bytes. User objects are pickled once, and both the consumer and queue-cleanup code still receive the original tuples. There is no public API change.This moves pickling onto the worker loop and adds copies of the serialized payload. Arrays passed through shared memory only add small metadata to that payload. In three interleaved local single-worker probes, median throughput differences were within run-to-run noise. These are not production benchmarks or a claim of zero overhead.
Tests:
process_prefetch_testmodule passes on Linux CPython 3.12 and 3.14: 71 tests on each, using the native absltest runner.The full repository/Bazel CI was not run locally. This change does not include the separate shared-memory cleanup work in #1386, #1421 or #1422, and does not address exceptions that are themselves unpicklable.
📚 Documentation preview 📚: https://google-grain--1428.org.readthedocs.build/