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.

Store the overview's summaries when a push lands

2a8f7cef47240564179a45126863d1ccd8d9d362 · Keenan Nemetz · 9d ago · parent 8dc56e4e

Store the overview's summaries when a push lands

The repository overview walked git on every read: `rev-parse` for the
tip, `log` for the last five commits, `for-each-ref` for tags, `ls-tree`
plus `shortlog` for languages and contributors, and a `cat-file` for the
README. All of those describe a ref except the README, and a ref moves
only when a push lands, so the push now records them.

- Schema v10 adds `repo_languages`, `repo_commits`, `repo_contributors`
  and `repo_tags`.
- `RefreshHead` stores the tip's newest commits and its language
  breakdown from one `ls-tree -r -l`, and returns whether the tip moved.
- `RefreshContributors` stores the top authors; the hook calls it only
  when the tip changed, never on a metadata or tag push.
- `RefreshTags` stores the tag rows beside the release events it already
  rewrote, and `IndexRepo` now refreshes tags and contributors too, so a
  rebuild restores everything a push would have written.
- The overview reads those rows when the recorded head is the branch tip
  (`RefCommit` is a loose-ref file read) and falls back to git when it is
  not, so a missed hook shows the correct page rather than a stale one.
  If one stored section is empty on a repository with commits, that
  section alone is re-read from git.
- The sidebar asks SQL for five open issues and changes instead of
  sorting the whole open queue in memory.
- The rendered README is cached by repository, commit and ref under a
  byte budget, so the overview's last git spawn is gone after the first
  read of a commit.
- The language fallback reads one `ls-tree -r -l` instead of `ls-tree`
  followed by a `cat-file --batch-check`.
- `Remove` deletes every derived row for a repository, not only its row.

Load harness at concurrency 4: overview goes from 473 to about 740 req/s,
p50 from 8 ms to 5 ms, and the server runs no git child process for the
warm requests.

server/web/cache_test.go +23

@@ -2,6 +2,8 @@ package web
2 2
3 3 import (
4 4 "fmt"
5 "html/template"
6 "strings"
5 7 "testing"
6 8 )
7 9
@@ -45,3 +47,24 @@ func TestCommitKeySeparatesRepositories(t *testing.T) {
45 47 t.Fatal("the same commit id in two repositories shares a key")
46 48 }
47 49 }
50
51 func TestReadmeCacheEvictsOldEntries(t *testing.T) {
52 t.Parallel()
53 var c readmeCache
54 // One large entry first, then enough small ones to exceed the byte budget.
55 big := readmeAnswer{html: template.HTML(strings.Repeat("x", readmeCacheBytes/2)), name: "README.md"}
56 c.put("big", big)
57 for i := 0; i < 8 && c.bytes <= readmeCacheBytes; i++ {
58 c.put(fmt.Sprintf("small-%d", i), readmeAnswer{html: template.HTML(strings.Repeat("y", 1<<20)), name: "README.md"})
59 }
60 if _, ok := c.get("big"); ok {
61 t.Fatal("the oldest entry survived a byte-budget eviction")
62 }
63 if c.bytes > readmeCacheBytes {
64 t.Fatalf("cache holds %d bytes, budget is %d", c.bytes, readmeCacheBytes)
65 }
66 if _, ok := c.get("small-7"); !ok && len(c.order) < readmeCacheEntries {
67 // The last inserted entry must survive unless the entry-count limit evicted it.
68 t.Fatal("the newest entry was evicted")
69 }
70 }