Skip to content

Commit

Permalink
Flush data points out of query range to prevent using heap more than …
Browse files Browse the repository at this point in the history
…need
  • Loading branch information
nakabonne committed Jun 1, 2021
1 parent d517ba7 commit 13f44c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func (c *cli) run(args []string) int {
return 1
}

s, err := storage.NewStorage()
// Data points out of query range get flushed to prevent using heap more than need.
s, err := storage.NewStorage(c.queryRange * 2)
if err != nil {
fmt.Fprintf(c.stderr, "failed to initialize time-series storage: %v\n", err)
c.usage()
Expand Down
3 changes: 2 additions & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ type Result struct {
P99 time.Duration
}

func NewStorage() (Storage, error) {
func NewStorage(partitionDuration time.Duration) (Storage, error) {
s, err := tstorage.NewStorage(
tstorage.WithLogger(log.Default()),
tstorage.WithPartitionDuration(partitionDuration),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 13f44c8

Please sign in to comment.