feature: Intelligent redistribution of last collection dates for better resource utilization consistency
- Dominant language
- Python
- Stars
- 13
- Forks
- 17
- Avg merge
- 6h 59m
- Merged PRs (30d)
- 1
Description
> [!NOTE]
> Migrated from [augurlabs/augur#3800](https://github.com/augurlabs/augur/issues/3800)
> Originally opened by `@MoralCode` on 2026-03-27
---
When an augur instance is fully collected, the distribution of last collected dates may tend to skew towards large spikes, especially if collection has been off for longer than the configured collection window.
in order to smooth out these spikes and enable a large instance to be more consistent with its resource usage (and thus be able to run in a lower-resource environment, if kept online), I propose introducing a scheduled task to augur.
This task would run daily and perform the following logic for each phase of collection:
1. check how many repositories are outside the configured collection window (i.e. have collection dates) and not ignored. If over some threshold, exit early and do nothing (we should be smoothing collection only after we are at least most of the way to full collection)
2. query the distribution of repo frequency by last collection date (query exists already and is used by grafana)
3. do some quick math to measure how close to a uniform distribution these results are
4. if the results are close enough to uniform, exit early and do nothing
5. if the results arent uniform, find the `ideal` uniform value by dividing the total count of non-ignored repos by the number of days in the collection window
6. for each day (most to least recent) in the collection window, count how many more repos that were collected compared to the `ideal` uniform value (`overage`)
- if there is not substantially (20%+) more repos collected today vs the `ideal`, skip to the next day
- ... if there is, randomly select `overage` number of repositories and set their collection dates back (older) by 1 day (meaning they will be recollected a day sooner than they would before)
- .... if setting the day back would put the repo outside the current collection window (i.e. this is the last iteration of the loop), limit how many repos get their dates changed
This will basically "spread" any large spikes in repos collected per day over preceding days. This smooths out the collection curve in a way that can only cause a repo to be recollected sooner than it would otherwise, never later.
The key impact of this is that augur instances are more consistent about their performance needs in the long run, moving away from being "large spike followed by relative idle-ness" and maintaining more of a "aim to collect a certain number of repos each day.
Further improvement to this consistency can be implemented by analyzing the specific time of day for the last collection dates and ensuring that the "set the date backwards" logic places the new repos into time "slots" th at have relatively few other repositories configured.
Contributor guide
Assessment
This issue has not been assessed yet.