-
Notifications
You must be signed in to change notification settings - Fork 415
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
Implement instrumentation RFC #3535
Conversation
src/dune/lib.ml
Outdated
let pps = | ||
let resolve = | ||
match db with | ||
| None -> assert false (* FIXME ??? *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db
argument is None
if allow_overlaps
is true
further below. Not sure what this is supposed to be for, so I didn't handle this case yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's just an artifact of using Lib_name.t
for comparison.
Ok, that seems like a good change anyway, |
Regarding |
Answering myself: it's the |
@nojb I'm adding |
Yes, thanks. I will give the final touches shortly (I was waiting for confirmation of the approach first, which we did during the last meeting). |
4f8d3fb
to
1df02eb
Compare
1df02eb
to
75faa82
Compare
I have finished all the remaining points (including doc and tests), and the PR is ready for review (I removed @aantron If you have the time it would be great if you could give it a test drive as well with |
75faa82
to
309f9ce
Compare
@rgrinberg could you do the code review? @nojb, just one suggestion regarding the documentation: it seems to me that defining an instrumentation backend is a more "expert" feature. i.e. most users will only be faced with using instrumentation and will never define their own backend. So personally I would put the documentation about defining a backend at the end and start with the more general usage. WDYT? |
Sounds good, I'll amend. By the way, the CI failure is that as a side-effect of this patch, |
Ack, I was wondering if we should just accept this change of semantic, but not accepting an empty |
Checking for a syntactically empty |
IIRC, we should be able to do this check at parsing time. i.e. the flags and pp names are split textually. |
ea2d216
to
5229892
Compare
OK, I pushed a commit rearranging the doc and another checking for an empty |
9b3cbcc
to
550f445
Compare
src/dune/findlib/findlib.ml
Outdated
@@ -565,7 +566,8 @@ let all_packages t = | |||
- A memoized function for finding packages by names (see [find]). | |||
|
|||
- A [Memo.Lazy.t] storing the set of all packages (see [root_packages]). *) | |||
let create ~stdlib_dir ~paths ~version ~lib_config = | |||
let create ~paths ~version ~lib_config = | |||
let stdlib_dir = lib_config.Lib_config.stdlib_dir in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version
seems to be present in Lib_config.t
. Perhaps we should unify these.
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Rudi Grinberg <[email protected]>
It's already passed there as a string Signed-off-by: Rudi Grinberg <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
… lib deps Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
c9cbca9
to
028f70e
Compare
I rebased the PR. I also did some small tests with Travis seems not to be working. Other than that, feel free to merge if you think it is OK. |
Indeed, for the attachment I suppose it's whatever makes the most sense. In general, I expect that authors will attach it to the library named after the package. I've clicked on "Update branch", let see what happens with Travis |
All the checks are passing now, thanks @nojb for this work! BTW, once a new version of Dune and landmarks and/or bisect_ppx are released, a blog post to announce the new feature would be great :) |
Thanks! OK for the blog post, I am a little short on time right now, but I will try to co-opt @mlasson :) |
@rgrinberg Sorry, but it looks like I forgot to update the CHANGES entry for this one (it still contains the mention of |
That’s not a problem. Just send a PR now :)
Rudi.
…On Aug 13, 2020, 10:29 PM -0700, Nicolás Ojeda Bär ***@***.***>, wrote:
@rgrinberg Sorry, but it looks like I forgot to update the CHANGES entry for this one (it still contains the mention of bisect_ppx of #3403).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
This PR implements the instrumentation RFC #3526.
It mostly builds upon what was done in #3403. The main difference is that instrumentation backends are referred to by their runtime library. Individual commits are discussed at the end.
The fact that we refer to instrumentation backends by the name of their runtime library complexifies the implementation considerably, as knowing the precise list of ppx preprocessors (the
pps
field) must be delayed until libraries can be resolved.Thinking about this point, and also from the point of view of having simple semantics, I wonder if we shouldn't drop the emphasis on "instrumentation" as a concept, and just think of the feature as a way to turn off ppx rewriters easily on a per-context or per-workspace basis. This is all the implementation does after all.
If we go this way, we could simplify the syntax quite a bit, dropping the
instrumentation.backend
field (any ppx would be eligible), and merge theinstrumentation
field withpps
field, as in(we would use a different name than
instrumentation
). It would also clears up a bit the semantics, since right now it is not clear how the list of instrumentations are merged with the list of "ordinary" ppx preprocessors.Additionally, we would no longer refer to the ppx by the name of their runtime library but by their own name, which would simplify the implementation as resolution of libraries is no longer needed. Maybe a bit uglier from a CLI perspective, but semantically clearer in my opinion and simpler.
Detailed description of the commits
There is some back and forth in the code which I would clean up before merging, but I left it as is for a first review as it illustrates some of the issues discussed above.
The main issue, as mentioned above, is that one must wait until resolution of libraries is possible in order to know the precise list of ppx preprocessors.
Commit 1, 2 and 3 are routine: adding the
instrumentation.backend
field tolibrary
, adding theinstrument_with
field to the workspace file, and CLI command-line logic.Commit 4 is the main part of the PR. Currently, the contents of the
pps
field are stored as a(Loc.t * Lib_name.t) list
obtained at parsing time (theLib_name.t
is the name of theppx
preprocessor). However, we can no longer do this in this PR, because we do not know the name of theppx
preprocessor at parsing time, only that of the associated runtime library. So we must keep an intermediate ("unresolved") data structure that will eventually "resolve" to this list of ppx rewriters.In this commit, I introduce a new type
where the
Ordinary
case corresponds to appx
rewriter as written by the user, andInstrumentation
corresponds to one coming from(instrumentation ...)
field (the payload is the library name that declares theinstrumentation.backend
field). This new type needs to be propagated everywhere until the point where theInstrumentation
case can be resolved to a "ordinary" ppx name.Commits 4 and 5 extend the above to libraries. There is a dependency issue because one must keep the "unresolved"
Dune_file.Preprocessor_map.t
in theLib_info.t
created at parsing time so that it can be "resolved" insideLib
. The problem is thatDune_file
already depends onLib_info
, so this is not possible. To work around this, I moved the wholePreprocess
andPreprocess_map
modules ofDune_file
to their own modulePreprocess
.Just to insist on this point: you can see how the implementation would be much simpler if we just referred to ppx's by their names instead of going through their runtime libraries.
What is left to do
Reimplement Enable/disable bisect_ppx via dune-workspace #3403 in terms of this PRlandmarks
while writing the code)