forked from Qortal/qortal
Moved AT State & online signatures trimming intervals, batch sizes, limits, etc. to Settings
This commit is contained in:
parent
5cf5c1e1f7
commit
532c697026
@ -13,14 +13,6 @@ public class AtStatesTrimmer implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(AtStatesTrimmer.class);
|
||||
|
||||
private static final long TRIM_INTERVAL = 2 * 1000L; // ms
|
||||
|
||||
// This has a significant effect on execution time
|
||||
private static final int TRIM_BATCH_SIZE = 200; // blocks
|
||||
|
||||
// Not so significant effect on execution time
|
||||
private static final int TRIM_LIMIT = 4000; // rows
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setName("AT States trimmer");
|
||||
@ -32,7 +24,7 @@ public class AtStatesTrimmer implements Runnable {
|
||||
while (!Controller.isStopping()) {
|
||||
repository.discardChanges();
|
||||
|
||||
Thread.sleep(TRIM_INTERVAL);
|
||||
Thread.sleep(Settings.getInstance().getAtStatesTrimInterval());
|
||||
|
||||
BlockData chainTip = Controller.getInstance().getChainTip();
|
||||
if (chainTip == null || NTP.getTime() == null)
|
||||
@ -47,13 +39,13 @@ public class AtStatesTrimmer implements Runnable {
|
||||
|
||||
int trimStartHeight = repository.getATRepository().getAtTrimHeight();
|
||||
|
||||
int upperBatchHeight = trimStartHeight + TRIM_BATCH_SIZE;
|
||||
int upperBatchHeight = trimStartHeight + Settings.getInstance().getAtStatesTrimBatchSize();
|
||||
int upperTrimHeight = Math.min(upperBatchHeight, upperTrimmableHeight);
|
||||
|
||||
if (trimStartHeight >= upperTrimHeight)
|
||||
continue;
|
||||
|
||||
int numAtStatesTrimmed = repository.getATRepository().trimAtStates(trimStartHeight, upperTrimHeight, TRIM_LIMIT);
|
||||
int numAtStatesTrimmed = repository.getATRepository().trimAtStates(trimStartHeight, upperTrimHeight, Settings.getInstance().getAtStatesTrimLimit());
|
||||
repository.saveChanges();
|
||||
|
||||
if (numAtStatesTrimmed > 0) {
|
||||
|
@ -7,6 +7,7 @@ import org.qortal.data.block.BlockData;
|
||||
import org.qortal.repository.DataException;
|
||||
import org.qortal.repository.Repository;
|
||||
import org.qortal.repository.RepositoryManager;
|
||||
import org.qortal.settings.Settings;
|
||||
import org.qortal.utils.NTP;
|
||||
|
||||
public class OnlineAccountsSignaturesTrimmer implements Runnable {
|
||||
@ -15,11 +16,6 @@ public class OnlineAccountsSignaturesTrimmer implements Runnable {
|
||||
|
||||
private static final long INITIAL_SLEEP_PERIOD = 5 * 60 * 1000L + 1234L; // ms
|
||||
|
||||
private static final long TRIM_INTERVAL = 2 * 1000L; // ms
|
||||
|
||||
// This has a significant effect on execution time
|
||||
private static final int TRIM_BATCH_SIZE = 200; // blocks
|
||||
|
||||
public void run() {
|
||||
Thread.currentThread().setName("Online Accounts trimmer");
|
||||
|
||||
@ -30,7 +26,7 @@ public class OnlineAccountsSignaturesTrimmer implements Runnable {
|
||||
while (!Controller.isStopping()) {
|
||||
repository.discardChanges();
|
||||
|
||||
Thread.sleep(TRIM_INTERVAL);
|
||||
Thread.sleep(Settings.getInstance().getOnlineSignaturesTrimInterval());
|
||||
|
||||
BlockData chainTip = Controller.getInstance().getChainTip();
|
||||
if (chainTip == null || NTP.getTime() == null)
|
||||
@ -42,7 +38,7 @@ public class OnlineAccountsSignaturesTrimmer implements Runnable {
|
||||
|
||||
int trimStartHeight = repository.getBlockRepository().getOnlineAccountsSignaturesTrimHeight();
|
||||
|
||||
int upperBatchHeight = trimStartHeight + TRIM_BATCH_SIZE;
|
||||
int upperBatchHeight = trimStartHeight + Settings.getInstance().getOnlineSignaturesTrimBatchSize();
|
||||
int upperTrimHeight = Math.min(upperBatchHeight, upperTrimmableHeight);
|
||||
|
||||
if (trimStartHeight >= upperTrimHeight)
|
||||
|
@ -83,8 +83,22 @@ public class Settings {
|
||||
private long repositoryBackupInterval = 0; // ms
|
||||
/** Whether to show a notification when we backup repository. */
|
||||
private boolean showBackupNotification = false;
|
||||
|
||||
/** How long to keep old, full, AT state data (ms). */
|
||||
private long atStatesMaxLifetime = 2 * 7 * 24 * 60 * 60 * 1000L; // milliseconds
|
||||
/** How often to attempt AT state trimming (ms). */
|
||||
private long atStatesTrimInterval = 5678L; // milliseconds
|
||||
/** Block height range to scan for trimmable AT states.<br>
|
||||
* This has a significant effect on execution time. */
|
||||
private int atStatesTrimBatchSize = 100; // blocks
|
||||
/** Max number of AT states to trim in one go. */
|
||||
private int atStatesTrimLimit = 4000; // records
|
||||
|
||||
/** How often to attempt online accounts signatures trimming (ms). */
|
||||
private long onlineSignaturesTrimInterval = 9876L; // milliseconds
|
||||
/** Block height range to scan for trimmable online accounts signatures.<br>
|
||||
* This has a significant effect on execution time. */
|
||||
private int onlineSignaturesTrimBatchSize = 100; // blocks
|
||||
|
||||
// Peer-to-peer related
|
||||
private boolean isTestNet = false;
|
||||
@ -420,4 +434,24 @@ public class Settings {
|
||||
return this.atStatesMaxLifetime;
|
||||
}
|
||||
|
||||
public long getAtStatesTrimInterval() {
|
||||
return this.atStatesTrimInterval;
|
||||
}
|
||||
|
||||
public int getAtStatesTrimBatchSize() {
|
||||
return this.atStatesTrimBatchSize;
|
||||
}
|
||||
|
||||
public int getAtStatesTrimLimit() {
|
||||
return this.atStatesTrimLimit;
|
||||
}
|
||||
|
||||
public long getOnlineSignaturesTrimInterval() {
|
||||
return this.onlineSignaturesTrimInterval;
|
||||
}
|
||||
|
||||
public int getOnlineSignaturesTrimBatchSize() {
|
||||
return this.onlineSignaturesTrimBatchSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user