chore(deps): integrate approved upstream foundations
- commit
- 4d548f3f69cfbdc7fc18360aeb70966c0b334bd3
- author
- brice · · 2026-07-14 14:11 UTC
- parent
- 41933ea
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
13 files · +482 -125
M go.mod +3 -3
| @@ -6,10 +6,10 @@ require ( | |||
| 6 | 6 | github.com/a-h/templ v0.3.1020 | |
| 7 | 7 | github.com/andybalholm/brotli v1.2.2 | |
| 8 | 8 | github.com/bnema/purego v0.11.0-bnema.4 | |
| 9 | - | github.com/bnema/purego-cef v0.13.3 | |
| 9 | + | github.com/bnema/purego-cef v0.13.4-0.20260714140305-f0b7414af67e | |
| 10 | 10 | github.com/bnema/purego-cef2gtk v0.8.4 | |
| 11 | - | github.com/bnema/purego-pipewire v0.1.4 | |
| 12 | - | github.com/bnema/purego-sqlite v0.1.3 | |
| 11 | + | github.com/bnema/purego-pipewire v0.1.5-0.20260714124450-6504b9cdf02a | |
| 12 | + | github.com/bnema/purego-sqlite v0.1.4-0.20260714131321-3614fe683b9c | |
| 13 | 13 | github.com/bnema/puregotk v0.7.0 | |
| 14 | 14 | github.com/charmbracelet/bubbles v1.0.0 | |
| 15 | 15 | github.com/charmbracelet/bubbletea v1.3.10 | |
| @@ -6,10 +6,10 @@ require ( | |||||
| 6 | github.com/a-h/templ v0.3.1020 | 6 | github.com/a-h/templ v0.3.1020 | ||
| 7 | github.com/andybalholm/brotli v1.2.2 | 7 | github.com/andybalholm/brotli v1.2.2 | ||
| 8 | github.com/bnema/purego v0.11.0-bnema.4 | 8 | github.com/bnema/purego v0.11.0-bnema.4 | ||
| 9 | - | github.com/bnema/purego-cef v0.13.3 | 9 | + | github.com/bnema/purego-cef v0.13.4-0.20260714140305-f0b7414af67e |
| 10 | github.com/bnema/purego-cef2gtk v0.8.4 | 10 | github.com/bnema/purego-cef2gtk v0.8.4 | ||
| 11 | - | github.com/bnema/purego-pipewire v0.1.4 | 11 | + | github.com/bnema/purego-pipewire v0.1.5-0.20260714124450-6504b9cdf02a |
| 12 | - | github.com/bnema/purego-sqlite v0.1.3 | 12 | + | github.com/bnema/purego-sqlite v0.1.4-0.20260714131321-3614fe683b9c |
| 13 | github.com/bnema/puregotk v0.7.0 | 13 | github.com/bnema/puregotk v0.7.0 | ||
| 14 | github.com/charmbracelet/bubbles v1.0.0 | 14 | github.com/charmbracelet/bubbles v1.0.0 | ||
| 15 | github.com/charmbracelet/bubbletea v1.3.10 | 15 | github.com/charmbracelet/bubbletea v1.3.10 | ||
M go.sum +6 -0 generated file: collapsed
A internal/infrastructure/persistence/sqlite/history_repo_benchmark_test.go +66 -0
| @@ -0,0 +1,66 @@ | |||
| 1 | + | package sqlite_test | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "fmt" | |
| 5 | + | "path/filepath" | |
| 6 | + | "testing" | |
| 7 | + | ||
| 8 | + | "github.com/bnema/dumber/internal/domain/entity" | |
| 9 | + | "github.com/bnema/dumber/internal/domain/repository" | |
| 10 | + | "github.com/bnema/dumber/internal/infrastructure/persistence/sqlite" | |
| 11 | + | ) | |
| 12 | + | ||
| 13 | + | // newHistoryBenchmarkRepository creates a representative local history corpus | |
| 14 | + | // outside the measured operation. Sidebar reads use GetRecent and omnibox | |
| 15 | + | // history suggestions use Search. | |
| 16 | + | func newHistoryBenchmarkRepository(b *testing.B) (repository.HistoryRepository, func()) { | |
| 17 | + | b.Helper() | |
| 18 | + | ||
| 19 | + | ctx := historyTestCtx() | |
| 20 | + | db, err := sqlite.NewConnection(ctx, filepath.Join(b.TempDir(), "dumber.db")) | |
| 21 | + | if err != nil { | |
| 22 | + | b.Fatal(err) | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | repo := sqlite.NewHistoryRepository(db) | |
| 26 | + | for i := range 200 { | |
| 27 | + | entry := &entity.HistoryEntry{ | |
| 28 | + | URL: fmt.Sprintf("https://example%d.test/dumber/history/%d", i%20, i), | |
| 29 | + | Title: fmt.Sprintf("Dumber history entry %d", i), | |
| 30 | + | } | |
| 31 | + | if err := repo.Save(ctx, entry); err != nil { | |
| 32 | + | _ = db.Close() | |
| 33 | + | b.Fatal(err) | |
| 34 | + | } | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | return repo, func() { _ = db.Close() } | |
| 38 | + | } | |
| 39 | + | ||
| 40 | + | func BenchmarkHistorySQLiteSidebarRecent(b *testing.B) { | |
| 41 | + | repo, closeDB := newHistoryBenchmarkRepository(b) | |
| 42 | + | defer closeDB() | |
| 43 | + | ctx := historyTestCtx() | |
| 44 | + | ||
| 45 | + | b.ReportAllocs() | |
| 46 | + | b.ResetTimer() | |
| 47 | + | for range b.N { | |
| 48 | + | if _, err := repo.GetRecent(ctx, 50, 0); err != nil { | |
| 49 | + | b.Fatal(err) | |
| 50 | + | } | |
| 51 | + | } | |
| 52 | + | } | |
| 53 | + | ||
| 54 | + | func BenchmarkHistorySQLiteOmniboxSearch(b *testing.B) { | |
| 55 | + | repo, closeDB := newHistoryBenchmarkRepository(b) | |
| 56 | + | defer closeDB() | |
| 57 | + | ctx := historyTestCtx() | |
| 58 | + | ||
| 59 | + | b.ReportAllocs() | |
| 60 | + | b.ResetTimer() | |
| 61 | + | for range b.N { | |
| 62 | + | if _, err := repo.Search(ctx, "dumber history", 10); err != nil { | |
| 63 | + | b.Fatal(err) | |
| 64 | + | } | |
| 65 | + | } | |
| 66 | + | } | |
| @@ -0,0 +1,66 @@ | |||||
| 1 | + | package sqlite_test | |||
| 2 | + | ||||
| 3 | + | import ( | |||
| 4 | + | "fmt" | |||
| 5 | + | "path/filepath" | |||
| 6 | + | "testing" | |||
| 7 | + | ||||
| 8 | + | "github.com/bnema/dumber/internal/domain/entity" | |||
| 9 | + | "github.com/bnema/dumber/internal/domain/repository" | |||
| 10 | + | "github.com/bnema/dumber/internal/infrastructure/persistence/sqlite" | |||
| 11 | + | ) | |||
| 12 | + | ||||
| 13 | + | // newHistoryBenchmarkRepository creates a representative local history corpus | |||
| 14 | + | // outside the measured operation. Sidebar reads use GetRecent and omnibox | |||
| 15 | + | // history suggestions use Search. | |||
| 16 | + | func newHistoryBenchmarkRepository(b *testing.B) (repository.HistoryRepository, func()) { | |||
| 17 | + | b.Helper() | |||
| 18 | + | ||||
| 19 | + | ctx := historyTestCtx() | |||
| 20 | + | db, err := sqlite.NewConnection(ctx, filepath.Join(b.TempDir(), "dumber.db")) | |||
| 21 | + | if err != nil { | |||
| 22 | + | b.Fatal(err) | |||
| 23 | + | } | |||
| 24 | + | ||||
| 25 | + | repo := sqlite.NewHistoryRepository(db) | |||
| 26 | + | for i := range 200 { | |||
| 27 | + | entry := &entity.HistoryEntry{ | |||
| 28 | + | URL: fmt.Sprintf("https://example%d.test/dumber/history/%d", i%20, i), | |||
| 29 | + | Title: fmt.Sprintf("Dumber history entry %d", i), | |||
| 30 | + | } | |||
| 31 | + | if err := repo.Save(ctx, entry); err != nil { | |||
| 32 | + | _ = db.Close() | |||
| 33 | + | b.Fatal(err) | |||
| 34 | + | } | |||
| 35 | + | } | |||
| 36 | + | ||||
| 37 | + | return repo, func() { _ = db.Close() } | |||
| 38 | + | } | |||
| 39 | + | ||||
| 40 | + | func BenchmarkHistorySQLiteSidebarRecent(b *testing.B) { | |||
| 41 | + | repo, closeDB := newHistoryBenchmarkRepository(b) | |||
| 42 | + | defer closeDB() | |||
| 43 | + | ctx := historyTestCtx() | |||
| 44 | + | ||||
| 45 | + | b.ReportAllocs() | |||
| 46 | + | b.ResetTimer() | |||
| 47 | + | for range b.N { | |||
| 48 | + | if _, err := repo.GetRecent(ctx, 50, 0); err != nil { | |||
| 49 | + | b.Fatal(err) | |||
| 50 | + | } | |||
| 51 | + | } | |||
| 52 | + | } | |||
| 53 | + | ||||
| 54 | + | func BenchmarkHistorySQLiteOmniboxSearch(b *testing.B) { | |||
| 55 | + | repo, closeDB := newHistoryBenchmarkRepository(b) | |||
| 56 | + | defer closeDB() | |||
| 57 | + | ctx := historyTestCtx() | |||
| 58 | + | ||||
| 59 | + | b.ReportAllocs() | |||
| 60 | + | b.ResetTimer() | |||
| 61 | + | for range b.N { | |||
| 62 | + | if _, err := repo.Search(ctx, "dumber history", 10); err != nil { | |||
| 63 | + | b.Fatal(err) | |||
| 64 | + | } | |||
| 65 | + | } | |||
| 66 | + | } | |||
M vendor/github.com/bnema/purego-cef/cef/bridge.go +8 -13
| @@ -563,14 +563,6 @@ func initRefCount(base unsafe.Pointer, size uintptr, owner any) { | |||
| 563 | 563 | mustCurrentRefManager().InitRefCount(base, size, owner) | |
| 564 | 564 | } | |
| 565 | 565 | ||
| 566 | - | // newCEFCallback creates a per-object callback trampoline and ties its purego | |
| 567 | - | // slot to the owning CEF object's refcount lifetime. | |
| 568 | - | func newCEFCallback(base unsafe.Pointer, fn any) uintptr { | |
| 569 | - | cb := purego.NewCallback(fn) | |
| 570 | - | mustCurrentRefManager().TrackCallback(base, cb) | |
| 571 | - | return cb | |
| 572 | - | } | |
| 573 | - | ||
| 574 | 566 | // sharedCEFCallback creates a process-lifetime callback trampoline once. It is | |
| 575 | 567 | // used for generated handler methods that can dispatch by their CEF self | |
| 576 | 568 | // pointer instead of capturing per-object Go state in a fresh closure. | |
| @@ -581,6 +573,7 @@ func sharedCEFCallback(once *sync.Once, slot *uintptr, fn any) uintptr { | |||
| 581 | 573 | return *slot | |
| 582 | 574 | } | |
| 583 | 575 | ||
| 576 | + | //go:nocheckptr | |
| 584 | 577 | func cefCallbackOwnerAs[T any](self uintptr) (T, bool) { | |
| 585 | 578 | var zero T | |
| 586 | 579 | if self == 0 { | |
| @@ -588,12 +581,14 @@ func cefCallbackOwnerAs[T any](self uintptr) (T, bool) { | |||
| 588 | 581 | } | |
| 589 | 582 | base := unsafe.Pointer(self) | |
| 590 | 583 | ||
| 584 | + | // Hold the registry read lock through Owner. This keeps a manager visible | |
| 585 | + | // for the entire lookup while register/unregister updates the slice. Owner | |
| 586 | + | // only reads RefManager's sync.Map; no user callback is invoked under this | |
| 587 | + | // lock. | |
| 591 | 588 | refManagerMu.RLock() | |
| 592 | - | managers := append([]*core.RefManager(nil), registeredRefManagers...) | |
| 593 | - | refManagerMu.RUnlock() | |
| 594 | - | ||
| 595 | - | for i := len(managers) - 1; i >= 0; i-- { | |
| 596 | - | owner, ok := managers[i].Owner(base) | |
| 589 | + | defer refManagerMu.RUnlock() | |
| 590 | + | for i := len(registeredRefManagers) - 1; i >= 0; i-- { | |
| 591 | + | owner, ok := registeredRefManagers[i].Owner(base) | |
| 597 | 592 | if !ok { | |
| 598 | 593 | continue | |
| 599 | 594 | } | |
| @@ -563,14 +563,6 @@ func initRefCount(base unsafe.Pointer, size uintptr, owner any) { | |||||
| 563 | mustCurrentRefManager().InitRefCount(base, size, owner) | 563 | mustCurrentRefManager().InitRefCount(base, size, owner) | ||
| 564 | } | 564 | } | ||
| 565 | 565 | ||||
| 566 | - | // newCEFCallback creates a per-object callback trampoline and ties its purego | |||
| 567 | - | // slot to the owning CEF object's refcount lifetime. | |||
| 568 | - | func newCEFCallback(base unsafe.Pointer, fn any) uintptr { | |||
| 569 | - | cb := purego.NewCallback(fn) | |||
| 570 | - | mustCurrentRefManager().TrackCallback(base, cb) | |||
| 571 | - | return cb | |||
| 572 | - | } | |||
| 573 | - | ||||
| 574 | // sharedCEFCallback creates a process-lifetime callback trampoline once. It is | 566 | // sharedCEFCallback creates a process-lifetime callback trampoline once. It is | ||
| 575 | // used for generated handler methods that can dispatch by their CEF self | 567 | // used for generated handler methods that can dispatch by their CEF self | ||
| 576 | // pointer instead of capturing per-object Go state in a fresh closure. | 568 | // pointer instead of capturing per-object Go state in a fresh closure. | ||
| @@ -581,6 +573,7 @@ func sharedCEFCallback(once *sync.Once, slot *uintptr, fn any) uintptr { | |||||
| 581 | return *slot | 573 | return *slot | ||
| 582 | } | 574 | } | ||
| 583 | 575 | ||||
| 576 | + | //go:nocheckptr | |||
| 584 | func cefCallbackOwnerAs[T any](self uintptr) (T, bool) { | 577 | func cefCallbackOwnerAs[T any](self uintptr) (T, bool) { | ||
| 585 | var zero T | 578 | var zero T | ||
| 586 | if self == 0 { | 579 | if self == 0 { | ||
| @@ -588,12 +581,14 @@ func cefCallbackOwnerAs[T any](self uintptr) (T, bool) { | |||||
| 588 | } | 581 | } | ||
| 589 | base := unsafe.Pointer(self) | 582 | base := unsafe.Pointer(self) | ||
| 590 | 583 | ||||
| 584 | + | // Hold the registry read lock through Owner. This keeps a manager visible | |||
| 585 | + | // for the entire lookup while register/unregister updates the slice. Owner | |||
| 586 | + | // only reads RefManager's sync.Map; no user callback is invoked under this | |||
| 587 | + | // lock. | |||
| 591 | refManagerMu.RLock() | 588 | refManagerMu.RLock() | ||
| 592 | - | managers := append([]*core.RefManager(nil), registeredRefManagers...) | 589 | + | defer refManagerMu.RUnlock() |
| 593 | - | refManagerMu.RUnlock() | 590 | + | for i := len(registeredRefManagers) - 1; i >= 0; i-- { |
| 594 | - | 591 | + | owner, ok := registeredRefManagers[i].Owner(base) | |
| 595 | - | for i := len(managers) - 1; i >= 0; i-- { | |||
| 596 | - | owner, ok := managers[i].Owner(base) | |||
| 597 | if !ok { | 592 | if !ok { | ||
| 598 | continue | 593 | continue | ||
| 599 | } | 594 | } | ||