Commit Graph

17551 Commits

Author SHA1 Message Date
Steven Barclay
ee45202521
Remove redundant listener from TransactionsListItem
Eliminate a minor quadratic time bug, caused by the unnecessary addition
of a (BtcWalletService) TxConfidenceListener for each list item in the
Transactions view. (Since the confidence listeners are internally held
in a CopyOnWriteArraySet, this sadly runs in quadratic time, slowing
down the Transactions view load a little.)

The confidence listener is apparently redundant because of a set of
calls to 'TransactionsListItem.cleanup' immediately upon construction of
the item list, which removes all the listeners just added. (This code
appears to date from at least February 2016, in commit c70df86.)

(The confidence indicators are kept up to date by simply reloading the
entire list upon each wallet change event.)
2023-02-11 09:40:03 +08:00
Steven Barclay
2e8f03061e
TransactionsListItem cleanup: remove unused local variable
(This also avoids a redundant call to 'Tradable.getShortId', shaving off
another percent or two from the Transactions view load.)
2023-02-11 08:04:21 +08:00
Steven Barclay
97ef9c1308
Place filter in front of 'isRelatedToTransaction' for speedup
Use a crude Bloom filter (of sorts) to cut down the quadratic number of
calls to 'TransactionAwareTradable.isRelatedToTransaction' (that is, one
for each tx-tradable pair) during the Transactions view load. In this
way, we may reduce the number of calls roughly 40-fold, for a Bisq
instance with similar numbers of BSQ swap trades and escrow trades.

(Sadly, profiling does not show a 40-fold reduction in the size of the
'isRelatedToTransaction' hotspot, likely due to the remaining calls
being expensive ones involving disputed trades or unusual txs with
nonzero locktime, e.g. dust attacks or funds from Electrum wallets.)

To this end, partition the wallet transactions into 64 pseudo-randomly
chosen buckets (with a dedicated bucket for txs which might be delayed
payouts, namely those with nonzero locktime). Add an interface method,
'TransactionAwareTradable.getRelatedTransactionFilter', which returns an
IntStream of all the indices of buckets where a related tx may plausibly
be found. Where this is unclear, e.g. for trades involved in a dispute,
just return everything (that is, the range 0..63 inclusive).

Add a class, 'RelatedTransactionFilterSlices', that holds a provided
list of TransactionAwareTradable instances and 64 bitsets of all the
slices through their respective filters (each realised as 64-bit word
instead of a streams of integers). In this way, a list of tradables
plausibly related to any given tx may be quickly found by simply
selecting the appropriate bitset of the 64 (by the tx bucket index).
2023-02-11 07:55:36 +08:00
Steven Barclay
19a80d19bb
Short circuit txId hex encoding for BSQ swap offers
Inline a local variable, to eliminate another minor Sha256Hash.toString
hotspot in the Transactions view load, this time coming from
'TransactionsAwareOpenOffer.isRelatedToTransaction'. This is helpful in
the case that the user has a large number of (possibly disabled) BSQ
swap offers.
2023-02-10 10:28:02 +08:00
Steven Barclay
fb78345ba3
Avoid repeated Set<Tradable> build in transactions view load
Move the line,

   Set<Tradable> tradables = tradableRepository.getAll();

to the top level of 'TransactionsView.updateList', instead of needlessly
calling 'TradableRepository.getAll' (which builds a new set every
invocation) for each wallet transaction being iterated over.

This was causing a significant slowdown of the view load.
2023-02-09 21:35:32 +08:00
Steven Barclay
3aacc99f38
Tidy up TransactionsView slightly
1. Expression lambda -> method reference;
2. Statement lambda -> expression lambda;
3. Field -> local variable.
2023-02-09 21:16:40 +08:00
Steven Barclay
c913b7a428
Cache last txId to further speed up 'isRelatedToTransaction'
Use a mutable static tuple field to cache the last result of
'Sha256Hash.toString', which is used to get the ID string of the input
tx, when calling 'TransactionAwareTrade.isRelatedToTransaction'. In this
way, consecutive calls to 'isRelatedToTransaction' on the same input tx
(over all the past trades, as done by 'TransactionsView.updateList') are
sped up significantly, since hex encoding the txId is a bottleneck.
2023-02-09 17:13:14 +08:00
Steven Barclay
88dd924577
Clean up TransactionAwareTrade & speed it up slightly
Replace the "Optional.ofNullable(...)..." constructs with more direct
code using short-circuit operators, as this is shorter and a little
faster. Also use "trade.get[Deposit|Payout]TxId()" instead of the code
"trade.get[Deposit|Payout]TxId().getTxId()", as (upon inspection of the
code) there should never be a case where the deposit/payout transaction
field of a Trade object is set but the respective txID field is null (or
set to an inconsistent value).

Also remove a redundant 'RefundManager.getDisputesAsObservableList'
method call, which was also slowing things down slightly.

The minor speedups afforded by the above are important because the
method 'TransactionAwareTrade.isRelatedToTransaction' is called a
quadratic number of times and consequently a major bottleneck when
loading the Transactions view.
2023-02-09 14:34:18 +08:00
Alva Swanson
20c7dc3777
Connection: Rename singleThreadExecutor to executorService 2023-02-07 11:58:56 +01:00
Alva Swanson
b1e16f2748
Connection: Pass uid to executor service name 2023-02-07 11:58:10 +01:00
Alejandro García
b1e2cb03ad
Merge pull request #6568 from alvasw/gradle_apply_central_bisq_java_conventions
Gradle apply central bisq java conventions
2023-02-05 22:43:48 +00:00
Alejandro García
c41f21bbad
Merge pull request #6567 from alvasw/create_gradle_java_convention_precompiled_script
Gradle: Create bisq.java-conventions precompiled script
2023-02-05 22:42:53 +00:00
Alejandro García
c61bd70ead
Merge pull request #6562 from alvasw/move_get_single_thread_executor_to_own_utils
Move SingleThreadExecutors to its own Utils class
2023-02-05 22:42:02 +00:00
Alejandro García
a57a903e71
Merge pull request #6561 from alvasw/centralize_executor_shutdown_and_await
Centralize executor shutdown and await
2023-02-05 22:41:02 +00:00
Alejandro García
882afc1ff3
Merge pull request #6560 from alvasw/delegate_thread_pool_shutdown_to_guava
Delagate thread pool shutdown to Guava MoreExecutors
2023-02-05 22:40:14 +00:00
Alva Swanson
53837bf00b
Move SingleThreadExecutors to its own Utils class 2023-02-05 22:11:35 +01:00
Alva Swanson
06f24a1b79
Connection: Call centralized thread pool shutdown await method 2023-02-05 22:10:43 +01:00
Alva Swanson
b2870ccee3
Delagate thread pool shutdown to Guava MoreExecutors 2023-02-05 22:09:56 +01:00
Alva Swanson
c1c4caf87f
Gradle: Apply bisq.java-conventions to all projects 2023-02-05 22:02:13 +01:00
Alva Swanson
faf9b23bc5
Gradle: Create bisq.java-conventions precompiled script 2023-02-05 21:58:46 +01:00
Alejandro García
f15a5ded64
Merge pull request #6566 from alvasw/ci_use_gradle_build_action
CI: Use official Gradle Build Action
2023-02-05 19:04:03 +00:00
Alejandro García
f254dd9026
Merge pull request #6565 from alvasw/ci_target_setup_java_version_tag
GitHub Actions: Target setup-java action tag
2023-02-05 19:03:38 +00:00
Alejandro García
00bcb057f9
Merge pull request #6564 from alvasw/ci_checkout_do_not_fetch_full_history
Ci checkout do not fetch full history
2023-02-05 19:03:17 +00:00
Alejandro García
e23ad64b90
Merge pull request #6563 from alvasw/ci_target_checkout_version_tag
GitHub Actions: Target checkout action tag
2023-02-05 19:02:28 +00:00
Alejandro García
842c1977c3
Merge pull request #6559 from alvasw/remove_utilities_get_scheduled_thread_pool_executor
Remove unused Utilities.getScheduledThreadPoolExecutor(...)
2023-02-05 18:59:06 +00:00
Alejandro García
4e4e7fb67a
Merge pull request #6558 from alvasw/broadcaster_shutdown_executor
Broadcaster: Shutdown executor
2023-02-05 18:58:42 +00:00
Alejandro García
e6f2703738
Merge pull request #6557 from alvasw/export_json_files_service_shutdown_executor
ExportJsonFilesService: Shutdown Executor
2023-02-05 18:58:00 +00:00
Alejandro García
80ea00d104
Merge pull request #6556 from alvasw/scrypt_utils_fix_thread_leak
ScryptUtil: Fix thread leak
2023-02-05 18:57:10 +00:00
Alva Swanson
54d236ab67
CI: Use official Gradle Build Action 2023-02-05 14:31:49 +01:00
Alva Swanson
fe67785060
GitHub Actions: Target setup-java action tag 2023-02-05 14:18:28 +01:00
Alva Swanson
e7cd6a9570
Checkout (CI): Don't fetch full history 2023-02-05 14:13:28 +01:00
Alva Swanson
54668627ce
GitHub Actions: Target checkout action tag 2023-02-05 14:12:05 +01:00
Alva Swanson
bf95af07bd
Remove unused Utilities.getScheduledThreadPoolExecutor(...) 2023-02-05 13:42:39 +01:00
Alva Swanson
7e984f86ca
Broadcaster: Shutdown executor 2023-02-05 13:38:50 +01:00
Alva Swanson
7665780ca4
ExportJsonFilesService: Shutdown Executor 2023-02-05 13:36:09 +01:00
Alva Swanson
5506443d54
ScryptUtil: Fix thread leak
Each time someone called the static method
ScryptUtil.deriveKeyWithScrypt(...) a new worker pool was created. The
worker pool was never shutdown.
2023-02-05 13:31:15 +01:00
Alejandro García
e25c27ec99
Merge pull request #6551 from alvasw/fix_burningman_accounting_store_data_races
Fix BurningManAccountingStore data races
2023-02-04 12:43:36 +00:00
Alva Swanson
4779c82d0b
Fix BurningManAccountingStore data races
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes #6545
2023-02-03 23:41:51 +01:00
Alejandro García
8dbdecd6f1
Merge pull request #6549 from alvasw/fix_mailbox_message_service_thread_leak_explosion
Fix MailboxMessageService thread leak/explosion
2023-02-03 15:15:39 +00:00
Alejandro García
f24e0f231d
Merge pull request #6548 from alvasw/fix_dao_state_storage_service_shutdown_data_corruption_bug
DaoStateStorageService: Fix shutdown data corruption bug
2023-02-03 15:14:44 +00:00
Alejandro García
2239924225
Merge pull request #6552 from stejbac/speed-up-closed-trades-view-load
Speed up loading and scrolling of trade history
2023-02-03 15:13:58 +00:00
Alejandro García
27613de363
Merge pull request #6546 from jmacxx/offer_availability_dao_sync_check
Maker check DAO health when handling OfferAvailabilityRequest.
2023-02-03 15:10:57 +00:00
Steven Barclay
57b2b4b864
Add txs-by-id cache to WalletService to speed up trade history view
Add a third cache to WalletService, cleared upon wallet change events,
which maps txIds to txs. This allows the speedup of repeated calls to
'WalletService.getConfidenceForTxId', by avoiding the need to copy and
scan the entire set of wallet txs to find the one with matching id,
for each method invocation.

This is mainly to provide a further speedup to the closed-trades-view
load, by making it much faster to filter the list of BSQ swap trades by
tx confirmation status in 'ClosedTradesDataModel.applyList' and
'ClosedTradesManager.getNumPastTrades'.
2023-02-01 23:02:25 +08:00
Steven Barclay
42ea12f74c
Rename WalletService.getAddressToMatchingTxSetMultiset to multimap
The return value is a (cached) SetMultimap, not a multiset.
2023-02-01 20:48:32 +08:00
Steven Barclay
f02bc787d5
Optimize 'getNumPastTrades' to speed up trade history view
Reduce a bottleneck in the closed-trades-view load & table scrolling,
caused by a call to 'ClosedTradesManager.getNumPastTrades' for each
list item displayed. This repeatedly scans the entire collection of
closed trades and BSQ swap trades, in order to count all those which
share a given peer node address. (Scanning the BSQ swap trades is
particularly slow due to their filtering by tx confirmation status.)

To this end, cache the counts of trades by peer node address with a
nullable Multiset field in ClosedTradesManager & BsqSwapTradeManager,
so that the trades are scanned at most once when the view loads. Add
listeners to clear the respective cache when the trade list changes or
the BSQ wallet txs change.
2023-02-01 19:59:48 +08:00
Alejandro García
742d251193
Merge pull request #6550 from alvasw/xmr_tx_proof_request_shutdown_executor_service_in_terminate
XmrTxProofRequest: Shutdown executor service in terminate()
2023-01-31 19:11:35 +00:00
Alejandro García
9b61966e07
Merge pull request #6547 from alvasw/make_proto_output_stream_thread_safe
Make ProtoOutputStream thread-safe
2023-01-31 19:09:24 +00:00
Alejandro García
3f518d1602
Merge pull request #6538 from yonson2023/fix_issue_6536
Fix delimiter used for combined fields copypaste.
2023-01-31 19:07:54 +00:00
Alva Swanson
d9372f3a4c
XmrTxProofRequest: Shutdown executor service in terminate() 2023-01-31 17:21:34 +02:00
Alva Swanson
10c46a3163
Fix MailboxMessageService thread leak/explosion
Each time when MailboxMessageService.onAdded(...) got called with
multiple mailbox entries a new thread got created. That thread was never
shutdown. This change explicitly creates a new Thread and sets its
result with a SettableFuture. After its computation the thread
terminates.
2023-01-31 17:02:09 +02:00