You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve performance in cfdm.read by caching any array values retrieved from disk #313
I'm a bit confused by your description @davidhassell, so just to check - from re-reading a bit my interpretation is that you mean we already cache first and last values for the array of data variables, but we can do this more often that we currently do? Would appreciate a clarification - on the following PR or here. Thanks.
Hi Sadie - sorry - the word "cache " is doing some heavy lifting, here! I'll try to re-word (although you're already correct!)
Selected array values (typically the first and last in the array) are read from disk and cached inside the Data objects of the returned constructs. A given netCDF variable might end up providing the data for multiple constructs, in which case the selected values end up getting read from disk multiple times. Therefore we need a new cache of these values in NetCDFRead that means we're not going to disk more often than we need to. I imagine that this new cache will look something like:
PR now up - empirical evidence on my laptop shows that this change speeds up the units tests by ~5%
Not been able to repeat this, and further investigation shows that the new cache is not accessed in the unit tests, anyway.
That said, there is at least one case when the cache does get accessed - when there is a scalar coordinate variable shared between two data variables, so we might as well leave it all in for that.
Activity
sadielbartholomew commentedon Jan 7, 2025
I'm a bit confused by your description @davidhassell, so just to check - from re-reading a bit my interpretation is that you mean we already cache first and last values for the array of data variables, but we can do this more often that we currently do? Would appreciate a clarification - on the following PR or here. Thanks.
davidhassell commentedon Jan 7, 2025
Hi Sadie - sorry - the word "cache " is doing some heavy lifting, here! I'll try to re-word (although you're already correct!)
Selected array values (typically the first and last in the array) are read from disk and cached inside the
Dataobjects of the returned constructs. A given netCDF variable might end up providing the data for multiple constructs, in which case the selected values end up getting read from disk multiple times. Therefore we need a new cache of these values inNetCDFReadthat means we're not going to disk more often than we need to. I imagine that this new cache will look something like:Then, each time we want to get the selected array values, we get them from the
NetCDFReadcache, only going to disk if they're not there.sadielbartholomew commentedon Jan 7, 2025
Ah I see - thanks for clarifying, I guess I'll be reviewing the PR eventually so it's out of more than just curiosity 🙂
davidhassell commentedon Apr 7, 2025
PR now up - empirical evidence on my laptop shows that this change speeds up the units tests by ~5%
davidhassell commentedon Jun 5, 2025
Not been able to repeat this, and further investigation shows that the new cache is not accessed in the unit tests, anyway.
That said, there is at least one case when the cache does get accessed - when there is a scalar coordinate variable shared between two data variables, so we might as well leave it all in for that.