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/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software: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.

forge/index/issues.go +10−3

@@ -18,10 +18,17 @@ import (
18 18 // read is reserved for the cases that need it: the first read, a rewritten
19 19 // branch, or an incremental refresh that cannot be trusted.
20 20 func (s *Store) Ensure(m *repo.Meta) error {
21 current := ""
22 if sha, err := m.Git().RevParse(metadata.Ref); err == nil {
23 current = sha
21 current, err := m.Git().RevParse(metadata.Ref)
22 if err != nil {
23 return err
24 24 }
25 return s.EnsureAt(m, current)
26 }
27
28 // EnsureAt refreshes the derived rows to the metadata commit the caller already
29 // resolved. It is Ensure for a caller that needs the commit for something else
30 // too, so one page does not resolve the same ref twice.
31 func (s *Store) EnsureAt(m *repo.Meta, current string) error {
25 32 var stored string
26 33 err := s.db.QueryRow(`SELECT issues_sha FROM repos WHERE id=?`, m.ID).Scan(&stored)
27 34 if err != nil {