Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Stop repeating the index check and the history summaries

73ec800beafe53eea186fbc1cebec3306cc49da0 · Keenan Nemetz · 10d ago · parent 5d440e37

Stop repeating the index check and the history summaries

The request memo covered the repository, the open counts and the change
list, but two more reads were repeated:

- The index refresh (issue rows, filters, `#42` numbers) ran on every
  surface that shows one, and each run started by resolving the metadata
  ref. A page calls it from the header, the number lookup and its own
  view, so it now happens once per request, and the resolved commit is
  shared with the change-request read instead of being resolved twice.
- The overview walked the repository's whole history on every load:
  `shortlog` for contributors, `rev-list --count` for the code page's
  commit count, and the tree grouping for languages. Those are properties
  of a commit, and a commit id is content-addressed, so they cannot go
  stale: they are remembered by commit id in a bounded per-process cache
  that evicts oldest-first.

On the fixture (30 change requests, 30 issues) the overview drops from 19
git calls to 9 on a repeated load, the code page from 12 to 11, and every
page loses one `rev-parse` for the metadata ref.

server/web/numbers.go +3−3

@@ -21,8 +21,8 @@ import (
21 21 // derived rows if the metadata branch moved. A repo whose branch cannot be read
22 22 // gets an empty map: an unnumbered page is better than a failed one, and the
23 23 // templates render a missing number as `#?` rather than `#0`.
24 func (w *Web) entityNumbers(m *repo.Meta) map[string]int {
25 if err := w.Index.Ensure(m); err != nil {
24 func (w *Web) entityNumbers(memo *requestMemo, m *repo.Meta) map[string]int {
25 if err := w.ensureIndex(memo, m); err != nil {
26 26 return map[string]int{}
27 27 }
28 28 nums, err := w.Index.Numbers(m.ID)
@@ -88,7 +88,7 @@ func (w *Web) NumberAlias(rw http.ResponseWriter, r *http.Request) {
88 88 w.notFound(rw, r)
89 89 return
90 90 }
91 if err := w.Index.Ensure(m); err != nil {
91 if err := w.ensureIndex(memoOf(r), m); err != nil {
92 92 w.serverError(rw, r, "number index unavailable: "+err.Error())
93 93 return
94 94 }