Skip to content
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

experiment for #188 and #429 -- insert show after error in silent mode #467

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hendriktews
Copy link
Collaborator

@hendriktews hendriktews commented Mar 12, 2020

This is my first partial take on issue #188 and Pierre's example in PR #429
This PR reliably inserts a show command after an error. The following points still need to be solved:

  • keep the error message visible and only update the goals buffer in the background
  • only insert this show command when the error is hit in silent mode or when the previous command was just unset silent.

This can be done, but would require some new features and additional state in delayed goals/response processing (proof-shell-handle-delayed-output). However, I would question if this makes sense, because I don't see an advantage when running silent. For my biggest files, which take about 11 seconds to process interactively (≈3000 lines), the speedup of silent processing is less then 5%, just a fraction of a second.

@hendriktews
Copy link
Collaborator Author

See #468 for measuring the difference between silent and non-silent processing.

@hendriktews
Copy link
Collaborator Author

@Matafou @cpitclaudel Do you have an opinion here? Shall we make delayed response/goal processing more complicated or simply switch to non-silent?

@cpitclaudel
Copy link
Member

I will have a look very soon. Thanks for working on this.

@Matafou
Copy link
Contributor

Matafou commented Apr 6, 2020

Thanks Hendriks!

My experiments on the silent stuff date back to more than a decade, maybe two. It was mostly dependent on the size of goals (times the number of tactics processed). Do your tests use big goals (say one page long)? The fact that coq was displaying the goal after each tactic was a serious bottleneck when goals were big. But again this was in the 2000's I think, so maybe this is negligible now.

Other protocols have all switched to silent mode: never show goals unless a "Show" is issued by the ide. It seems the most reasonable to me.

@cpitclaudel
Copy link
Member

Concretely, what does silent processing do now that goal printing isn't automatic anymore?

@hendriktews
Copy link
Collaborator Author

@Matafou: Maybe my goals are not so long. In one of the tested files I see about 1400 goals printed, maximum size 88 lines, average 41, and about 700 goals more than 41 lines. Do you have a big file with longer goals?

@cpitclaudel: I am not sure I understand your question. Silent processing issues Set Silent and Unset Silent commands. Without this (eg, with setting full-annotation), all goals are fully printed in the *coq* buffer.

@cpitclaudel
Copy link
Member

cpitclaudel commented Apr 6, 2020

@cpitclaudel: I am not sure I understand your question.

I thought recent Coq versions printed a lot less when processing, but it seems I was wrong about this.

@Matafou
Copy link
Contributor

Matafou commented Apr 10, 2020

@cpitclaudel what you guessed is not true currently, but I think we wan tto switch to it (unless async comes to maturity meanwhile).

@hendriktews

  • keep the error message visible and only update the goals buffer in the background

... without triggering your Show again. I remember having a hard time with this one. This is where pg generic mechanism makes things a bit difficult.

  • only insert this show command when the error is hit in silent mode or when the previous command was just unset silent.

...and we are inside a proof.

@hendriktews
Copy link
Collaborator Author

The approach of this PR is to submit a Show command after the error to update the goals buffer while keeping the error message somehow visible.

A completely different approach would be to remember the last successful command and, in case of an error, retract to before that command and execute the last successful and the failing command again (of course not silent). I have the impression that this alternative approach would be simpler. Or do I oversee something?

@Matafou
Copy link
Contributor

Matafou commented Apr 11, 2020

If the last successful command takes long this may feel frustrating.

@hendriktews
Copy link
Collaborator Author

If the last successful command takes long this may feel frustrating.

Maybe, but note that this does not happen during interactive development, because there you are asserting single commands and do not switch to silent. Do you have a lot of long running commands? And what does long mean?

@Matafou
Copy link
Contributor

Matafou commented Apr 13, 2020 via email

@Matafou
Copy link
Contributor

Matafou commented Apr 13, 2020

Actually it is generally more frequent during proof development, while e.g. type classes have not yet been fine tuned for your purpose.

@hendriktews
Copy link
Collaborator Author

@Matafou : I would like to repeat to ensure I understand: When fine tuning type classes, you assert bigger chunks (so Coq is switch to silent), in these chunks one command is likely to fail and the command before the failing one takes several seconds to process. Right?

@Matafou
Copy link
Contributor

Matafou commented Apr 15, 2020

@Matafou : I would like to repeat to ensure I understand: When fine tuning type classes, you assert bigger chunks (so Coq is switch to silent), in these chunks one command is likely to fail and the command before the failing one takes several seconds to process. Right?

Yes. Actually even after fine tuning type classes some single commands still take a long time to process.

@Matafou
Copy link
Contributor

Matafou commented Apr 15, 2020

  • keep the error message visible and only update the goals buffer in the background

Maybe the simplest is to store the error message and re-insert it afterward?

  • only insert this show command when the error is hit in silent mode or when the previous command was just unset silent.

Maybe this is not so important: issuing a superfluous Show is probably not a problem?

@Matafou
Copy link
Contributor

Matafou commented May 20, 2020

@hendriktews I am playing with your version and it seems to work quite well.

This is my first partial take on issue #188 and Pierre's example in PR #429
This PR reliably inserts a show command after an error. The following points still need to be solved:

  • keep the error message visible and only update the goals buffer in the background

At first glance this seems to work already, doesn't it?

  • only insert this show command when the error is hit in silent mode or when the previous command was just unset silent.

This is not so important: making one spurious Show is OK imho if it does not reset the response buffer.

Actually it is the occasion to add a few other missing "Show": Currently when pg has a bunch of commands to process it Set Silent, plays all commands except the last one, then unset silent, then plays the last command.
This is not accurate: sometimes the last command is "Proof", or a comment, and the goal is not displayed. What we should really do is set silent, play everything, if the last prompt says there is still a goal, do Show (without reseting response buffer).

@hendriktews hendriktews changed the title experiment for #188 and #429 -- do not merge experiment for #188 and #429 -- insert show after error in silent mode May 20, 2020
@hendriktews
Copy link
Collaborator Author

hendriktews commented May 20, 2020 via email

@Matafou
Copy link
Contributor

Matafou commented May 20, 2020

OK I will try to make something from your PR. I never did this before, do I just push directly on your branch?

@erikmd
Copy link
Member

erikmd commented May 20, 2020

@Matafou

OK I will try to make something from your PR. I never did this before, do I just push directly on your branch?

Yes, you can just add hendrik's repo as another remote:

git remote add hendrik [email protected]:hendriktews/PG.git
git fetch hendrik

and checkout/push as usually:

git checkout -b pr-467 -t hendrik/issue-188-pr-429

(given GitHub knows this branch from hendrik is a "PR source branch", you will automatically have write rights for this remote branch)

@Matafou
Copy link
Contributor

Matafou commented May 20, 2020

OK thanks.
Currently your branch falls into a loop if an error occurs when not in a proof (Show sends an error which triggers the same piece of code again, which sends another Show, etc).
I know how to fix this, but now I realize that what you implemented is roughly the same as what proof-shell-empty-action-list-command has been made for:

(when (and (null proof-action-list)

So maybe we should adapt this part instead.
Still studying things.

proof-state-change-pre-hook happens earlier than
proof-state-change-hook, i.e. before proof-done-advancing. This should
be used to register information in the currently processed span before
proof-done-advancing classifies it.

Historically PG design was to gather these information during
proof-done-advancing (or in its hook called at the end) by just
looking at the command statement. But it is often useful to look at
the output (messages and/or prompt) to gather more accurate
information. Some of this information may be needed DURING
proof-done-advancing. Hence this early hook.
hendriktews and others added 3 commits May 28, 2020 14:25
new, generic interface for priority action items, see
proof-priority-action-list and proof-add-to-priority-queue, for
asynchronously adding commands to the head of proof-action-list
@Matafou
Copy link
Contributor

Matafou commented May 28, 2020

This should work correctly now.

  • I had to first commit 5807535 to have the information about being in proof mode at this point of the code.
  • There are still cases where the goal is not displayed: If a bunch of commands sent to the prover ends with a comment or Proof., no goal is printed since only this (silent) span is processed with Silent Off. To fix this correctly I need to figure out how to detect that no goal were displayed since the beginning of the bunch. Or maybe just check the goal buffer is empty?

@Matafou
Copy link
Contributor

Matafou commented May 28, 2020

  • To fix this correctly I need to figure out how to detect that no goal were displayed since the beginning of the bunch. Or maybe just check the goal buffer is empty?

Or wait for our switch to "always silent, always ask for Show", where we will always send a Show after a command in proof mode.

@Matafou
Copy link
Contributor

Matafou commented May 28, 2020

by the way @erikmd @CyrilAnac my previous force-push had a spurious debug message left in the code and it made the CI test fail apparently, which is fine, but when going to the log page (https://github.com/ProofGeneral/PG/runs/714045321?check_suite_focus=true) I had a serious bug in my browser due (I guess) to a very long log. This made the diagnostic a bit painful. Do you think this fixable?

@erikmd
Copy link
Member

erikmd commented May 28, 2020

@Matafou

I had a serious bug in my browser due (I guess) to a very long log.

I can't see the log either (I only see This file has been truncated. […] and it seems the CI job lasted during 6h :) so maybe the simplest solution is:

  • you disable the debugging feature that is very verbose and re-force-push
  • or you run the following command locally to have the full log:
    cd .../PG/ci && ./test.sh
    (this doesn't require having docker installed)

@Matafou
Copy link
Contributor

Matafou commented May 28, 2020

I forced pushed a commit and it solved the problem, if I have time I will try to understand why the test took so long. It cannot be just because of the message (one word), can it?

@erikmd
Copy link
Member

erikmd commented May 28, 2020

It cannot be just because of the message (one word), can it?

maybe the issue was some kind of infinite loop (which would explain the 6h+ build time?) adding zillions of copies of the word at stake? but I didn't have a look on the code you mention so I don't know exactly

@erikmd
Copy link
Member

erikmd commented May 28, 2020

In any case, if you note somewhere the SHA1 of the commit at stake, we'll be able to try reproducing the issue with the ./ci/test.sh script locally

@Matafou
Copy link
Contributor

Matafou commented May 28, 2020

I will. But I think I know the problem. There was indeed a loop in some cases in Hendrik's first try, and my force push did not fix it yet.

hendriktews added a commit to hendriktews/PG that referenced this pull request Jun 6, 2021
Most of these tests currently fail because of different instances
of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467.
hendriktews added a commit to hendriktews/PG that referenced this pull request Jan 23, 2024
Most of these tests currently fail because of different instances
of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
hendriktews added a commit to hendriktews/PG that referenced this pull request Jan 28, 2024
Most of these tests currently fail because of different instances
of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
hendriktews added a commit to hendriktews/PG that referenced this pull request Feb 7, 2024
Most of these tests currently fail because of different instances
of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
hendriktews added a commit that referenced this pull request Feb 18, 2024
Most of these tests currently fail because of different instances
of #568, see also #429, #467, #103.
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