Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issue in BsqWalletService #3177

Merged

Conversation

chimp1984
Copy link
Contributor

The updateBsqWalletTransactions method got called at each block for all
transactions. During block download that wasted a lot of cpu and
led to stuck UI thread and lost connections.
The updateBsqBalance is not cheap (a few ms) and called for 100s of txs
at each block was very problematic.
Furthermore the listeners on the walletTransactions observableList got
triggered which made the situation worse.

We changed the observableList to a ArrayList and use a listener which
gets called after the list is updated.
We also make sure the onTransactionConfidenceChanged listener is not
calling updateBsqWalletTransactions if bsq parsing is not complete and
if the depth of the tx is > 1.
In the updateBsqWalletTransactions method we use a flag and a delay
to ensure that the updateBsqBalance is not called more then once
in 100 ms.

We changed also the getter to return a cloned version of the list to
avoid potential concurrent modification exceptions at clients.

Closes #3175

The updateBsqWalletTransactions method got called at each block for all
transactions. During block download that wasted a lot of cpu and
led to stuck UI thread and lost connections.
The updateBsqBalance is not cheap (a few ms) and called for 100s of txs
at each block was very problematic.
Furthermore the listeners on the walletTransactions observableList got
triggered which made the situation worse.

We changed the observableList to a ArrayList and use a listener which
gets called after the list is updated.
We also make sure the onTransactionConfidenceChanged listener is not
calling updateBsqWalletTransactions if bsq parsing is not complete and
if the depth of the tx is > 1.
In the updateBsqWalletTransactions method we use a flag and a delay
to ensure that the updateBsqBalance is not called more then once
in 100 ms.

We changed also the getter to return a cloned version of the list to
avoid potential concurrent modification exceptions at clients.

Closes bisq-network#3175
@sqrrm
Copy link
Member

sqrrm commented Sep 1, 2019

Changes look reasonable but while running I notice that the awaiting blocks... Verified nnn blocks out of mmm is now counting out both the verified number and the total expected.

Screenshot_2019-09-02_00-07-13
Screenshot_2019-09-02_00-07-30
Screenshot_2019-09-02_00-07-42
Screenshot_2019-09-02_00-07-59

@chimp1984
Copy link
Contributor Author

chimp1984 commented Sep 1, 2019

@sqrrm That is expected while block download as the chain tip gets updated with new blocks. The right one is from BitcoinJ, the left one the parsed blocks.

@sqrrm
Copy link
Member

sqrrm commented Sep 1, 2019

@chimp1984 The right one should be the known block height from bitcoinj but it keeps changing, that's strange.

@chimp1984
Copy link
Contributor Author

chimp1984 commented Sep 1, 2019

but it keeps changing, that's strange.

If that is during block download it is expected, otherwise its a bug. I will test again.

@chimp1984
Copy link
Contributor Author

Just tested again but did the block download completed before parsing started. But taht way all was as expected.

Copy link
Member

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@ripcurlx ripcurlx merged commit 9c0be82 into bisq-network:master Sep 2, 2019
@sqrrm
Copy link
Member

sqrrm commented Sep 2, 2019

Made a video. The total used to be known at start, now it's changing, and the progress is not showing correctly.

blocksync

@chimp1984
Copy link
Contributor Author

chimp1984 commented Sep 2, 2019

@sqrrm
Yes that shows that you received the BSQ blocks before the blocks had been synced (you should see the % of download not completed on the left bottom side for BTC). The code should handle that case so that you repeat requesting BSQ blocks. But maybe there are bugs in that part if your BSQ blocks don't get updated again.

@chimp1984 chimp1984 deleted the fix-bsq-wallet-performance-issue branch September 2, 2019 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Startup problems
3 participants