Skip to content

Cache SkynetStats in API

Christopher Schinnerl requested to merge chris/optmize-stats-speed into master

MERGE REQUEST

MR Guidelines

Overview

This MR adds caching for the number of files and total size of files in the skynetstats endpoint.

NOTE: The cached values are assumed to not be perfectly accurate. The cache will be updated in the common cases. This means when a skyfile is uploaded or when a skyfile is deleted. Certain rare edge cases like a user deleting a file directly on disk or renaming a skyfile in a way that moves it to an unknown location in the sia filesystem are not handled directly.

To work around this, a background thread will invalidate the cache periodically. Whenever that happens, the next time the stats are fetched it will be slow again. Simultaneous calls won't all query the filesystem though but instead wait for the first cal to finish.

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.

  • All new methods or updated methods have clear docstrings
  • Testing added or updated for new methods
  • Any new packages are added to Makefile and .gitlab-ci.yml
  • API documentation updated for API updates
  • Module README.md updated for changes to workflow
  • Issue added to Sia-UI repo for new supporting features
  • Changelog File Created

Issues Closed

Edited by Christopher Schinnerl

Merge request reports