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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
fix tog log view performance bug
To:
gameoftrees@openbsd.org
Date:
Wed, 16 Oct 2019 19:02:49 +0200

Download raw body.

Thread
I have noticed cursor movement in tog's log view slows down when
lots of commits are loaded. To reproduce, run tog in openbsd's
src.git repository and search for a garbage pattern that will
never match. Wait for tog to load all the >200000 commits.
Moving the cursor down with 'j' should now be rather sluggish.

The problem is that draw_commits() calculates the optimal length
to use for author strings across all commits in the loaded list,
rather than just for commits being displayed.

Trivial fix below. ok?

diff 73529b9f61583f0e9c36cd6ce82523837e394747 /home/stsp/src/got
blob - 082650a7623054ef35d2d467e3d678240ee3ddf3
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -1387,40 +1387,41 @@ draw_commits(struct tog_view *view, struct commit_queu
 	/* Grow author column size if necessary. */
 	entry = first;
 	ncommits = 0;
 	while (entry) {
 		char *author;
 		wchar_t *wauthor;
 		int width;
 		if (ncommits >= limit - 1)
 			break;
 		author = strdup(got_object_commit_get_author(entry->commit));
 		if (author == NULL) {
 			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		err = format_author(&wauthor, &width, author, COLS,
 		    date_display_cols);
 		if (author_cols < width)
 			author_cols = width;
 		free(wauthor);
 		free(author);
+		ncommits++;
 		entry = TAILQ_NEXT(entry, entry);
 	}
 
 	entry = first;
 	*last = first;
 	ncommits = 0;
 	while (entry) {
 		if (ncommits >= limit - 1)
 			break;
 		if (ncommits == selected_idx)
 			wstandout(view->window);
 		err = draw_commit(view, entry->commit, entry->id, refs,
 		    date_display_cols, author_cols);
 		if (ncommits == selected_idx)
 			wstandend(view->window);
 		if (err)
 			goto done;
 		ncommits++;
 		*last = entry;
 		entry = TAILQ_NEXT(entry, entry);