Skip to content

Cache size statistics #307

@lheckemann

Description

@lheckemann

Some statistics would be helpful.

I've recently set up an attic instance and wanted to evaluate how the storage use compares to a flat-file binary cache, and came up with the following queries:

atticd=# select pg_size_pretty(total_nar_size) total_nar_size, pg_size_pretty(total_compressed_nar_size) total_compressed_nar_size, pg_size_pretty(total_chunk_size) uncompressed_chunk_size, pg_size_pretty(total_storage_used) total_storage_used, total_compressed_nar_size / total_storage_used ratio from (select (select sum(nar_size) from nar) total_nar_size, (select sum(chunk_size) from chunk)  total_chunk_size, (select sum(file_size) from chunk) total_storage_used, (select sum(compressed_nar_size) total_compressed_nar_size from (select sum(file_size) compressed_nar_size from nar, chunkref, chunk where nar_id = nar.id and chunk_id = chunk.id group by nar.id)));
 total_nar_size | total_compressed_nar_size | uncompressed_chunk_size | total_storage_used |       ratio        
----------------+---------------------------+-------------------------+--------------------+--------------------
 9157 MB        | 3145 MB                   | 4843 MB                 | 1708 MB            | 1.8419919245644854
(1 row)

ratio is an approximation of how much space is saved (for nars only, not narinfos!) compared to a flat-file binary cache.

This is a single-tenant instance, so I haven't spent much thought on getting these stats per cache, but they're probably useful as-is even from a multi-tenant operator perspective (though they don't shed any light on how much deduplication happens across tenants). It would probably also not be complicated to get these numbers per cache, which could be useful from an individual tenant perspective as well.

Maybe something like this could be surfaced via the API? Somewhat related to #7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions