-
Notifications
You must be signed in to change notification settings - Fork 1k
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
'Real time' pondering output for GUI like Lizzie #1240
Conversation
Generate more output during the pondering phase to let GUI display that information in a more 'real time' fashion.
Thanks. The ~begin and ~end outputs aren't FULLY necessary but we'll see what gcp thinks. something like newlines might be fine. of course, I like the ~begin flags 😁 |
last_update = elapsed_centis; | ||
|
||
if (cfg_rt_log) { | ||
myprintf("~begin\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random marker? Nah.
|
||
if (cfg_rt_log) { | ||
myprintf("~begin\n"); | ||
dump_stats(m_rootstate, *m_root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't threadsafe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to check if taking the root node lock early on in dump_stats still allows the engine to work. You'll get a performance dip every time you dump, but that's unavoidable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that doesn't work, you can rewrite the "root moves" dumping part of dump_stats into a separate function and call that instead. You can't use the sort_root_moves code there though, you'll have to write some code that gets the top x moves and remember them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could I make it thread safe? Is there an existing lock I could use? What code should I use (I don't know enough C to know how to do it)?
I would advise designing this more like UCI works: the engine advertises a "dump_move_stats" command in list_commands, which the GUI uses to probe that capability. That command could then either be send during the search (trickier to implement), or the GUI could send "dump_move_stats 10" to enable periodic dumping every xx centiseconds. You can then add some markers or whatever format you want for easy and flexible display/parsing, as it will only be sent when the GUI requests it. Whatever you do do not add command line options! That's terrible design for these kind of features because you can't steer them without reloading the entire engine. |
Does https://github.com/Cabu/leela-zero/tree/Lizzie2 could be the way to go? |
If you want to handle the command while the search is running it needs special handling. That's why I said that this option is "trickier to implement". |
For Lizzie use, the think function of the engine is not used, only the ponder function is used to generate the datas to display on the board. This make handling the command while the search is running is not a problem as ponder stop when e new command is send and can be re-lunch like for the time_left command (that what I have done in the new pull request #1242). |
Generate more output during the pondering phase to let GUI display that information in a more 'real time' fashion.
This should reduce the number of fork of the engine just for the sake of having more information out of it to display in GUI.