cointop-sh / cointop

A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
https://cointop.sh
Apache License 2.0
3.98k stars 311 forks source link

Docker slow to respond #265

Open skiwithpete opened 2 years ago

skiwithpete commented 2 years ago

(thanks for updating the docker to .10)

Actions in Docker are taking a very long time to render. For example, smashing the [ key stops showing the change progress (from 3d to 7d for example) after a couple of presses and can take up to 10seconds to update. Then it takes an age to update the graph as well.

Another example is Shift+J or Shift+K taking 4 or 5 seconds for the graph to resize (whereas in earlier releases it was instantaneous).

I'm using on a 2019 i3 server, with a 2019 macbook pro in terminal.

Let me know what additional info I can provide to help find the cause.

Thanks,

Pete

lyricnz commented 2 years ago

I am not experiencing this (docker on macbook pro). How are you running docker?

https://user-images.githubusercontent.com/122371/140664892-89d5243f-2122-48e8-981c-8bede7e812fa.mov

lyricnz commented 2 years ago

I actually made a change recently #256 to improve the refresh after changing currencies. Seems quick here?

https://user-images.githubusercontent.com/122371/140664948-c3cf40d2-53ca-4311-b5ca-f4f72c254e32.mov

skiwithpete commented 2 years ago

Actually, it happens in portfolio view. And then, when I leave Portfolio view, it affects the main page as well.

/edit -- I didn't do a screengrab, because it just looks like nothing is happening, and you can't see my keystrokes. -- also I have different 11 coins in my portfolio. Some with just a few, and some lower cap ones with hundreds.

lyricnz commented 2 years ago

I can see a problem with swapping back and forth to portfolio mode (at least since previous release). Raised #266 on that. But doesn't seem to be slow.

skiwithpete commented 2 years ago

In portfolio mode pressing [ or ] doesn't go slow for you?

I'm running both a pretty powerful server and a powerful laptop...

Might be worth messing around with quantities of coins in your portfolio to see the problem I'm having.

lyricnz commented 2 years ago

Yes, [ and ] are slow when you have lots of coins. It looks like it's fetching the history for each coin, one by one (with a 2 second delay between, to avoid coingecko rate limiting etc). Wasn't that always the case?

$ DEBUG=1 DEBUG_HTTP=1 ./bin/cointop
....
$ grep doReq /tmp/cointop.log  | grep days=7
time="2021-11-08T12:59:57+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/wrapped-bitcoin/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:00+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:02+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/ethereum/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:04+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/binancecoin/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:07+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/solana/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:10+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/litecoin/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:12+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/avalanche-2/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:14+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/polkadot/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:17+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/avaterra/market_chart?days=7&vs_currency=AUD"
time="2021-11-08T13:00:19+11:00" level=debug msg="doReq GET https://api.coingecko.com/api/v3/coins/binance-peg-xrp/market_chart?days=7&vs_currency=AUD"
lyricnz commented 2 years ago

This delay has been in place for 3 years https://github.com/cointop-sh/cointop/blame/master/cointop/chart.go#L255

skiwithpete commented 2 years ago

Then is it an ordering bug? Like it should prioritize the change of state with the [ and cease the previous operation to avoid the slowdown?

On Sun, Nov 7, 2021 at 9:06 PM Simon Roberts @.***> wrote:

This delay has been in place for 3 years https://github.com/cointop-sh/cointop/blame/master/cointop/chart.go#L255

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cointop-sh/cointop/issues/265#issuecomment-962748695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQAEDOLWEKIJMZ2U3TILZTUK4WB5ANCNFSM5HRKGPXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

lyricnz commented 2 years ago

It's not doing anything else at the time, from what I can tell. The 2-second delay is intended to avoid (coingecko) rate-limiting. It would be very easy to hit 50 requests/minute (their API limit) with a couple of range-changes across a large portfolio. There's an existing issue to investigate/tune/minimize this #228

lyricnz commented 2 years ago

Maaaaaybe it would be possible to "fake" the new time range data (using the previous range, and dropping ~half the data), and update it in the background? Especially if moving to a shorter time range.