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

MapCache's cache size slow loading #138

Closed
vincentneo opened this issue Nov 9, 2019 · 6 comments
Closed

MapCache's cache size slow loading #138

vincentneo opened this issue Nov 9, 2019 · 6 comments

Comments

@vincentneo
Copy link
Collaborator

vincentneo commented Nov 9, 2019

I have tested the app quite a lot, and had my cache size at 77.4MB.
It took quite a while for that large of a cache size to load. Placeholder text 'Zero KB', is hence, slightly confusing to a possible user too.

I have tried making MapCache branch fasterDirectorySize by using someone else's code to count file directory size, but while it seems marginally faster, it still is, only 'marginally faster'. I guess I forgot to 'clean' before running. Actually quite a lot faster! :)

@vincentneo
Copy link
Collaborator Author

Further tests seems to show something weirder: (Same cache size throughout this test, cache has increased since original comment.)

  • Current commit - Size: 86.2 MB
  • Branch fasterDirectorySize- Size: 106.6 MB

Instead of the current commit being slow, I have noticed that, it seems like the size calculation have already done, but label was not updated. (If I were to slightly pull the view down and back, the label is updated with the size).

The other commit loads almost instantaneously without user intervention.

@merlos
Copy link
Owner

merlos commented Nov 10, 2019

@vincentneo It used to work in iOS12, but I think with iOS13 stopped working.

Regarding the weird size, did you run the unit tests of MapCache? Although there are some issues with them, size test seemed to work fine.

@vincentneo
Copy link
Collaborator Author

I haven't tried the unit tests. That said, I was wondering that could it be an async-related issue of some sort instead?

@merlos
Copy link
Owner

merlos commented Nov 23, 2019

I found out the reason why you get a different size.

While current implementation looks at the actual data the file has (for instance, an image may have 656 bytes of data) the implementation you shared counts the allocated disk, which is done in blocks of 4096 bytes. In the 656 bytes example you would get 1 block = 4096 bytes.

Now, my doubt now is what makes more sense to count... disk usage or the actual size...

In any case, there is an issue returning the cache size in MapCache in iOS13

@vincentneo
Copy link
Collaborator Author

So in that kind of a rationale, a 4097 bytes image would report 8192 bytes, due to actual allocation on disk?

In that case, I feel that it would make more sense to have your implementation, as I feel that the size calculation, should some what follow what is default in macOS anyway: a 152 byte text file is still represented as such, except in 'Get Info', where its represented as 152 bytes (4 KB on disk)

@merlos
Copy link
Owner

merlos commented Nov 24, 2019

I finally decided to implement the calculation of both sizes in MapCache (V0.6.0), however I switched to use the allocated disk size internally for keeping capacity limits

While updating OpenGPXTracker I noticed: merlos/MapCache#14

Fix will be applied when merging #139

@merlos merlos closed this as completed Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants