app/vmselect/netstorage: add a comment explaining why all the samples in block are taken into account when checking the -search.maxSamplesPerQuery limit

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5851

This is a follow-up for b07a02c516
This commit is contained in:
Aliaksandr Valialkin 2024-06-25 03:01:36 +02:00
parent b07a02c516
commit 6a0cf2cd29
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB

View File

@ -1192,6 +1192,11 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
return nil, fmt.Errorf("timeout exceeded while fetching data block #%d from storage: %s", blocksRead, deadline.String())
}
br := sr.MetricBlockRef.BlockRef
// Take into account all the samples in the block when checking for *maxSamplesPerQuery limit,
// since CPU time is spent on unpacking all the samples in the block, even if only a few samples
// are left then because of the given time range.
// This allows effectively limiting CPU resources used per query.
samples += br.RowsCount()
if *maxSamplesPerQuery > 0 && samples > *maxSamplesPerQuery {
putTmpBlocksFile(tbf)