Skip to content

Commit

Permalink
Merge #1217: [Startup][GUI][Performance] Optimizations for huge wallets.
Browse files Browse the repository at this point in the history
7a1a639 [Trivial] Adding load txs on demand todo text. (furszy)
6d5c84e [Startup] Decrease the amount of blocks checked for corruption in the startup. (furszy)
7c9dd0d [GUI][Performance] Optimizations to every list view load in the GUI. (furszy)
b1aa1e2 [Model] Maximum amount of loaded record in ram, preventing any self-spamming. (furszy)

Pull request description:

  Made several changes in order to improve the wallet startup and navigation performance in huge wallets (wallets with more than 20,000 transactions).
   

  1) Maximum amount of loaded transaction records in the GUI set to 20,000.
  * If the wallet has more, then it will not load them into the UI anymore. Hard to think that any user will be benefited from having 100k txs that he/she made in 2 years always visible when them are most likely all spent and only the latest 5k txs have utxo..

  2) Optimized every listview load in the GUI.
  * The list items are laid out in batches of a certain size, instead of all of the items loaded at once in the first run.
  * Uniform row size flag enabled in every list optimizing their painting.

  3) Db verification decreased to 10 blocks.
  * Previously our wallet was checking, disconnecting and reconnecting the last 100 blocks in the startup, looking for inconsistencies. That is really too much, if we have any inconsistency, it should appear in the last 10 blocks.

ACKs for top commit:
  Fuzzbawls:
    ACK 7a1a639
  random-zebra:
    ACK 7a1a639 and merging...

Tree-SHA512: 66f2241d881bd82a97848ad6c3975b7b512cde9bf6d42a6c67c2864cf7382e40ce99e611085f673abaff604decd9fd00acdd75a63211e1c89c82ce2cc0fc0bef
  • Loading branch information
Liquid369 committed Jan 2, 2020
1 parent 6a1a1da commit 4a2b6e9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ int64_t nStart;
}

// Zerocoin must check at level 4
if (!CVerifyDB().VerifyDB(pcoinsdbview, 4, GetArg("-checkblocks", 100))) {
if (!CVerifyDB().VerifyDB(pcoinsdbview, 4, GetArg("-checkblocks", 10))) {
strLoadError = _("Corrupted block database detected");
fVerifyingBlocks = false;
break;
Expand Down
1 change: 1 addition & 0 deletions src/qt/dogecash/addresseswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ AddressesWidget::AddressesWidget(DogeCashGUI* parent) :
ui->listAddresses->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listAddresses->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listAddresses->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listAddresses->setUniformItemSizes(true);

//Empty List
ui->emptyContainer->setVisible(false);
Expand Down
1 change: 1 addition & 0 deletions src/qt/dogecash/coldstakingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ ColdStakingWidget::ColdStakingWidget(DogeCashGUI* parent) :
ui->listViewStakingAddress->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listViewStakingAddress->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listViewStakingAddress->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listViewStakingAddress->setUniformItemSizes(true);

connect(ui->pushButtonSend, &QPushButton::clicked, this, &ColdStakingWidget::onSendClicked);
connect(btnOwnerContact, &QAction::triggered, [this](){ onContactsClicked(true); });
Expand Down
3 changes: 3 additions & 0 deletions src/qt/dogecash/dashboardwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ DashboardWidget::DashboardWidget(DogeCashGUI* parent) :
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listTransactions->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listTransactions->setLayoutMode(QListView::LayoutMode::Batched);
ui->listTransactions->setBatchSize(50);
ui->listTransactions->setUniformItemSizes(true);

// Sync Warning
ui->layoutWarning->setVisible(true);
Expand Down
3 changes: 3 additions & 0 deletions src/qt/dogecash/privacywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ PrivacyWidget::PrivacyWidget(DogeCashGUI* parent) :
ui->listView->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listView->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listView->setLayoutMode(QListView::LayoutMode::Batched);
ui->listView->setBatchSize(30);
ui->listView->setUniformItemSizes(true);
}

void PrivacyWidget::loadWalletModel(){
Expand Down
1 change: 1 addition & 0 deletions src/qt/dogecash/receivewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ReceiveWidget::ReceiveWidget(DogeCashGUI* parent) :
ui->listViewAddress->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listViewAddress->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->listViewAddress->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listViewAddress->setUniformItemSizes(true);

spacer = new QSpacerItem(40, 20, QSizePolicy::Maximum, QSizePolicy::Expanding);
ui->btnMyAddresses->setChecked(true);
Expand Down
20 changes: 20 additions & 0 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@

#define SINGLE_THREAD_MAX_TXES_SIZE 4000

// Maximum amount of loaded records in ram in the first load.
// If the user has more and want to load them:
// TODO, add load on demand in pages (not every tx loaded all the time into the records list).
#define MAX_AMOUNT_LOADED_RECORDS 20000

// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
Qt::AlignLeft | Qt::AlignVCenter, /* status */
Expand Down Expand Up @@ -89,6 +94,21 @@ class TransactionTablePriv
std::size_t txesSize = walletTxes.size();
if (txesSize > SINGLE_THREAD_MAX_TXES_SIZE) {

// First check if the amount of txs exceeds the UI limit
if (txesSize > MAX_AMOUNT_LOADED_RECORDS) {
// Sort the txs by date just to be really really sure that them are ordered.
// (this extra calculation should be removed in the future if can ensure that
// txs are stored in order in the db, which is what should be happening)
sort(walletTxes.begin(), walletTxes.end(),
[](const CWalletTx & a, const CWalletTx & b) -> bool {
return a.GetComputedTxTime() < b.GetComputedTxTime();
});

// Only latest ones.
walletTxes = std::vector<CWalletTx>(walletTxes.begin(), walletTxes.begin() + MAX_AMOUNT_LOADED_RECORDS);
txesSize = walletTxes.size();
};

// Simple way to get the processors count
std::size_t threadsCount = (QThreadPool::globalInstance()->maxThreadCount() / 2 ) + 1;

Expand Down

0 comments on commit 4a2b6e9

Please sign in to comment.