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

Prevent UI freeze in BSQ dashboard view. #6131

Merged
merged 2 commits into from Apr 7, 2022
Merged

Prevent UI freeze in BSQ dashboard view. #6131

merged 2 commits into from Apr 7, 2022

Conversation

ghost
Copy link

@ghost ghost commented Apr 4, 2022

@chimp1984 asked me to review DAO -> Facts & Figures -> Dashboard as it has been freezing the UI.

The BSQ dashboard listens to price update events so as to recalculate the UI periodically.
Observation shows that price updates are issued in fast succession for about 100 altcoins.
This PR solves the freezing issue by limiting the refresh rate of Dashboard to at most every 10 seconds.

Details
Apr-04 14:10:40.984 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SCP 6 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NAV 700 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PNC 25000 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PEPECASH 479 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XND 199900 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SDC 162564 
Apr-04 14:10:40.987 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : STEEM 544959 
Apr-04 14:10:40.988 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ODN 120000 
Apr-04 14:10:40.988 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : AEON 7250 
Apr-04 14:10:40.988 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DOI 20000 
Apr-04 14:10:41.003 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BSQ 2975 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NBT 234100 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : RSD 18440336100 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PASC 128695 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CROAT 190 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BCH 7485073 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GEL 260098300 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BTC 259053 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BTG 602718 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PGK 200429600 
Apr-04 14:10:41.004 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : OMR 22742200 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : HATCH 3200000 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : VEIL 300 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SEM 14500 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DXO 95 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ARS 9380484911 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : VTC 2000 
Apr-04 14:10:41.005 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PPI 6000 
Apr-04 14:10:41.007 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SC 164 
Apr-04 14:10:41.008 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : TRTL 1 
Apr-04 14:10:41.009 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SF 20000000 
Apr-04 14:10:41.010 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : RDD 77 
Apr-04 14:10:41.012 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CREA 6669 
Apr-04 14:10:41.012 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ASK 12 
Apr-04 14:10:41.012 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XUEZ 30000 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : USDT-E 2100 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CNMC 2260 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PIVX 4250 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ESP 1 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NMC 5000 
Apr-04 14:10:41.013 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ACH 30000 
Apr-04 14:10:41.058 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DAC 26000 
Apr-04 14:10:41.058 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DAI 2025 
Apr-04 14:10:41.060 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GRIN 580 
Apr-04 14:10:41.060 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : L-BTC 100100000 
Apr-04 14:10:41.060 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : VUV 38133470000 
Apr-04 14:10:41.061 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BLUR 600 
Apr-04 14:10:41.062 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ELLA 13000 
Apr-04 14:10:41.062 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CHA 1501 
Apr-04 14:10:41.063 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XZC 69156 
Apr-04 14:10:41.063 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : TRC 20000 
Apr-04 14:10:41.063 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : POST 9000 
Apr-04 14:10:41.065 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XRC 40000 
Apr-04 14:10:41.065 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : LBC 600 
Apr-04 14:10:41.066 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : MAID 16103 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CASH2 500 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GHS 311547500 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : KHR 23789019900 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : MAZA 12 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DNET 530 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : WMCC 10000 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : AUS 70 
Apr-04 14:10:41.067 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : AQUA 10000 
Apr-04 14:10:41.144 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NTBC 1 
Apr-04 14:10:41.145 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : LSK 39280 
Apr-04 14:10:41.148 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : MT 1500000 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SYP 42305158000 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SIB 9523 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : R-BTC 100900000 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ZOC 190 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BEAM 35000 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : RON 833092663 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XSL 1 
Apr-04 14:10:41.149 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : CRC 3508691560 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : D4RK 1000 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SIL 1311 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GRC 175 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : USDC 5258 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XCP 4000 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : SFSC 13000 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GBYTE 718869 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BURST 231 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NXT 2464 
Apr-04 14:10:41.150 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : LTZ 31 
Apr-04 14:10:41.151 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DRGL 20 
Apr-04 14:10:41.161 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : ONION 30000 
Apr-04 14:10:41.162 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : WAVI 299 
Apr-04 14:10:41.162 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PART 6600 
Apr-04 14:10:41.162 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : UNO 65000 
Apr-04 14:10:41.167 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : PARS 100 
Apr-04 14:10:41.167 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : RADS 17800 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DMD 26720 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : DMC 27500 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : AEUR 29400 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BCHC 500 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : IOP 90942 
Apr-04 14:10:41.168 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : XSPEC 2600 
Apr-04 14:10:41.169 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : BIS 3200 
Apr-04 14:10:41.169 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : GALI 449 
Apr-04 14:10:41.169 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : RIN 50 
Apr-04 14:10:41.200 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : KOTO 60 
Apr-04 14:10:41.206 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : NEOS 690 
Apr-04 14:10:41.206 [JavaFX Application Thread] INFO  b.c.p.price.PriceFeedService: *** update(bisq) : TEO 300 

@chimp1984
Copy link
Contributor

Hi @jmacxx Thanks for looking into that.
I just added myself logs to replicate that but I think those repeated calls are only happening at startup when the trade statistics call it for each currency to set latest price.
But then at run time that would not happen anymore. I got those freezes when having the app running or a while.
I will try out your fix to see if I get it still happening and add some more logs to get an idea what triggers it if that method is the reason.

@chimp1984
Copy link
Contributor

Also if the price updates are the reason we should look to other clients listening to it and fix it at the root by throtteling the change of that property.
If you search for
updateCounterProperty().addListener you will find quite a few...

We could make a speacialized IntegerProperty implementation which handles throtteling to avoid that the listeners get flooded. I think for that use case a 1-3 second throttle might be ok.

@ghost
Copy link
Author

ghost commented Apr 5, 2022

The block of price updates happens each time a new trade is added to tradestatistics.

I agree that the throttling can be done at the event source; it was only to minimize risk and keep within the scope of your original request that this solution was limited to the Dashboard.

@ripcurlx ripcurlx added this to the v1.9.0 milestone Apr 5, 2022
@chimp1984
Copy link
Contributor

chimp1984 commented Apr 5, 2022

I think the applyLatestBisqMarketPrice method should be optimized so that we are not rebuilding the lookup map each time but keep it cached and only add the new tradeStatistics at the appendOnlyDataStoreListener call in TradeStatisticsManager. The only the relevant added price is added to setBisqMarketPrice not all the latest from all currencies. That would reduce the load of the updates by itself and would not require a throttling then. For safety we can still keep the throttling but I think its better to fix it at the root.

Actually the caching should be done inside TradeStatisticsManager, its just another view on the data and should use references to avoid increase memory usage with duplicate data.

Price change events were being fired too frequently and for ccys
which had not changed.
This caused UI freezing issues most noticably in the DAO dashboard.
@ghost
Copy link
Author

ghost commented Apr 5, 2022

I made the requested changes and reverted the initial UI fix as its not needed anymore.
Tested OK with the BSQ Dashboard UI and in the app in general.

Copy link
Contributor

@chimp1984 chimp1984 left a comment

Choose a reason for hiding this comment

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

utACK

@chimp1984
Copy link
Contributor

chimp1984 commented Apr 5, 2022

Thanks @jmacxx Looks good! I will leave my app running a while with that branch to see if I still get issues. Hope there is not more...

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

utACK

@chimp1984
Copy link
Contributor

I left my app running over night with that branch and never got the issue triggered again. So I am pretty sure that PR fixed the observed problem. Great job @jmacxx ! Bug hunter hero!

Copy link
Contributor

@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 based on #6131 (comment)

@ripcurlx ripcurlx merged commit 02fac21 into bisq-network:master Apr 7, 2022
@ghost ghost mentioned this pull request Apr 26, 2022
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.

2 participants