-
Notifications
You must be signed in to change notification settings - Fork 409
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
How to support bisect_ppx? #57
Comments
We can get started by using the ml syntax and setting up bisect depending on some user settings. We could also make jbuilder knows about bisect, but i'd rather not hardcode the knowledge of too many tools in jbuilder itself as it will become a maintenance nightmare. Hopefully later we can have some more modular configuration and allow individual packages to provide some kind of plugins |
OK I understand the sentiment about bloating the tool. But I do think that bisect_ppx is no less important than ppx_inline_tests and certainly no less important than ppx_bench. But I guess this all depends on the size of the patch for it. Are there concrete plans for a plugin api btw? Or is it something to think about post 1.0 |
I have some ideas (see #56), but I think this should indeed come post 1.0. For 1.0 I prefer to focus on the essential stuff. Nice user features that will require careful design can be added later |
I had a closer look at bisect_ppx and it seems to me that all we need to do the same as |
The tests would also need a |
Well as long as the ppx for bisect_ppx declares the runtime dependencies in the META file, it should be added automatically |
I'm highly interested in this, both as one of the maintainers of Bisect_ppx, and because we badly need to have usable coverage analysis in Lwt. Also, cc @rleonid. |
We need a way to:
conditionally when coverage is enabled. |
It's also possible to restructure Bisect_ppx in various ways, so let me know the constraint space. |
I suppose one easy way to do it would be to always specify
and jbuilder will pick it up automatically. |
I'm working on finishing porting Bisect to omp+jbuilder (aantron/bisect_ppx#117, started and nearly finished by @rgrinberg – thanks), so that it's at least usable in the
Before we release Lwt, we will manually remove the Bisect_ppx references. However, this isn't a user-friendly process, and not something most projects should be asked to do. So, I think we need a more sustainable solution. Let me know any other ideas for using Bisect_ppx with Jbuilder, or if I'm missing something in my description above. I'll be happy to further adapt the project, if needed. |
+1 Yep, I agree that the performance doesn't matter when actually wanting to run Bisect – but both the performance and the hard dependency matter if there is no nice way to remove Bisect for release. Another thing is, with the environment variable, if I am triggering some kind of recursive build of multiple dependencies, and some of them are also sensitive to the variable, I might get performance penalties, rebuilds, excess |
Ok, so Bisect_ppx |
Maybe this is short sighted, but I don't really see what's wrong with adding some hard coded bisect support to jbuilder. I imagine something as primitive as I'd be more sympathetic if this was an invasive change to jbuilder, but it doesn't seem like that to me now. |
With the flag, I'd be concerned that the user has insufficient control over which files get instrumented. At least, the code under test needs to be instrumented, and the tests don't. I'm not sure this will be easy to get right over all users with a single flag. |
The Jbuilder test is missing the no-instrumentation case until ocaml/dune#57 is resolved. Resolves #141.
I suppose that if support is hard-coded in jbuilder, we'd allow to write something like In this case, what we really want is add a ppx conditionally. There are other cases where this would be useful, such as a ppx tracer to print the names of every function called. We could add support for this in jbuilder. For instance you'd write |
That sounds quite reasonable. The only thing I would add is that I'd rather avoid environment variables, and have some way of triggering the condition by passing an argument to Jbuilder. |
Seems fine to me, we could have |
Yep. As long as ppxopts following This scheme might be insufficient for some more-exotic PPX out there, but I think it's enough for most usage of Bisect. cc @rleonid |
Under this scheme would
also be dynamic; in the sense that it is loaded only when the code is instrumented with |
I still think the current proposal suffers from having to add this annoying boilerplate in your jbuild files just for bisect support. Just imagine trying bisect some 3rd party package. It's especially annoying given that jbuilder should be able to tell what are libraries and what are tests. But I suppose this also gives you the flexibility to enable bisect conditionally only for a few libraries. In any case, I'm just happy we'll have something in the interim. |
If Jbuilder can be opinionated enough to do this with a flag and no modification to Jbuilder files, that's fine too. But the flag shouldn't be called |
What's the story regarding ppxopts? Currently jbuilder ignores this field |
The way to run this is: ``` BISECT_ENABLE=yes make -f Makefile.dune test-suite bisect-ppx-report -I _build/default -html coq-coverage `find . -name 'bisect*.out' ``` Note that support for bisect is still not very optimal c.f. ocaml/dune#57 , and in particular support for incremental runs is kinda broken, so running from a clean tree is recommended for now.
The way to run this is: ``` BISECT_ENABLE=yes make -f Makefile.dune test-suite bisect-ppx-report -I _build/default -html coq-coverage `find . -name 'bisect*.out' ``` Note that support for bisect is still not very optimal c.f. ocaml/dune#57 , and in particular support for incremental runs is kinda broken, so running from a clean tree is recommended for now.
The latest consensus solution seems to have lost sight of one objective, that to me (a user of |
I wondered about that. Profiles are a bit lighter though. Originally, additional contexts where tied to an opam switch, so switching contexts would have required installing a new opam switch. At the same time, the concept of release/dev modes is universal and shouldn't be tied to what switches the user has installed. In any case, the shared cache will change a bit the equation here, as switching back and forth between different profiles will eventually become fast. |
I have also wondered about the necessity of both contexts and profiles, as IME most contexts are added in order to specify a different profile. It seems necessary to have an additional context in order to have a separate copy of the build artifacts produced using a different profile. And the fact that a separate context enables building multiple profiles in parallel is important, and it is useful to be able to use e.g. an flambda compiler only in release profiles. But perhaps that sort of functionality could usefully be disentangled with e.g. opam switches.
|
But as far as the coverage proposal is concerned, if I do the normal development edit/compile/test loop for a while, and then want to check coverage, I still have to do a |
Well, you don't need to run |
This will be false. Dune dependency tracking will take care of rebuilding the needed files, and again when not doing coverage anymore. The dependencies of files will change to include This is an explicit goal of the integration (and has always been), and I wouldn't approve integration that didn't have this property. All discussion above has had this as a basic assumption. You're not the only one that would be bothered by not having this :) |
@diml :
I've been reading and re-reading the dune doc since before I first commented here, but I don't see how this would work. The only two documented ways to define a context are:
I must be missing something basic, but the doc must be failing to explain something basic. |
You are right, the doc needs a refresh here. You can actually write this since a while:
|
@diml : Looks promising! I'll try it soon. Thanks. |
Well, it looked promising at first, but now I'm confused again. Should I perhaps start a new issue, since this is only tangentially related to bisect_ppx? |
Opening a new issue seems good |
@diml, @rgrinberg, I'd like to ask you to address this issue (as opposed to me; I was previously looking into fixing it). The problem with me doing it is that, IIRC, when I looked at it in the summer, I found that the expander needed to replace variables depends on having a context, dependency information was already computed by the time a context was created, and there was no reasonable way to amend it. As a result, there was no (simple) way to introduce a new dependency from variable expansion. It seems necessary to introduce the dependency only after expansion, since a non-coverage build should not require Bisect to be installed — a typical non-coverage build would be any release build during normal installation by a user. On the other hand, a coverage build should depend on Bisect, including so that a rebuild is triggered if coverage is enabled and Bisect has changed. When I considered how to fix that, it seemed that a pretty extensive refactoring would be necessary, including of LibDB. I don't think I can, from my outsider position, efficiently make the design decisions such a refactoring would entail. |
The master of dune now has a It doesn't yet have a file exclusion mechanism or a way to specify flags, but the basis is here and such features can now be added incrementally. In the meantine, please test it and report feedback! |
bisect_ppx is an odd ppx rewriter because you only want it active when you're measuring coverage. Usually when you're running your test suite. Dually, the tests only require the bisect ppx runtime when measuring the coverage. Ideally, this is something jbuilder would support on a global basis with minimum hassle. @diml any advice on might jbuilder accommodate bisect_ppx?
The text was updated successfully, but these errors were encountered: