diff options
author | Mayeul Cantan <oss+nheko@mayeul.net> | 2022-07-19 13:42:28 +0200 |
---|---|---|
committer | Mayeul Cantan <oss+nheko@mayeul.net> | 2022-07-19 14:13:14 +0200 |
commit | 702d7e620ff8ce8c2b49700f8c784a2dac66e556 (patch) | |
tree | 32909ce8805507253b703f2a37caeeafc9dd1340 /src/Cache.cpp | |
parent | Translated using Weblate (Finnish) (diff) | |
download | nheko-702d7e620ff8ce8c2b49700f8c784a2dac66e556.tar.xz |
Better handle 32-bit platforms by limitting database size
Experimentally, setting the database size to 2GB didn't work. These values are quite arbitrary, and should probably be settings or automatically adjusted.
Diffstat (limited to '')
-rw-r--r-- | src/Cache.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp index 79a5ea04..9782ee99 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -46,10 +46,16 @@ static const std::string_view OLM_ACCOUNT_KEY("olm_account"); static const std::string_view CACHE_FORMAT_VERSION_KEY("cache_format_version"); static const std::string_view CURRENT_ONLINE_BACKUP_VERSION("current_online_backup_version"); +constexpr auto MAX_DBS = 32384UL; +#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit +constexpr auto DB_SIZE = 32ULL * 1024ULL * 1024ULL * 1024ULL; // 32 GB constexpr size_t MAX_RESTORED_MESSAGES = 30'000; - -constexpr auto DB_SIZE = 32ULL * 1024ULL * 1024ULL * 1024ULL; // 32 GB -constexpr auto MAX_DBS = 32384UL; +#elif Q_PROCESSOR_WORDSIZE == 4 // 32-bit address space limits mmaps +constexpr auto DB_SIZE = 1ULL * 1024ULL * 1024ULL * 1024ULL; // 1 GB +constexpr size_t MAX_RESTORED_MESSAGES = 5'000; +#else +#error unknown word size on target CPU +#endif constexpr auto BATCH_SIZE = 100; //! Cache databases and their format. |