Added debug setting for DB checkpoints

pull/205/head
M66B 3 years ago
parent b228b8313c
commit 7c05b65f34

@ -124,6 +124,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swDebug;
private SwitchCompat swQueries;
private SwitchCompat swWal;
private SwitchCompat swCheckpoints;
private TextView tvSqliteCache;
private SeekBar sbSqliteCache;
private ImageButton ibSqliteCache;
@ -157,7 +158,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"shortcuts", "fts",
"classification", "class_min_probability", "class_min_difference",
"language", "deepl_enabled", "watchdog", "updates", "weekly",
"experiments", "wal", "query_threads", "sqlite_cache", "crash_reports", "cleanup_attachments",
"experiments", "wal", "checkpoints", "query_threads", "sqlite_cache", "crash_reports", "cleanup_attachments",
"protocol", "debug", "log_level",
"use_modseq", "perform_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl",
@ -239,6 +240,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swDebug = view.findViewById(R.id.swDebug);
swQueries = view.findViewById(R.id.swQueries);
swWal = view.findViewById(R.id.swWal);
swCheckpoints = view.findViewById(R.id.swCheckpoints);
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
@ -614,6 +616,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swCheckpoints.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("checkpoints", checked).apply();
}
});
sbSqliteCache.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -1097,6 +1106,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swDebug.setChecked(prefs.getBoolean("debug", false));
swQueries.setChecked(prefs.getInt("query_threads", 4) < 4);
swWal.setChecked(prefs.getBoolean("wal", true));
swCheckpoints.setChecked(prefs.getBoolean("checkpoints", true));
int sqlite_cache = prefs.getInt("sqlite_cache", DB.DB_DEFAULT_CACHE);
int cache_size = sqlite_cache * class_mb * 1024 / 100;

@ -57,14 +57,14 @@ public class WorkerFts extends Worker {
Log.i("FTS index");
Context context = getApplicationContext();
DB.checkpoint(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean checkpoints = prefs.getBoolean("checkpoints", true);
int indexed = 0;
List<Long> ids = new ArrayList<>(INDEX_BATCH_SIZE);
DB db = DB.getInstance(context);
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
for (long id : db.message().getMessageFts())
try {
@ -105,6 +105,9 @@ public class WorkerFts extends Worker {
markIndexed(db, ids);
if (checkpoints)
DB.checkpoint(context);
Log.i("FTS indexed=" + indexed);
return Result.success();
} catch (Throwable ex) {

@ -640,6 +640,17 @@
app:layout_constraintTop_toBottomOf="@id/tvQueriesRemark"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckpoints"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_checkpoints"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swWal"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSqliteCache"
android:layout_width="0dp"
@ -650,7 +661,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swWal" />
app:layout_constraintTop_toBottomOf="@id/swCheckpoints" />
<SeekBar
android:id="@+id/sbSqliteCache"

@ -630,6 +630,7 @@
<string name="title_advanced_debug">Debug mode</string>
<string name="title_advanced_query_threads">Limit parallel database access</string>
<string name="title_advanced_wal" translatable="false">WAL</string>
<string name="title_advanced_checkpoints" translatable="false">Checkpoints</string>
<string name="title_advanced_sqlite_cache" translatable="false">Sqlite cache %1$s %% - %2$s</string>
<string name="title_advanced_modseq" translatable="false">MODSEQ</string>
<string name="title_advanced_expunge" translatable="false">EXPUNGE</string>

Loading…
Cancel
Save