Repository navigation
Conversation
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 #1479.
enable_async_delis process-wide and first-call-wins, but until now nothing recorded what was actually applied: the bound lived only as the initial value of a private semaphore, and a later call with different arguments returned silently and changed nothing. I ran into the same wall the issue describes while sizing shared memory for a prefetch pipeline, so here is a fix along the lines of the proposal in the issue.What this does:
AsyncDelSettings(num_threads,max_outstanding_requests), and aSharedMemoryArray.async_del_settings()classmethod that returns the settings in effect, orNonewhile deletion is still synchronous. It is also exported fromgrain.multiprocessing.enable_async_delnow records the settings it applies, after the existingmax(max_outstanding_requests, num_threads)normalization, under the lock it already takes, so the recorded bound is the bound actually in effect.enable_async_delcall with the same settings is a quiet no-op, same as today. A later call with different settings logs a warning through absl logging naming both the requested and the in-effect values, and leaves the first call's settings in place. I went with a warning rather than an exception becausemp_prefetchcallsenable_async_del(1)at every worker start, so raising there would break existing pipelines that enabled deletion earlier with their own bound._disable_async_delclears the recorded settings along with the pool and the semaphore.Tests: six new cases in
shared_memory_array_test.pycovering no settings before the first enable, the settings recorded by the first enable, the recorded bound after it is raised tonum_threads, a same-settings re-enable staying quiet, a conflicting re-enable warning and keeping the first settings, and the settings being cleared on disable. I ran the full file locally (after generating the proto bindings and building the extension the waysetup.pydoes): with this change, all 18 tests pass. With only the source change reverted and the new tests kept, the six new tests fail and the 12 pre-existing tests still pass.On the CLA: I have signed the Google Individual CLA and it is on file for my account, so that side is sorted. Happy to adjust the shape if you would prefer different names or a different signal for the conflicting call.