On below tests, ledger v3 is 21 and 46 times slower that ledger v2.
Some specs:
- CPU is AMD Athlon(tm) Dual Core Processor 4850e, 2500MHz, 64 bits
- RAM is 1790MiB
- OS is Ubuntu 9.10
John, I sent you privately the ledger file.
Thierry
---
$ ledger3 print --anon -f thierry.ledger > thierry.ledger.anon
$ time ledger -f thierry.ledger.anon reg 2eb75f84 1eede0cb >/dev/null
real 0m2.166s
user 0m1.940s
sys 0m0.210s
$ time ledger -f thierry.ledger.anon -V reg 2eb75f84 1eede0cb >/dev/
null
real 0m7.300s
user 0m7.050s
sys 0m0.160s
$ time ledger3 --european -f thierry.ledger.anon reg 2eb75f84 1eede0cb
>/dev/null
real 0m47.190s
user 0m18.100s
sys 0m28.770s
$ time ledger3 --european -f thierry.ledger.anon -V reg 2eb75f84
1eede0cb >/dev/null
real 5m42.510s
user 3m0.020s
sys 2m40.350s
$ ledger -v
Ledger 2.6.2, the command-line accounting tool
$ ledger3 -v
Ledger master-0-g5471370, the command-line accounting tool
> On below tests, ledger v3 is 21 and 46 times slower that ledger v2.
How did you build it?
John
How did you build it?
How did you build it?
cd ledger && ./acprep update
> As an experiment, I played with "acprep gprof update" in a duplicated directory. My input ledger file contains 24920 non empty lines. and I was surprised by the number of calls to some ledger functions (between 150 and 200 millions of calls). I do not know if there is anything to dig in this area. I can send gprof output if needed.
Yes, I would very much like to see your gprof output.
John
It looks like you've exposed a somewhat pathological case with regard to multiple currencies. Ledger is doing far too much make work than it should be. Is there any chance I can gain access to your data file? Use "ledger print --anon" may, in your case, yield a file which still exposes this problem.
Thanks, John
On Feb 27, 2010, at 5:37 PM, thierry wrote:
You have to build it as such:
acprep opt update
> On below tests, ledger v3 is 21 and 46 times slower that ledger v2.
After several days of intensive examination, I think now there is little help for what you're seeing. The slowness comes from (a) the size of your data file and how many commodities you're using, and (b) the correctness and new behavior of --exchange (and, to a lesser extent, -V).
To illustrate what I mean, I've added a new command "pricemap". It outputs a DOT file showing the pricing relationships between all commodities in your data file at a given date. To give an example of how complex the situation can be, consider this data file:
http://ftp.newartisans.com/pub/exchange.dat
At 2009/01/03, the price relationships are as shown here:
http://ftp.newartisans.com/pub/090103.png
But by 2009/01/10, they have changed significantly:
http://ftp.newartisans.com/pub/090110.png
When you use --exchange $, Ledger tries to find the most recent conversion to $ that it can. To do this, it considers not only whether a commodity A could be priced in dollars, but whether it could also be priced in terms of B, which could then be priced in dollars. And so on. It must walk the graph of all possible connections to $, truncating the search only if the most recent valuation down that leg is older than the most recent found so far. Sometimes, it can take several hops before the most recent conversion price is found.
Note to mention that all of this can happen several times for a single posting: while computing the amount, the running total, to see if a revaluation has occurred, to see if a rounding error has occurred, etc.
I have managed to speed things up a fair bit, however, so please try your tests again with the latest 'next' branch. Here are the improvements, using an "acprep opt" build on a 2.26GHz Core i7 (all output going to /dev/null):
Before optimization work (current 'master' branch):
reg, no flags 6.86s
reg, -V 39.23s
reg, -X 85.92s
After optimization work (current 'next' branch):
reg, no flags 5.00s
reg, -V 13.39s
reg, -X 12.91s
John
> After optimization work (current 'next' branch):
>
> reg, no flags 5.00s
> reg, -V 13.39s
> reg, -X 12.91s
Note too that with --no-rounding, I can get -V and -X numbers within only 2x slower. That is, if you don't need that information (which strictly speaking is there only for exactitude, but adds little value).
John
I've download next branch (with modification suppressing rounding) and
did "./acprep opt update" (no use of boost mt)
$ ledger -v
Ledger next-0-gefcede3, the command-line accounting tool
Here are results:
1. My first use case (something like "ledger Assets:Invest --exchange=
€ -J")
- 5m59.399s (previous ledger version, with rounding)
- 3m31.564s (this ledger version, without rounding)
- 0m1.314s (this ledger version, without rounding, without --exchange
option)
2. My second use case (something like "ledger Assets Liabilities --
exchange=€ -J")
- 39m34.209s (previous ledger version, with rounding)
- 27m1.114s (this ledger version, without rounding)
- 0m5.279s (this ledger version, without rounding, without --exchange
option)
There is definitely an amelioration by dropping the exact rounding
(41% for 1st, 32% for 2nd).
But may I ask to dig further about --exchange impact?
Thanks
Thierry
> Your results are :
>
> > using an "acprep opt" build on a 2.26GHz Core i7 (all output going to /dev/null):
> >
> > reg, no flags 5.00s
> > reg, -V 13.39s
> > reg, -X 12.91s
>
> My results are, on a AMD Athlon(tm) Dual Core Processor 4850e, 2500MHz, 64 bits
>
> $ time ledger reg > /dev/null
> real 0m12.727s
> $ time ledger reg -X € > /dev/null
> real 2m8.355s
>
> The ratio are 12.7/5=2.54 and 128.355/12.91=9.94
>
> When my ledger executable is running I can see that only one core is used. I suspect you used a compilation option that enables ledger executable to use several cores when running. Am I right ? What is this option ?
This is troubling. Ledger only ever uses one core, however it uses main memory pretty
heavily. So the fact that my i7 has direct access to main memory could account for a bit of the difference. But an order of magnitude? Also, on OS X I'm using the -fast option to gcc, which is often 2-3x faster than -O3. What version of gcc do you have?
John
$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
> Also, on OS X I'm using the -fast option to gcc, which is often 2-3x faster than -O3.
--fast is a Mac OX X only option
(http://developer.apple.com/mac/library/documentation/DeveloperTools/gcc-4.0.1/gcc/Optimize-Options.html)
I've dig and read a little about compilation flags:
- gcc man pages
- gentoo Compilation Optimization Guide (a linux distro where they
recompile every bit), and they recommend "-march=k8 -O2 -pipe"
- AMD GCC Quick Reference Guide (my CPU is AMD Athlon 64 x2), and they
recommend "-O3 -mtune=k8 -funroll-all-loops -fprefetch-loop-arrays
-ffast-math"
Here are the results:
With defaults from "./acprep opt" :
CFLAGS = -O3 -fomit-frame-pointer
CXXFLAGS = -fpch-deps -Wconversion -pthread -O3 -fomit-frame-pointer -pipe
time ~/ledger/ledger reg -X € -J > /dev/null
real 2m5.204s
With CXXFLAGS = CFLAGS = -march=k8 -O2 -pipe
time ~/ledger-O2/ledger reg -X € -J > /dev/null
real 2m12.285s
With CXXFLAGS = CFLAGS = -O3 -mtune=k8 -funroll-all-loops
-fprefetch-loop-arrays -ffast-math
time ~/ledger-O3/ledger reg -X € -J > /dev/null
real 2m13.937s
My conclusion is that I will stick with defaults compiler flags from
"acprep opt"...
Thierry
> Hello, On below tests, ledger v3 is 21 and 46 times slower that ledger v2.
> Some specs:
> - CPU is AMD Athlon(tm) Dual Core Processor 4850e, 2500MHz, 64 bits
> - RAM is 1790MiB
> - OS is Ubuntu 9.10
At last, Thierry, this is solved. I'm now using the Boost.Graph library to
manage historical commodity prices, and Dijkstra's shortest-path algorithm to
find most-recent conversion rates.
Care to test out your example again? :)
John