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

ShufflePlug : Fix specific bug with matching names #5941

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

danieldresser-ie
Copy link
Contributor

As discussed this morning, you would expect a Shuffle mapping R to R with a missingSourceMode of Black to create a channel R with black in it if it didn't already exist, but due to a bug, this wasn't working.

@@ -142,7 +145,7 @@ T ShufflesPlug::shuffleInternal( const T &sourceContainer, const T *extraSources
if( ! dstPattern.empty() )
{
const std::string dstName = scope.context()->substitute( dstPattern );
if( srcName != dstName )
if( srcName != dstName || usingExtraSource )
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering why we had this srcName != dstName check in the first place. If we're doing a series of shuffles, any of which might have written to dstName already, it's not like we're detecting a no-op here. As far as I can tell, the only unit test that is affected is ShufflePlugTest.testIgnoreIdentity, which complains that multiple wildcard-matched sources are being shuffled to the same destination if we remove the check. But that seems like a pretty reasonable response to the input data, and it's not like the check would have helped if there were three members in the input data.

Your change is obviously more limited in scope, and I'd be happy to accept it, but I wonder if you might be feeling bold and want to rip out the check entirely? @murraystevenson, do you have any thoughts on this? Perhaps I'm missing an obvious reason why we must keep the check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My assumption was that this was just a minor optimization. If you consider a very simple ( and sloppy ) shuffle, like: R = R, G = G, B = __black, then having the check doesn't affect the result, but does mean that two channels get a slightly earlier passthrough ( since there is no shuffle created in the destinationContainer ).

But maybe I'm wrong that the intention was just a tiny optimization - if ShufflePlugTest.testIgnoreIdentity is failing, that implies that someone did think about this behaviour. I don't really like the behaviour though, I guess it's trying to be helpful, but it just seems inconsistent. Currently:

  • if we shuffle R,G,B to R, R ends up set to B ( since it was last )
  • if we shuffle R,G,B to G, G ends up set to B ( since it was last )
  • if we shuffle R,G,B to B, B ends up set to G ( second last, because B was ignored )
    I think that behaviour would be a lot easier to explain if we just ditched the check.

So yeah, as far as I can tell, everything is both simpler and better if we remove the check. And I guess this is already targetting main, so there's probably no reason to hold back.

Copy link
Member

Choose a reason for hiding this comment

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

That gets my vote, unless @murraystevenson or @ericmehl has any objections.

Copy link
Contributor

Choose a reason for hiding this comment

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

No objections. Simplicity gets my vote.

@danieldresser-ie
Copy link
Contributor Author

Per conversation, I've completely switched this to just remove the counterproductive conditionals.

@johnhaddon johnhaddon merged commit 6a074fc into GafferHQ:main Jul 10, 2024
5 checks passed
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.

3 participants