spicedb icon indicating copy to clipboard operation
spicedb copied to clipboard

Reduce memory usage of `serve-testing` server in large test suites

Open mateenkasim opened this issue 5 months ago • 5 comments

Problem Statement

I wasn't sure how to label this as it's more of a concern than a bug or proposal, and it's not high priority for me. Previous discussions in Discord:

  • https://discord.com/channels/844600078504951838/1278749294349910097
  • https://discord.com/channels/844600078504951838/1278750115057893418

In many testing paradigms, the DB state is torn down between tests. SpiceDB's serve-testing server mimics this by granting siloed DB states for every unique secret key. However, the server doesn't actually delete any of the data, since it doesn't know when the tests have completed. Because it's a memory datastore, this means memory usage increases monotonically.

Between test suite runs, memory can be cleared by restarting the test SpiceDB instance. However, within a test suite, memory usage may quickly increase if some tests write a lot of relationships. Some mechanism to "tear down" those relationships at the end of the test would be awesome. Doing it by manually tracking writes and running DeleteRelationships would be possible, except for this comment by @vroldanbet:

Deleting won't really reduce memory usage because of the revisioning system.

Solution Brainstorm

No response

mateenkasim avatar Aug 30 '24 17:08 mateenkasim