[bisq-network/bisq] Speed up trades charts view load (#3828)

Steven Barclay notifications at github.com
Mon Dec 23 23:17:37 UTC 2019


Use a `LinkedHashMap` in place of a `List`, for the caching `CurrencyUtil` fields `allSortedFiatCurrencies` & `allSortedCryptoCurrencies`, using the same iteration order as before. In this way, we can avoid a linear search in the lookup methods `getFiatCurrency` & `getCryptoCurrency`.

In particular, this speeds up the activation of `TradesChartsView` (and to a lesser extent `OfferBookChartView`), which make a lot of calls to `CurrencyUtil.getTradeCurrency` in the `fillTradeCurrencies`/`updateChartData` methods respectively.

Additionally, do some tiding of `TradeChartsViewModel` and remove some unused constructor-injected fields from that class and others.

To reproduce the hotspot, one can select the _Trades_ tab under _Market_ at least once, then flipping repeatedly between (say) the _Market_ and _Buy BTC_ panels, the following hotspots are revealed by JProfiler:

![Screenshot from 2019-12-23 23-01-07](https://user-images.githubusercontent.com/54855381/71384295-64a63800-25d8-11ea-808b-a7522077f490.png)

(The also very significant `com.sun.javafx.collections.VetoableListDecorator.setAll` hotspot seen at the bottom of the screenshot occurs during the initialisation of many views, but I haven't been able to find the cause or a fix for that yet.)
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/3828

-- Commit Summary --

  * Remove unused fields passed as constructor params from various classes
  * Optimise CurrencyUtil.get[Fiat|Crypto|Trade]Currency

-- File Changes --

    M core/src/main/java/bisq/core/app/WalletAppSetup.java (11)
    M core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java (9)
    M core/src/main/java/bisq/core/locale/CurrencyUtil.java (46)
    M core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java (8)
    M desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java (11)
    M desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java (2)
    M desktop/src/main/java/bisq/desktop/main/MainView.java (10)
    M desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java (2)
    M desktop/src/main/java/bisq/desktop/main/account/content/notifications/ManageMarketAlertsWindow.java (24)
    M desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java (11)
    M desktop/src/main/java/bisq/desktop/main/dao/news/NewsView.java (6)
    M desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsView.java (6)
    M desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java (11)
    M desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java (47)
    M desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java (4)
    M desktop/src/main/java/bisq/desktop/main/offer/createoffer/CreateOfferView.java (11)
    M desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java (7)
    M desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesView.java (8)
    M desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferView.java (10)
    M desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java (15)
    M desktop/src/main/java/bisq/desktop/main/settings/network/NetworkSettingsView.java (11)
    M desktop/src/main/java/bisq/desktop/main/settings/network/P2pNetworkListItem.java (5)
    M desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java (4)
    M desktop/src/test/java/bisq/desktop/MarketsPrintTool.java (6)
    M desktop/src/test/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModelTest.java (20)
    M desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java (9)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/3828.patch
https://github.com/bisq-network/bisq/pull/3828.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/3828
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191223/ddcb3df1/attachment.html>


More information about the bisq-github mailing list