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

From:
Mikhail <mp39590@gmail.com>
Subject:
tog: log view search eats 100% cpu
To:
gameoftrees@openbsd.org
Date:
Thu, 10 Aug 2023 20:40:20 +0300

Download raw body.

Thread
tog (in current got repo)
/Mikhail - (it will land you on [151/151]
n - (this must land you on [152/x])
tog starts eating 100% cpu

Proposed fix:

diff /home/misha/work/got
commit - 0778bf802f073bf7f785d53ab5ea4d8e6a8f0a59
path + /home/misha/work/got
blob - 7da57bf9f6480d998efd8205b57ef7814af17182
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -3700,6 +3700,22 @@ search_next_log_view(struct tog_view *view)
 		else
 			entry = TAILQ_PREV(s->selected_entry, commit_queue_head,
 			    entry);
+
+		/*
+		 * There is scenario when matched_entry and selected_entry are
+		 * the last in the queue of currently loaded commits, if so, we
+		 * must request loading more commits to proceed with the search,
+		 * if we leave 'entry' as NULL, we always will end up in this
+		 * branch of 'if' and won't do any actual matching in the code
+		 * below.
+		 *
+		 * To overcome this we set search_entry to selected_entry and
+		 * make next iteration of this function to land in previous
+		 * 'if' branch, which allows commits to be actually loaded.
+		 */
+		if (entry == NULL)
+			s->search_entry = s->selected_entry;
+
 	} else {
 		entry = s->selected_entry;
 	}