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

Ledger compiles with debug information - thus decreasing speed. #2299

Open
n4s-linux opened this issue Nov 22, 2023 · 9 comments
Open

Ledger compiles with debug information - thus decreasing speed. #2299

n4s-linux opened this issue Nov 22, 2023 · 9 comments

Comments

@n4s-linux
Copy link

Problem

Ledger turns out to be pretty slow with many transactions - up to a second with around 20.000 postings.

Solution

Clone and compile with ./acprep opt # for optimizations

Ledger --version doesnt show its a debugging version

Even though it was a debugging version, ledger --version says:
0ms [INFO] Ledger starting
Ledger 3.3.0-20230208, the command-line accounting tool

Copyright (c) 2003-2023, John Wiegley. All rights reserved.

This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.
Error: No journal file was specified (please use -f)
0ms [INFO] Ledger ended

@afh
Copy link
Member

afh commented Nov 30, 2023

Not sure what the issue is here. @n4s-linux can you please clarify? Is that ledger by default compiles with debug by default but shouldn't according to you?

@n4s-linux
Copy link
Author

Hi there. Yes, it turns out that with debug information compared to the optimized binary without debug info - it its 8 times faster.
So by compiling ledger without debugging, we are saving a lot of time.
It may not matter to most users, - but if You grow You book to 20k transactions, You will surely notice - it can take up to 800ms. The same book can be run without debugging in only 100ms.

@afh
Copy link
Member

afh commented Nov 30, 2023

Could be that changing to the debug build flavor by default was done unintentional.

See https://github.com/ledger/ledger/blob/master/acprep#L234-L235, it seems the codelines date back to e0473e2 when John "[r]ewrote acprep in Python and improved the build".

If you build using ./acprep default is the compiled ledger's speed acceptable for you, @n4s-linux?

@n4s-linux
Copy link
Author

that builds the slow version for me.
takes 1.138 seconds to run my book (23.4k postings)
whereas the optimized binary will only take 0.174 seconds.

which is ~6.5 times slower than my current binary.

i used acprep opt to get the fast version

@afh
Copy link
Member

afh commented Dec 1, 2023

After a quick investigation I think the performance improvements are mainly due to acprep setting NO_ASSERTS (which I believe should be DISABLE_ASSERTS as that is the option declared in CMakeLists.txt, which then sets NO_ASSERTS). Generally asserts could be useful in production code, yet the function implementing asserts is called debug_assert (assert is a macro), so its intended use is likely not for production.

@afh
Copy link
Member

afh commented Dec 2, 2023

To better understand your measurements, @n4s-linux, would you be willing to share how, i.e. with which commands, you measure performance and possible share your anonymised underlying dataset (e.g. ledger print --anon)?

@n4s-linux
Copy link
Author

Sure thing.
Not sure if the book balances when it puts all the A's in front of the amount, i surely cant run that book
anon.txt

@afh
Copy link
Member

afh commented Dec 5, 2023

Thanks, @n4s-linux, and to get a better understanding how you measure performance, which commands do you run?

@afh
Copy link
Member

afh commented Dec 5, 2023

Note to self: Unless ledger is compiled with DISABLE_ASSERTS tracing, which may slow down ledger, is still available (see ledger.hh.in:64)

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

No branches or pull requests

2 participants