Skip to content

Commit

Permalink
Improve range cache efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Jul 5, 2022
1 parent 963eb29 commit bb84791
Show file tree
Hide file tree
Showing 22 changed files with 459 additions and 133 deletions.
30 changes: 30 additions & 0 deletions cmd/pint/tests/0025_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ level=info msg="Loading configuration file" path=.pint.hcl
"uri": "https://",
"timeout": "2m",
"concurrency": 16,
"cache": 10000,
"required": true
},
{
"name": "custom-concurrency",
"uri": "https://",
"timeout": "2m",
"concurrency": 32,
"cache": 10000,
"required": false
},
{
"name": "custom-cache",
"uri": "https://",
"timeout": "10s",
"concurrency": 16,
"cache": 32,
"required": false
}
],
"checks": {
Expand Down Expand Up @@ -133,6 +150,19 @@ prometheus "prom" {
required = true
}

prometheus "custom-concurrency" {
uri = "https://"
timeout = "2m"
required = false
concurrency = 32
}

prometheus "custom-cache" {
uri = "https://"
timeout = "10s"
cache = 32
}

checks {
disabled = ["promql/fragile"]
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/pint/tests/0041_watch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ pint.ok --no-color -l debug watch --interval=5s --listen=127.0.0.1:6041 --pidfil
stderr 'level=info msg="Pidfile created" path=pint.pid'
stderr 'level=info msg="Started HTTP server" address=127.0.0.1:6041'
stderr 'level=info msg="Will continuously run checks until terminated" interval=5s'
stderr 'level=debug msg="Clearing cache"'
stderr 'level=debug msg="Running checks"'
stderr 'level=error msg="Got an error when running checks" error="no matching files"'
stderr 'level=debug msg="Clearing cache"'
stderr 'level=debug msg="Running checks"'
stderr 'level=error msg="Got an error when running checks" error="no matching files"'
stderr 'level=info msg="Shutting down"'
Expand Down
4 changes: 0 additions & 4 deletions cmd/pint/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ func startTimer(ctx context.Context, cfg config.Config, workers int, interval ti
for {
select {
case <-ticker.C:
log.Debug().Msg("Clearing cache")
for _, prom := range cfg.PrometheusServers {
prom.ClearCache()
}
log.Debug().Msg("Running checks")
if !wasBootstrapped {
ticker.Reset(interval)
Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

## v0.23.0

### Fixed

- Improved range query cache efficiency.

### Added

- Added extra global configuration for `promql/series` check.
See check [documentation](checks/promql/series.md) for details.
- `prometheus` server definition in `pint` config file can now accept optional
`cache` field (defaults to 10000) to allow fine tuning of built-in Prometheus
API query caching.
- Added `pint_prometheus_cache_size` metric that exposes the number of entries
currently in the query cache.

## v0.22.2

Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ prometheus "$name" {
failover = ["https://...", ...]
timeout = "60s"
concurrency = 16
cache = 10000
required = true|false
paths = ["...", ...]
}
Expand All @@ -177,6 +178,7 @@ prometheus "$name" {
- `timeout` - timeout to be used for API requests.
- `concurrency` - how many concurrent requests can pint send to this Prometheus.
Optional, defaults to 16.
- `cache` - size of the query cache, defaults to 10000.
- `required` - decides how pint will report errors if it's unable to get a valid response
from this Prometheus server. If `required` is `true` and all API calls to this Prometheus
fail pint will report those as `bug` level problem. If it's set to `false` pint will
Expand Down
2 changes: 1 addition & 1 deletion internal/checks/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func simpleProm(name, uri string, timeout time.Duration, required bool) *promapi
return promapi.NewFailoverGroup(
name,
[]*promapi.Prometheus{
promapi.NewPrometheus(name, uri, timeout, 16),
promapi.NewPrometheus(name, uri, timeout, 16, 1000),
},
required,
)
Expand Down
Loading

0 comments on commit bb84791

Please sign in to comment.