Skip to content

1.29-1.32.2: performance regression with many accounts #2153

Description

@markokocic

This issue was discussing a severe performance regression affecting 1.29-1.32.2 with many accounts.
(There is a separate moderate drop in general performance affecting hledger 1.26 and later, see #2122.
The issue for comparing hledger vs Ledger performance is #2363.)


Lately I noticed that hledger was not as fast as it was. It is an issue because some scripts that I have that execute hledger multiple times are becoming very slow.

I decided to benchmark it against ledger.

My system:

marko@fine ~> hledger stats
Main file                : /home/marko/src/ledgers/transactions.ledger
Included files           :
Transactions span        : 2011-11-29 to 2024-01-16 (4431 days)
Last transaction         : 2024-01-15 (3 days from now)
Transactions             : 17385 (3.9 per day)
Transactions last 30 days: 156 (5.2 per day)
Transactions last 7 days : 37 (5.3 per day)
Payees/descriptions      : 3382
Accounts                 : 470 (depth 6)
Commodities              : 4 ($, inr, rsd, €)
Market prices            : 0 ()

Run time (throughput)    : 3.45s (5035 txns/s)

Balance command

marko@fine ~> time hledger bal > /dev/null

________________________________________________________
Executed in    4.07 secs    fish           external
   usr time    3.91 secs  878.00 micros    3.91 secs
   sys time    0.18 secs  185.00 micros    0.18 secs

Then I converted my journal file in order to use it with ledger:

marko@fine ~> hledger print --round=soft > test.journal

And tested it again with ledger

marko@fine ~> time ledger bal -f test.journal > /dev/null

________________________________________________________
Executed in  381.00 millis    fish           external
   usr time  344.67 millis    1.35 millis  343.31 millis
   sys time   36.13 millis    0.20 millis   35.93 millis

The result is that for balance operation, hledger takes 10 times more time that ledger.

My system is a small Linux VM with 2 CPU and 4 GB RAM. Hledger is the latest one built from source.

Other commands are also slower. Notice above that hledger print took 3.45 seconds. In ledger it's less than 1 second.

marko@fine ~> time ledger print -f test.journal > /dev/null

________________________________________________________
Executed in    1.13 secs      fish           external
   usr time  984.76 millis    1.29 millis  983.47 millis
   sys time  144.16 millis    0.23 millis  143.92 millis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.affects3-fewAffects just a few users.annoyance4-majorMajor usability/doc bug, or any regression or crash.bountyThar's some kind o' loot on offer..performanceAnything performance-related (run time, memory usage, disk space..)regressionA backwards step, indicating a weakness in our QA. We don't like these.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions