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

Fix too slow "End", "Ctrl-V", etc. by omitting unnecessary lz-analyze #289

Merged
merged 2 commits into from
Jun 20, 2018

Conversation

kaorahi
Copy link
Contributor

@kaorahi kaorahi commented Jun 5, 2018

"Ctrl-V" takes several minutes on my machine.
It is caused by "lz-analyze" after every "play ..." and "undo".
You may not notice this issue if your machine is fast.

The first patch introduces a command queue and defers sending commands
until leelaz responds to the previous command.
Unnecessary "lz-analyze", that will be stopped immediately by the next command,
is removed from the queue before sending it to leelaz.

I also add the second patch for preventing possible hang-up in unexpected cases
that cannot happen theoretically.

$ git log --oneline | head -n 1
1912f4a Merge pull request #272 from kaorahi/komi_sgf

@bittsitt
Copy link
Contributor

bittsitt commented Jun 6, 2018

This seems a bit hacky and prone to weird errors down the head that leaves us scratching our heads. Why not just disable pondering, move to end (or whatever) and enable it again?

Example:

            case VK_END:
+               Lizzie.leelaz.togglePonder();
                while (Lizzie.board.nextMove()) ;
+               Lizzie.leelaz.togglePonder();
                break;

@kaorahi
Copy link
Contributor Author

kaorahi commented Jun 6, 2018

Because...

(1) It is not restricted to VK_END and VK_V. There are many commands
that need such treatments, and more commands will be added in future.
I could not list all such commands, but this queue fixes them at once.

(2) Lizzie has to remember the pondering status before the command and
restore it afterward if we use togglePonder-strategy. We then need
more code in addition to simple togglePonder().

(3) This queue supports auto-repeated keys naturally. Namely,
pondering is stopped when we begin to hold down up-arrow key, and
pondering is restarted immediately when we release up-arrow key. If
we use togglePonder-strategy, we need additional code for the
KeyReleased event to realize such a smart behavior.

@featurecat
Copy link
Owner

I will review this a little more before merging.

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.

3 participants