1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-05 18:40:59 +00:00
forgejo-runner/act
Mathieu Fenniak 022d5ad3e7
fix: artifact cache DB not using indexes for searching (#878)
Uses the `Repo` field as an index during searches of the cache database.  Removes unused indexes.

To measure the performance of this change, I created a synthetic test which wrote 10,000 records into the artifact cache DB.  Of course, all benchmarks are lies that can't be generalized to real-world usage, but it seems clear from the magnitude of improvement that this fixes a flawed implementation, even if it's not perfect.
- Unmodified performance:
    - Write: 196 records/second
    - Read: 1 record/second
- With `Repo` index being used for reads, and other indexes being removed:
    - Write: 347 records/second
    - Read: 22,398 records/second

`Repo` is, I think, the only index that made sense to remain, with an eye on workflow run performance:
- `Key` -- can't be used for index because `findCache` searches for key *prefixes*, not equal values.
- `Version` -- isn't very distinct for different workflow runs (https://code.forgejo.org/actions/cache#cache-version)
- `Complete` - significant portion of the cache DB will be complete, making it the least selective possible index
- `UsedAt` & `CreatedAt` - only used in GC operation, so could remain, but this isn't a performance-sensitive codepath

Closes #874.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/878): <!--number 878 --><!--line 0 --><!--description Zml4OiBhcnRpZmFjdCBjYWNoZSBEQiBub3QgdXNpbmcgaW5kZXhlcyBmb3Igc2VhcmNoaW5n-->fix: artifact cache DB not using indexes for searching<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/878
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-08-19 20:19:23 +00:00
..
artifactcache fix: artifact cache DB not using indexes for searching (#878) 2025-08-19 20:19:23 +00:00
cacheproxy chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
common test: fix data race in TestNewParallelExecutor... tests (#860) 2025-08-15 09:12:32 +00:00
container fix: fixes the build on FreeBSD (#882) 2025-08-18 06:01:33 +00:00
exprparser chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
filecollector chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
jobparser fix: RunsOn in jobparser is not used by the runner but it is used by Forgejo [skip cascade] (#884) 2025-08-18 12:16:44 +00:00
lookpath chore: use the same .golangci.yml as the runner & gofumpt over gofmt (#206) 2025-07-28 12:26:41 +00:00
model fix: data race in 'runs-on' expressions causes incorrect job labels during execution (#871) 2025-08-16 20:44:40 +00:00
runner fix: data race in 'runs-on' expressions causes incorrect job labels during execution (#871) 2025-08-16 20:44:40 +00:00
schema chore: modernize code (#857) 2025-08-15 04:54:13 +00:00
workflowpattern chore: modernize code (#857) 2025-08-15 04:54:13 +00:00