-
Notifications
You must be signed in to change notification settings - Fork 17
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
Too much RAM and CPU usage when printing semi-large goals #94
Comments
😍 this example is so small, thanks a lot :) |
Some quick notes: The CPU profile looks like this:
+ ~10% in GC time. Newer Emacsen can use a native JSON parser, and we can disable syntax highlighting for large goals; so we could improve here. The memory profile looks like this:
This one is trickier: we might save memory on JSON, but these allocations are strings actually printed by F*. Now comes the part where I blame F* :) The problem is the pretty-printer, AFAICT:
This printing strategy is quadratic in the number of calls to And indeed:
Having 53MB of JSON to parse slows Emacs down quite a bit, and it slows F* correspondingly because F* waits for Emacs to read the output before resuming. Running on the CLI is about twice as fast as running under Emacs, and I suspect that's because F* block while waiting for Emacs to empty the shared pipe. We could consider a queue design in which F* doesn't block while writing to Emacs. Of course, all of this doesn't say why Emacs ends up consuming so much memory :) I'll investigate this when I'm back from vacation. |
Another thing: Emacs is bad at long lines. Like, really bad. So these long lines will tend to slow the display to a crawl. I suspect that's the 100% CPU use you were seeing |
Regarding RAM usage: are you running with fstar-debug set? With it I observe linearly growing ram as I replay the snippet over and over, which is expected (the full history of input and output is kept), but without it every time I kill the goals buffer memory usage reverts to what it was before running the snippet. Each run of the snippet allocated an extra 50MB, but that's roughly expected given the size of the output. |
Hey Clément, documenting the issue we spoke about on slack.
This file
verifies in the command line pretty quickly:
However, in the interactive mode, emacs (not F* for once!) seems to take a huge amount of time to print each goal, about 3 seconds each! This is the (wall clock) time it takes to check the last definition:
It in fact takes much longer than F* itself takes for the whole run, as
top
shows. Also, emacs memory consumption doubles after the run, and killing the buffers (plus GC'ing) doesn't seem to help. Here's a before and after of checkingtest
:Of course it can be made worse by making the VC larger, for instance by uncommenting the lines above. This was seen while running the separation logic tactics, and it's much worse there. I think it reaches about 10 seconds per dump, and I've seen emacs take over 40GB of RAM+swap in a clean run. Hopefully this small example is enough to diagnose, but I can provide a repro for the bigger example if not.
The text was updated successfully, but these errors were encountered: