-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Optimize trade chart view [6] #5794
Optimize trade chart view [6] #5794
Conversation
dd0202d
to
4369db3
Compare
4369db3
to
45a40ab
Compare
I'm starting to review from 6cc4265 onwards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK - Reviewed code and tested it on Mainnet. Will wait for final test and merge after rebase to master.
Make buildUsdPricesPerTickUnit static and pass params Rename usdPriceMapsPerTickUnit to usdAveragePriceMapsPerTickUnit Rename local variable map to usdAveragePriceMap Move method calls syncPriceFeedCurrency() and setMarketPriceFeedCurrency() before other calls (those will become async later)
use it instead of updateSelectedTradeStatistics (preparation for follow up commit)
Convenience util for CompletableFuture.allOf method
The creation of TradeStatistics3ListItem is rather fast but the applying to the list is due sorting pretty slow (300 ms) as its > 100k items. We do the applying on the callback thread. Seems JavaFx permits that. So we can keep the UI thread unblocked. Remove modelReadyListener Renamed model.selectedTradeStatistics to model.tradeStatisticsByCurrency
in parallel and once both are done we call asyncUpdateChartData (not yet refactored). Clear all data at deactivate This cause a bit of costs when we activate again but as we delegate now all work to threads it should be OK. It decreases the memory usage if we do not keep those data in the fields. The View classes are cached in the view loader so all data in fields stays in memory once it was activated once and not manually cleared in deactivate. Move getTradeStatisticsForCurrency to ChartCalculations Rename buildUsdPricesPerTickUnit to getUsdAveragePriceMapsPerTickUnit Rename selectedTradeStatistics to tradeStatisticsByCurrency Make itemsPerInterval final Remove modelReady Add deactivateCalled flag
…rtCalculations Make maxTicks static and rename to MAX_TICKS
it to table in UI thread afterwards. Chain updateSelectedTradeStatistics and updateChartData calls.
45a40ab
to
a659a78
Compare
Merged/Rebased with master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
Based on #5790
Starts at ebf5eac
This optimizes performance and memory usage of the Trade Charts view (market).
It uses about 620MB (in JProfiler) when visible and 600 MB when at other view.
Before it was about 680-700 MB and memory did not really go lower when moving away (as we kept the data structures for caching).
It uses CompletableFutures and moved all heavy calculation code to static methods. So at view activation there is nothing heavy left on the UI thread and it can render faster, and as soon the tasks are completed the UI gets updated to render the table and charts.
I think that pattern can be used elsewhere (like BSQ Dashboard which also uses the trade stats and is therefore heavy). But it requires caution to not call JavaFx controls from a non UI thread.
EDIT: Merged and rebased with #5790