★ wanayoo — archive 1999 https://github.com/grantjenks/python-diskcache/issues/140Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size_limit for cache does not take into account the size of directories #140

Closed
crash-g opened this issue Mar 25, 2020 · 2 comments
Closed

size_limit for cache does not take into account the size of directories #140

crash-g opened this issue Mar 25, 2020 · 2 comments

Comments

@crash-g
Copy link

@crash-g crash-g commented Mar 25, 2020

I have noticed that the volume method does not return the exact size of the cache, but in some scenarios there could be a discrepancy of more than 100 MB.

From the code, I gather that volume = page_size * page_count + total_file_size, where page_size * page_count is an estimate of the database size and total_file_size is the size of all file-backed entries.

The problem is that this does not take into account the space occupied by directories. There are two levels of directories, whose names correspond to one byte in the hash, so there can be at most 65536 directories. Each directory being 4KB in my case, this gives at most 256MB of space which is unaccounted for.

This is not a problem in my scenario but the behavior was confusing, so I was wondering if I missed the explanation somewhere or if it is implied by the current documentation of volume.

Version: 3.1.1
OS: Ubuntu

@grantjenks
Copy link
Owner

@grantjenks grantjenks commented Mar 25, 2020

You didn’t miss anything in the docs. I simply haven’t accounted the directory sizes because I don’t know good and easy way to do so.

The directory structure could change with a different Disk so maybe it’s best to exclude them. I’d lean toward a simple docs update saying it excludes directory sizes.

I do think it’s worth calling out. Others have been concerned by the large number of directories. When I created diskcache, I had an abundance of disk space so I don’t worry about it much.

@grantjenks
Copy link
Owner

@grantjenks grantjenks commented Aug 23, 2020

Blurb added to Caveats in a8a014c to be released in v5

@grantjenks grantjenks closed this Aug 23, 2020
grantjenks added a commit that referenced this issue Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.