From 263c1dd1accfdd7a53afdda08c6abf7463c33931 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 17 Oct 2021 08:47:11 +0200 Subject: [PATCH] Added chunk size debug option --- app/src/main/java/eu/faircode/email/Core.java | 7 +++-- .../faircode/email/FragmentOptionsMisc.java | 31 ++++++++++++++++++- .../main/res/layout/fragment_options_misc.xml | 25 ++++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 038880ed2b..9d8a545699 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -67,7 +67,6 @@ import com.sun.mail.imap.IMAPStore; import com.sun.mail.imap.protocol.FLAGS; import com.sun.mail.imap.protocol.FetchResponse; import com.sun.mail.imap.protocol.IMAPProtocol; -import com.sun.mail.imap.protocol.Namespaces; import com.sun.mail.imap.protocol.UID; import com.sun.mail.pop3.POP3Folder; import com.sun.mail.pop3.POP3Message; @@ -137,10 +136,11 @@ import javax.mail.search.SentDateTerm; import me.leolin.shortcutbadger.ShortcutBadger; class Core { + static final int DEFAULT_SYNC_CHUNCK_SIZE = 100; + private static final int MAX_NOTIFICATION_DISPLAY = 10; // per group private static final int MAX_NOTIFICATION_COUNT = 100; // per group private static final long SCREEN_ON_DURATION = 3000L; // milliseconds - private static final int SYNC_CHUNCK_SIZE = 100; private static final int SYNC_BATCH_SIZE = 20; private static final int DOWNLOAD_BATCH_SIZE = 20; private static final int SYNC_YIELD_COUNT = 100; @@ -3120,7 +3120,8 @@ class Core { ranges.add(new Pair<>(first, last < 0 ? first : last)); // https://datatracker.ietf.org/doc/html/rfc2683#section-3.2.1.5 - List>> chunks = Helper.chunkList(ranges, SYNC_CHUNCK_SIZE); + int chunk_size = prefs.getInt("chunk_size", DEFAULT_SYNC_CHUNCK_SIZE); + List>> chunks = Helper.chunkList(ranges, chunk_size); Log.i(folder.name + " executing uid fetch count=" + uids.size() + " ranges=" + ranges.size() + " chunks=" + chunks.size()); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 77d782cef0..e8b8b157d5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -135,6 +135,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swCheckpoints; private TextView tvSqliteCache; private SeekBar sbSqliteCache; + private TextView tvChunkSize; + private SeekBar sbChunkSize; private ImageButton ibSqliteCache; private SwitchCompat swModSeq; private SwitchCompat swExpunge; @@ -174,7 +176,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "experiments", "crash_reports", "cleanup_attachments", "protocol", "debug", "log_level", "query_threads", "wal", "checkpoints", "sqlite_cache", - "use_modseq", "perform_expunge", + "chunk_size", "use_modseq", "perform_expunge", "auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "exact_alarms", "dup_msgids", "test_iab" }; @@ -263,6 +265,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvSqliteCache = view.findViewById(R.id.tvSqliteCache); sbSqliteCache = view.findViewById(R.id.sbSqliteCache); ibSqliteCache = view.findViewById(R.id.ibSqliteCache); + tvChunkSize = view.findViewById(R.id.tvChunkSize); + sbChunkSize = view.findViewById(R.id.sbChunkSize); swModSeq = view.findViewById(R.id.swModSeq); swExpunge = view.findViewById(R.id.swExpunge); swAuthPlain = view.findViewById(R.id.swAuthPlain); @@ -775,6 +779,27 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + sbChunkSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + progress = progress / 10; + if (progress < 1) + progress = 1; + progress = progress * 10; + prefs.edit().putInt("chunk_size", progress).apply(); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + // Do nothing + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + // Do nothing + } + }); + swProtocol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1287,6 +1312,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc Helper.humanReadableByteCount(cache_size * 1024L))); sbSqliteCache.setProgress(sqlite_cache); + int chunk_size = prefs.getInt("chunk_size", Core.DEFAULT_SYNC_CHUNCK_SIZE); + tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size)); + sbChunkSize.setProgress(chunk_size); + swModSeq.setChecked(prefs.getBoolean("use_modseq", true)); swExpunge.setChecked(prefs.getBoolean("perform_expunge", true)); swAuthPlain.setChecked(prefs.getBoolean("auth_plain", true)); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index d9f113f460..05868d8589 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -744,6 +744,29 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/ibSqliteCache" /> + + + + WAL Checkpoints Sqlite cache: %1$s %% - %2$s + Chunk size: %1$d MODSEQ EXPUNGE PLAIN