Tool for minimizing examples

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Tool for minimizing examples

crockeea
Devs: as I'm sure you know, the hardest part of reporting a GHC bug is finding a minimal example that triggers the bug. When I initially trigger a bug in my large code base, my workflow is something like:

 1. write a driver that triggers the bug
 2. do manual dead code elimination by removing unused files and functions
 3. "human required" step to figure out what can be trimmed to further minimize
 4. go to step 2 until example is simple enouogh

Since I work on a large library (>60 modules) and also report a fair number of bugs, I spend a nontrivial amount of time on step 2, which is completely mechanical. It would be nice to have a tool that can help out. Specifically, something that takes a "driver" file, and produces a copy of the code contents to a new directory sans unimported files, and unused functions from imported files.

Ideally, this tool would make a "closed universe" assumption so that exported functions can also be eliminated as dead, if they are never used elsewhere. A bonus feature would be to remove unused imports, and even unused build-depends from the cabal file.

Are there any tools out there that can do any portion of this process for me? Perhaps it is possible to output contents after the compiler does a DCE pass?

Regards,
Eric Crockett


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Tool for minimizing examples

Edward Z. Yang
I asked about this on Twitter a while back
<https://twitter.com/johnregehr/status/768693836616912898> and John
Regehr suggested that we give C-reduce a try.  I have not
yet but if you try it out I'm quite curious to see what
happens.

Edward

Excerpts from Eric Crockett's message of 2016-10-26 00:27:11 -0400:

> Devs: as I'm sure you know, the hardest part of reporting a GHC bug is
> finding a minimal example that triggers the bug. When I initially trigger a
> bug in my large code base, my workflow is something like:
>
>  1. write a driver that triggers the bug
>  2. do manual dead code elimination by removing unused files and functions
>  3. "human required" step to figure out what can be trimmed to further
> minimize
>  4. go to step 2 until example is simple enouogh
>
> Since I work on a large library (>60 modules) and also report a fair number
> of bugs, I spend a nontrivial amount of time on step 2, which is completely
> mechanical. It would be nice to have a tool that can help out.
> Specifically, something that takes a "driver" file, and produces a copy of
> the code contents to a new directory sans unimported files, and unused
> functions from imported files.
>
> Ideally, this tool would make a "closed universe" assumption so that
> exported functions can also be eliminated as dead, if they are never used
> elsewhere. A bonus feature would be to remove unused imports, and even
> unused build-depends from the cabal file.
>
> Are there any tools out there that can do any portion of this process for
> me? Perhaps it is possible to output contents after the compiler does a DCE
> pass?
>
> Regards,
> Eric Crockett
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

RE: Tool for minimizing examples

GHC - devs mailing list
In reply to this post by crockeea

Great question.

 

And just to add: I _really_ appreciate the fact that you make small examples.  Thank you.

 

Simon

 

From: ghc-devs [mailto:[hidden email]] On Behalf Of Eric Crockett
Sent: 26 October 2016 05:27
To: ghc-devs <[hidden email]>
Subject: Tool for minimizing examples

 

Devs: as I'm sure you know, the hardest part of reporting a GHC bug is finding a minimal example that triggers the bug. When I initially trigger a bug in my large code base, my workflow is something like:

 

 1. write a driver that triggers the bug

 2. do manual dead code elimination by removing unused files and functions

 3. "human required" step to figure out what can be trimmed to further minimize

 4. go to step 2 until example is simple enouogh

 

Since I work on a large library (>60 modules) and also report a fair number of bugs, I spend a nontrivial amount of time on step 2, which is completely mechanical. It would be nice to have a tool that can help out. Specifically, something that takes a "driver" file, and produces a copy of the code contents to a new directory sans unimported files, and unused functions from imported files.

 

Ideally, this tool would make a "closed universe" assumption so that exported functions can also be eliminated as dead, if they are never used elsewhere. A bonus feature would be to remove unused imports, and even unused build-depends from the cabal file.

 

Are there any tools out there that can do any portion of this process for me? Perhaps it is possible to output contents after the compiler does a DCE pass?

 

Regards,

Eric Crockett

 


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Tool for minimizing examples

Ben Gamari-2
In reply to this post by crockeea
Eric Crockett <[hidden email]> writes:

> Are there any tools out there that can do any portion of this process for
> me?

This is a good question. Unfortunately I don't know of any; I do my
minimizations by hand.

> Perhaps it is possible to output contents after the compiler does a DCE
> pass?
>
Unfortunately I don't believe this would be helpful as DCE isn't done on
the Haskell syntax tree representation and we have no external
representation of Core.

That being said, you might be able to write something without too much
difficulty using the GHC API. I have a small toy project that I once
used to explore the API; you might find that it's a useful place to
start [1].

Sorry for the not-so-helpful response!

Cheers,

- Ben

[1] https://github.com/bgamari/play-type-search

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

signature.asc (463 bytes) Download Attachment