"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog log & got-read-pack on the fly:
To:
Tracey Emery <tracey@traceyemery.net>
Cc:
Martin Pieuchot <mpi@openbsd.org>, gameoftrees@openbsd.org
Date:
Thu, 10 Oct 2019 17:38:51 +0200

Download raw body.

Thread
On Thu, Oct 10, 2019 at 09:02:12AM -0600, Tracey Emery wrote:
> On Thu, Oct 10, 2019 at 04:45:07PM +0200, Stefan Sperling wrote:
> > Can you please try this diff just to check if this helps?
> > If it does, we need to find a proper way of fixing this.
> 
> Patch significantly sped up the search process here!

I cannot figure out how to make wgetch() faster, the related timeout
settings have no apparent effect.

Calling wgetch in a loop is obviously bad. Below is a simple workaround
that works for me, with some more tweaks that seem to help.

I don't expect this will address the stalls during regular scrolling
that Marting was seeing, though.

diff 366e0a5f18070d353035fdfa945719809c60f0aa /home/stsp/src/got
blob - aad8017a1963e96977883c2dadfcef0fce8eac58
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -573,6 +573,7 @@ view_search_start(struct tog_view *view)
 			regfree(&view->regex);
 			return err;
 		}
+		halfdelay(1); /* fast refresh while searching */
 		view->searching = TOG_SEARCH_FORWARD;
 		view->search_next_done = 0;
 		view->search_next(view);
@@ -607,6 +608,8 @@ view_input(struct tog_view **new, struct tog_view **de
 		view->search_next(view);
 		return NULL;
 	}
+	if (view->searching && view->search_next_done)
+		halfdelay(10); /* disable fast refresh */
 
 	nodelay(stdscr, FALSE);
 	/* Allow threads to make progress while we are waiting for input. */
@@ -1793,7 +1796,15 @@ search_next_log_view(struct tog_view *view)
 	}
 
 	if (s->search_entry) {
-		if (wgetch(view->window) == KEY_BACKSPACE) {
+		static int check_cancel_search;
+		/*
+		 * wgetch() slows search down a lot so do not call it often.
+		 * The point is to allow users to bail out of a bad search
+		 * that might never finish until all commits have been loaded.
+		 * So checking infrequently is OK.
+		 */
+		if ((++check_cancel_search % 500 == 0) &&
+		    wgetch(view->window) == KEY_BACKSPACE) {
 			view->search_next_done = 1;
 			return NULL;
 		}
@@ -1829,7 +1840,7 @@ search_next_log_view(struct tog_view *view)
 			 * will resume at s->search_entry once we come back.
 			 */
 			s->thread_args.commits_needed++;
-			return trigger_log_thread(1,
+			return trigger_log_thread(0,
 			    &s->thread_args.commits_needed,
 			    &s->thread_args.log_complete,
 			    &s->thread_args.need_commits);