Skip to content

Fix typo in default targetv in clj-frontend/run-workflow - #149

Merged
dirtyvagabond merged 1 commit into
Factual:developfrom
morrifeldman:targetv-typo
Oct 28, 2014
Merged

dirtyvagabond merged 1 commit into
Factual:developfrom
morrifeldman:targetv-typo

Conversation

@morrifeldman

Copy link
Copy Markdown
Contributor

Switches the default targetv from ["=..."] to ["..."] in clj-frontend/run-workflow.

Switches the default targetv from ["=..."] to ["..."] in clj-frontend/run-workflow.
dirtyvagabond pushed a commit that referenced this pull request Oct 28, 2014
Fix typo in default targetv in clj-frontend/run-workflow
@dirtyvagabond
dirtyvagabond merged commit 84778e0 into Factual:develop Oct 28, 2014
@dirtyvagabond

Copy link
Copy Markdown
Contributor

thanks @morrifeldman

@amalloy

amalloy commented Oct 28, 2014

Copy link
Copy Markdown
Contributor

Is this really a correct change? In drake itself the target list defaults to =.... This is a ... with the = prefix, which means "build the named target but not its dependents or dependencies". I'm not entirely sure what that's supposed to mean with ..., since that's "all targets". But I don't know that we should be changing this just because we don't understand it: it looks like something that someone put there on purpose.

@aboytsov

Copy link
Copy Markdown
Contributor

Alan, you may be right. I have a very vague recollection of the =... thing. I should have probably left a comment. If I remember correctly, one reason for it is performance. With ... Drake will go on to expand all targets' dependencies, which will result in a lot of unnecessary checks as the original algorithm was pretty dumb. With =..., no dependency checks will be performed, which is OK, since all targets are going to be built anyway.

The other (and somewhat related) reason might have to do with build order determinism. Now these details are really foggy in my mind, but if I remember correctly, if you have a Drakefile with A -> B and you run Drake with =B =A it will be smart enough to still run A first, because B depends on it, i.e. it will do the minimum amount of shuffling to ensure that targets are never built before their dependencies, in case both are specified in the batch. If this is not the case then =... as the default target may not work correctly and should be fixed everywhere. But if it is the case, =... will better preserve the build order in the Drakefile under one more condition: that Drake honors the order in which inputs were specified in targets with multiple inputs.

This is somewhat confusing so I'll give an example. Imagine Drakefile with 3 targets: A, B -> C. But the order in which they are specified in it is: C, B, A (which is perfectly valid as I remember). Then if Drake honors input order, when you run C it will run A, B and then C. This is arguably more flexible because it gives the developer finer control on which to run first: A or B, when building C. But if Drake doesn't care about input order, and only looks at the order targets are specified in the Drakefile, when you run C, it will still run as B, A and then C because B is listed before A.

Now if you build all targets anyway, it makes more sense to preserve the order in the Drakefile as much as possible, so in this example, =... will expand to =B =A =C while ... will ultimately expand to =A =B =C (by first expanding to C B A, then to =A =B =C B A etc.). This would, of course, still be OK, but less consistent with the idea of "build all targets in the order they're specified in the Drakefile honoring dependencies as necessary".

If my theory is correct (and I don't really remember), all ... should be treated as =... and honoring of input order should be documented in the spec (something like "when building a target with multiple inputs, Drake tries to build dependencies in the order they were listed, unless they are also specified in the batch in which case Drake gives precedence to order in the batch"). The alternative is to say Drake always tries to preserve Drakefile order and ignores input order, in which case ... and =... are semantically equivalent and it's just a small performance optimization. But it's somewhat less intuitive and can be surprising when building a single target with multiple inputs such as in the example I gave above.

Phew, sorry it's a mouthful. :)

@morrifeldman

Copy link
Copy Markdown
Contributor Author

Sounds like it wasn't a typo on my part. I must have picked up =... from drake.core/drake and used it in clj-frontend/run-workflow. When I ran into "=..." recently and didn't understand it, I assumed it was a typo on my part, but based on what Artem says, it sounds like it would be best to revert this commit.

dirtyvagabond pushed a commit that referenced this pull request Nov 14, 2014
@dirtyvagabond

Copy link
Copy Markdown
Contributor

Thanks @aboytsov for the write-up, that was some enjoyable reading. :-)

My response:
de5e10e

@dirtyvagabond

Copy link
Copy Markdown
Contributor

oh, and:
0b6ac05

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.

4 participants