osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.73k stars 1.03k forks source link

Use transparent zlib library for compressed OsmAnd maps #10653

Open hvdwolf opened 3 years ago

hvdwolf commented 3 years ago

Currently the OsmAnd files are big (not to say huge). Uncompressed some almost run into the (old) 2GB FAT-16 limit. (And I know this has been led to the decision to split countries in smaller size due to this limit) We are now currently using the OBF version 2 format (since 2011?). Please create an OBF version 3 map format based on zlib compressed maps. The zlib license is a "free software license" comparable with GPL.

zlib and compressed maps have the following advantages:

"Irrelevant" counter arguments: :wink:

hvdwolf commented 3 years ago

Note: If the obf format is heavily sqlite(3) based, one can still use the zlib library. Sqlite knows the CEROD(*) extension for compressed databases also based on the zlib library.

*: CEROD: Compressed and Encrypted Read-Only Database

vshcherb commented 3 years ago

I don't think it's actually very relevant but we can't afford zipping maps cause binary references inside the files will be broken, so indexes won't work correctly. You need to zip atomic bulks of data, so you can access and build indexes on top of it.

hvdwolf commented 3 years ago

I don't have the background to judge that, but I do know other navigation apps using the same technique. Considering the fact that zlib is transparent as a layer between the reading logic and the data, it should not matter. If it's not feasible, then so be it. But has it actually ever been examined?

vshcherb commented 3 years ago

No, but it's not clear the ultimate goal of it. Making maps 20% smaller doesn't look very attractive to a deep research and refactoring. So the truth is to make some incremental steps to improve situation but I don't know which steps exactly and how to make yet.

hvdwolf commented 3 years ago

Not 20% smaller. It is the same as the currently zip compressed map. Both zip and zlib use DEFLATE. So compressed map size will be 40-60% of that of an uncompressed map. Like said: size is not the goal. Improving reading speed is the goal, thereby hopefully improving rendering speed as well.

I can't do it myself so I will leave it with this. Hopefully some time in the future. You can close after reading :)

trou commented 3 years ago

For what it's worth, zstd is probably better than zlib: faster and more efficient.

hvdwolf commented 3 years ago

Great 😃 . I fully agree to implement that. But I don't think it will be implemented in the near future.

tiziodcaio commented 5 months ago

First of all, how maps are generated? We should add a new workflow which generates compressed maps, then implement the support in osmand. It should not be such that hard to do!

sonora commented 5 months ago

In my experience with recent optimization work (on our gpx file handling), OsmAnd spends a significant amount of time on I/O.

Chances are, as @hvdwolf already noted above, supporting to work with files zipped in storage could actually make the app snappier by reducing I/O. And this may be true for all types of files, gpx and maps alike.

Would in deed be interesting to test...