Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions framework/modelcatalog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const (
// syncWorkerTickerPeriod is the fixed interval at which the background sync worker
// wakes up to check whether a sync is due. This is independent of pricingSyncInterval —
// the ticker defines the check granularity, not the sync frequency.
// Setting pricingSyncInterval below this value has no effect on actual sync frequency.
syncWorkerTickerPeriod = 1 * time.Hour
// Kept well below MinimumPricingSyncIntervalSec so the threshold check is not
// defeated by ticker drift when pricingSyncInterval is set near the minimum.
syncWorkerTickerPeriod = 5 * time.Minute
Comment thread
Pratham-Mishra04 marked this conversation as resolved.

ConfigLastPricingSyncKey = "LastModelPricingSync"
ConfigLastParamsSyncKey = "LastModelParametersSync"
Expand Down
17 changes: 7 additions & 10 deletions framework/modelcatalog/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,16 @@ func (mc *ModelCatalog) loadModelParametersFromDatabase(ctx context.Context) (in
func (mc *ModelCatalog) startSyncWorker(ctx context.Context) {
// IMPORTANT: scheduling model
//
// The sync worker wakes on a fixed ticker (syncWorkerTickerPeriod = 1h).
// On each wake it calls checkAndSyncPricing, which checks:
// The sync worker wakes on a fixed ticker (syncWorkerTickerPeriod). On each
// wake it checks:
//
// time.Since(lastSyncTimestamp) >= pricingSyncInterval
//
// This means:
// • pricingSyncInterval defines the *minimum elapsed time* between syncs.
// • The actual sync frequency = max(syncWorkerTickerPeriod, pricingSyncInterval).
// • Setting pricingSyncInterval < 1h does NOT increase sync frequency —
// the hourly ticker is the hard lower bound on check granularity.
//
// Design rationale: avoids high-frequency polling while allowing operators to
// tune how stale pricing data can get (e.g., 1h vs 24h vs 7d).
// pricingSyncInterval defines the minimum elapsed time between syncs. The
// ticker period is the check granularity and must stay well below the
// minimum supported pricingSyncInterval, otherwise ticker drift (the few
// seconds a sync takes to complete) pushes the next check just under the
// threshold and the effective cadence doubles.
mc.syncTicker = time.NewTicker(syncWorkerTickerPeriod)
mc.wg.Add(1)
go mc.syncWorker(ctx)
Expand Down
Loading