Why is beancount v3 not faster for me?

210 views
Skip to first unread message

Aaron Stacy

unread,
Jan 5, 2025, 3:12:48 PM1/5/25
to bean...@googlegroups.com
I upgraded to beancount v3 and I'm happy I did with the type annotations and more focused deps (i.e. breaking out beangulp & others from the core).

Only thing that surprised me though was that it seems slightly slower (maybe a percentage point or so). I've got about 15k entries in my ledger, and I've got a few plugins. My implicit prices directive wraps beancount.prices.implicit_prices. This is on an M1 macbook.

As I said, v3 is for sure an over all improvement, but let me know if yall know of anything I'm missing out on here or if this is expected.

Here are a few runs of the check operation with v2:

∂me-macbookpro4 🅖 finances_beancount_v2
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                105 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          105 ms
INFO    : Operation: 'parse'                                          Time:          107 ms
INFO    : Operation: 'booking'                                        Time:          189 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 12 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                 16 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 33 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 33 ms
INFO    : Operation: 'run_transformations'                            Time:           96 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  6 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 43 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 13 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           68 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    462 ms
(env)
∂me-macbookpro4 🅖 finances_beancount_v2
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                102 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          103 ms
INFO    : Operation: 'parse'                                          Time:          105 ms
INFO    : Operation: 'booking'                                        Time:          189 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 12 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                 16 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 33 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 34 ms
INFO    : Operation: 'run_transformations'                            Time:           98 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  7 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 43 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 14 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           70 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    461 ms
(env)
∂me-macbookpro4 🅖 finances_beancount_v2
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                111 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          111 ms
INFO    : Operation: 'parse'                                          Time:          114 ms
INFO    : Operation: 'booking'                                        Time:          194 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 12 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                 16 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 33 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 34 ms
INFO    : Operation: 'run_transformations'                            Time:           96 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  6 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 42 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 13 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           68 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    473 ms



And then with v3:

∂me-macbookpro4 🅖 finances_beancount_v3
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                112 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          112 ms
INFO    : Operation: 'parse'                                          Time:          114 ms
INFO    : Operation: 'booking'                                        Time:          191 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                  5 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 31 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 26 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 33 ms
INFO    : Operation: 'run_transformations'                            Time:           99 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  6 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 43 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 13 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           68 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    472 ms
(env)
∂me-macbookpro4 🅖 finances_beancount_v3
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                113 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          113 ms
INFO    : Operation: 'parse'                                          Time:          116 ms
INFO    : Operation: 'booking'                                        Time:          195 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                  5 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 32 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 27 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 34 ms
INFO    : Operation: 'run_transformations'                            Time:          101 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  7 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 45 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 13 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           71 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    482 ms
(env)
∂me-macbookpro4 🅖 finances_beancount_v3
§ bean-check -v finances.beancount
INFO    : Operation: 'beancount.parser.parser.parse_file'             Time:                112 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:          112 ms
INFO    : Operation: 'parse'                                          Time:          115 ms
INFO    : Operation: 'booking'                                        Time:          194 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:                  5 ms
INFO    : Operation: 'finances.plugins.implicit_prices'               Time:                 32 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:                 27 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:                 34 ms
INFO    : Operation: 'run_transformations'                            Time:          100 ms
INFO    : Operation: 'function: validate_open_close'                  Time:                  1 ms
INFO    : Operation: 'function: validate_active_accounts'             Time:                  6 ms
INFO    : Operation: 'function: validate_currency_constraints'        Time:                  4 ms
INFO    : Operation: 'function: validate_duplicate_balances'          Time:                  1 ms
INFO    : Operation: 'function: validate_duplicate_commodities'       Time:                  0 ms
INFO    : Operation: 'function: validate_documents_paths'             Time:                  0 ms
INFO    : Operation: 'function: validate_check_transaction_balances'  Time:                 42 ms
INFO    : Operation: 'function: validate_data_types'                  Time:                 12 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:           66 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:    475 ms

Martin Blais

unread,
Jan 5, 2025, 4:34:26 PM1/5/25
to Beancount
There should not be a meaningful difference in performance. I think what you're reporting is just variance between runs. 

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/beancount/CACjABkks64zGD4NvyREvfnLe9hBGfxyMevF613gC4jdi1pJnCw%40mail.gmail.com.

Daniele Nicolodi

unread,
Jan 6, 2025, 4:06:01 PM1/6/25
to bean...@googlegroups.com
On 05/01/25 21:12, Aaron Stacy wrote:
> I upgraded to beancount v3 and I'm happy I did with the type annotations
> and more focused deps (i.e. breaking out beangulp & others from the core).
>
> Only thing that surprised me though was that it seems slightly slower
> (maybe a percentage point or so). I've got about 15k entries in my
> ledger, and I've got a few plugins. My implicit prices directive wraps
> beancount.prices.implicit_prices. This is on an M1 macbook.
>
> As I said, v3 is for sure an over all improvement, but let me know if
> yall know of anything I'm missing out on here or if this is expected.

I don't remember when the change landed exactly and whether it is
included in the 3.0 release, but we switched to the regex package to
evaluate some regular expression to correctly validate account names
containing non-ASCII characters. As the regular expressions are more
complex, this may have introduced a slight slowdown.

There is work underway to speed up the parser, but nothing had been
merged yet and I have been busy with other things.

Cheers,
Dan

Aaron Stacy

unread,
Jan 7, 2026, 9:48:45 AM (3 days ago) Jan 7
to Beancount
Ah thanks for the updates Martin and Daniele!

I run a lot of reporting scripts each month (returns, income, budgeting, etc), and really those and the tests I run to make sure those work as expected are what take the most time for me, so that's nothing to do with beancount itself.

Excited about parsing updates though! That'll make importing expenses so much nicer since the in-editor checks just re-run bean-check on each change, and my ledger has gotten a bit long.

Reply all
Reply to author
Forward
0 new messages