While doing alternative implementation of value cache to improve speed and avoid locks i have found that the original implementation stores a lot of items in the value cache for unknown reasons.
Investigating the issue i realized the problem is in current implementation of the nodata function (in both evalfunc.c and evalfunc2.c) which if quite inefficient:
code fetches all the data from the cache for period 'period' and causes the valuecache 1) remember demand for the item as period "period" and 2) actively load the data from the db storage.
replacing that with getting only the latest item from the cache like this:
and comparing cached latest value's timestamp to request period will:
- set cache demand to have only one item
- it might be that there will be some data already, so it will eliminate need to fetch it from the db at all}}
- will not require db requests if nodata is used with periods of more then maximum cache age (24h)
Having that fixed along with own cache implementation (which is out of this ticket scope) greatly improves server startup time along with database pressure especially if there are lots of nodata checks implemented