hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger-web renders slow

Open dstrelnikov opened this issue 7 years ago • 5 comments
trafficstars

Hi!

If I want to adjut the scaling then the html page of hledger-web renders really slow (on a good competer). I think its a consequence of a big nubmer of transactions in my journal.

Maybe it would be good to sepatate the transactions list on pages?

dstrelnikov avatar Jul 24 '18 14:07 dstrelnikov

This is already tracked in another issue here (I'm mobile right now, I'll find it later), and it's quite high in priority on my todo list for hledger-web, I just haven't had the time lately.

zarybnicky avatar Jul 24 '18 14:07 zarybnicky

@zarybnicky, thanks a lot!

dstrelnikov avatar Jul 24 '18 16:07 dstrelnikov

Would someone like to follow up on this ? @dstrelnikov how many transactions have you, how much data is the page downloading, how long does it take to download & render ?

simonmichael avatar Feb 12 '19 00:02 simonmichael

@dstrelnikov how many transactions have you, how much data is the page downloading, how long does it take to download & render ?

$ hledger stats   
Main file                : /home/aquadon/Documents/.ledger/ledger.journal
Included files           : /home/aquadon/Documents/.ledger/prices.dat    
                           /home/aquadon/Documents/.ledger/accounts.dat  
                           /home/aquadon/Documents/.ledger/modifiers.dat 
                           /home/aquadon/Documents/.ledger/budget.journal
Transactions span        : 2017-07-01 to 2019-03-01 (608 days)
Last transaction         : 2019-02-28 (16 days from now)
Transactions             : 1565 (2.6 per day)
Transactions last 30 days: 66 (2.2 per day)
Transactions last 7 days : 14 (2.0 per day)
Payees/descriptions      : 547
Accounts                 : 144 (depth 4)
Commodities              : 8

The page is rendering quite fast, but it's very slow to rescale it. I think some pagination will help.

dstrelnikov avatar Feb 12 '19 14:02 dstrelnikov

The same problem is tracked in the old issue #586

Skimming through the options for pagination in Yesod, the only semi-maintained library is https://hackage.haskell.org/package/yesod-paginator-1.1.0.1/, but I'm not sure it's worth pulling in another dependency just for this. https://ersocon.net/blog/2016/10/10/pagination-in-yesod-from-naive-to-monads describes a simple approach to static server-rendered pagination.

I'd say a good start is simple server-rendered pagination, paginating via query string parameters (offset+count or page no.+count) and keeping the rendering logic as is. The next step would be to move the rendering logic to the client and add a JSON-based API to the server, for implementing infinite scrolling or other pagination variants, but even just server-rendered pagination would solve the usability problem without too much work.

zarybnicky avatar Feb 17 '19 11:02 zarybnicky