Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Last active May 13, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmichael/a0712bc395ec4603b70afa7722296660 to your computer and use it in GitHub Desktop.
Save simonmichael/a0712bc395ec4603b70afa7722296660 to your computer and use it in GitHub Desktop.
hledger performance notes

–perf/–bench flag for all commands

prints perf stats on stderr
time elapsed (s):
memory resident (Mb):
memory allocated (Mb):
throughput (ktxns/s):
normalised throughput (ktxns/s/mips):
2013 macbook air MIPS rating: 58240

MIPS equivalent performance units

> Vax 11/780               =   1 MIPS
> 10<sup>9</sup> Mind Children b/s   =   40 MIPS
> 1757 Dhrystones          =   1 MIPS
> 1 Dhrystone 2.1 MIPS     =   1 MIPS
> 1 Specmark               =   1 MIPS
> 1 Specint92              =   1 MIPS
> 1 Specint95              =   40 MIPS
> 1 Specint2000            =   4 MIPS
> 1 MacBench               =   0.66 MIPS
> 1 MacBench 5.0           =   0.58 MIPS	
> 1 MacBogoMIPS            =   7.3 MIPS
> 1 MacBogoMIPS Opt.       =   1.8 MIPS	
> 1 BYTEmark               =   100 MIPS
> 1 MacWorld Speedmark     =   110 MIPS
> 1 WinScore 2.0           =   3.4 MIPS
> 1 Sysmark 2002           =   15 MIPS
> 1 SPECint<sub>base2000</sub>       =   5 MIPS
> 1 SPECint<sub>rate</sub><sub>base2000</sub>  =   431 MIPS
> 1 Speedmark 4.5          =   18.5 MIPS
> 1 Cinebench 10           =   3.4 MIPS
> 1 Cinebench 11.5         =   8000 MIPS
> 1 Speedmark 6            =   110 MIPS
> 1 Speedmark 6.5          =   130 MIPS
> 1 Geekbench 2            =   5.5 MIPS
> 1 Geekbench 3            =   13 MIPS

MIPS by machine

> Type  
>        H  Hand (manual calculation)
>        G  Gear (mechanical calculator)
>        E  Electromechanical
>        V  Vacuum tube
>        T  Transistor
>        C  Ceramic (discrete components on small ceramic chip)
>        I  Integrated circuit
>        P  Processor (integrated microprocessor)
>        R  RISC processor
>        M  Multiprocessor
>        -+<>{\* layout hints for early graph
>
> Machine           Type  Date    Dollars     Mbytes       MIPS
> 
By<sub>Hand</sub>             -<H   1892       8500   9.54e-05   1.19e-08
Ohdner                G   1891      11000   1.49e-07   3.33e-09
Steiger<sub>Millionaire</sub>   G   1900      12000   3.58e-07   1.33e-08
Hollerith             G   1908      50000   0.000286   1.85e-08
Analytical<sub>Engine</sub>     G   1910      1e+06     0.0244   3.77e-07
Monroe<sub>Calculator</sub>   -{G   1911      35000   2.86e-06   2.18e-08
IBM<sub>Tabulator</sub>       +<G   1919      20000   2.38e-05   4.12e-08
Torres<sub>Arithmometer</sub>   E   1920      25000   4.77e-06   3.58e-08
National-Ellis<sub>3000</sub>   G   1928      15000   4.29e-06   7.38e-08
Burroughs<sub>Class</sub><sub>16</sub>   +G   1929      15000   4.29e-06   7.38e-08
Zuse-1              -<G   1938      10000   3.05e-05   4.24e-08
Zuse-2               EG   1939      10000   3.05e-05   4.24e-07
BTL<sub>Model</sub><sub>1</sub>           E   1939      50000   3.81e-06      2e-06
Zuse-3               EG   1941      50000   0.000244   2.04e-06
BTL<sub>Model</sub><sub>2</sub>           E   1943      50000   1.19e-05   1.03e-06
Colossus             +V   1943     100000   2.38e-06   0.000224
BTL<sub>Model</sub><sub>3</sub>           E   1943     200000   4.29e-05   2.83e-06
ASCC<sub>(Mark<sub>1</sub>)</sub>       -<E   1944     300000   0.000601   2.33e-06
Zuse-4                E   1945      50000   0.000244   2.04e-06
BTL<sub>Model</sub><sub>5</sub>           E   1946     500000   0.000147   3.29e-06
ENIAC                +V   1946     600000   9.54e-05    0.00289
Harvard<sub>Mark</sub><sub>2</sub>        E   1947     300000   0.000488   6.22e-06
IBM<sub>SSEC</sub>             VE   1948     500000   4.58e-05   0.000597
EDSAC                 V   1949     100000    0.00214    0.00255
SEAC                  V   1950     800000    0.00549    0.00416
UNIVAC<sub>I</sub>             +V   1951     930000    0.00537    0.00575
Zuse-5                E   1952     100000   0.000244   9.33e-06
IBM<sub>CPC</sub>              VE   1952     100000   0.000154    0.00176
IBM<sub>650</sub>             ->V   1953     200000    0.00488   0.000966
EDVAC                 V   1954     500000    0.00537     0.0017
Whirlwind           +<V   1955     200000    0.00391     0.0694
IBM<sub>704</sub>              +V   1955      2e+06     0.0352     0.0536
Librascope<sub>LGP</sub>-30     V   1956      50000     0.0159   0.000701
IBM<sub>7090</sub>            +>T   1959      3e+06      0.141      0.326
IBM<sub>1620</sub>             -T   1960     200000     0.0122    0.00103
DEC<sub>PDP</sub>-1             T   1960     150000     0.0176      0.124
Atlas                 T   1961      5e+06     0.0234        1.4
Burroughs<sub>5000</sub>      ->T   1962      1e+06     0.0254     0.0989
IBM<sub>7040</sub>             -T   1963     560000       0.07      0.063
Honeywell<sub>1800</sub>        T   1963    1400000      0.093      0.15
DEC<sub>PDP</sub>-6             T   1964     300000     0.0703      0.169
CDC<sub>6600</sub>              T   1964      5e+06          4       8.76
IBM<sub>1130</sub>            +{C   1965      50000     0.0156       0.15
IBM<sub>360</sub>/75           -C   1966      5e+06          8       2.54
IBM<sub>360</sub>/65            C   1967      3e+06          4       1.24
DEC<sub>PDP</sub>-10           +I   1968     500000      0.562      0.655
CDC<sub>7600</sub>             +T   1969      1e+07          8       25.7
DG<sub>Nova</sub>             ->I   1969       7600      0.008     0.1175
GE-635                T   1970      2e+06        0.5      0.649
SDS<sub>920</sub>              -T   1971     100000       0.25      0.105
IBM<sub>360</sub>/195           C   1972      8e+06        0.5       17.3
Honeywell<sub>700</sub>         I   1972      12000      0.031      0.075
Prime<sub>Computer</sub><sub>100</sub>    I   1973       8500      0.031       0.36
IBM-370/168           I   1974      2e+06          1       8.88
MITS<sub>Altair</sub>           P   1974        500    0.00024       0.01
DG<sub>Eclipse</sub>           +I   1975      50000       0.25       0.47
DEC-KL-10            -I   1975     500000        4.5        2.3
DEC<sub>PDP</sub>-11/70         I   1976     150000      0.125        0.4
Cray-1                I   1976      1e+07         32        150
Apple<sub>II</sub>             +P   1977       1300     0.0039       0.02
DEC<sub>VAX</sub><sub>11</sub>/780      -<P   1977     200000          8        1.0
TRS-80                P   1977       2000      0.015       0.04
Commodore<sub>PET</sub>         I   1977       1500      0.008       0.06
CDC<sub>IPL</sub>               I   1978     500000          1        7.5
Nanodata<sub>VMX200</sub>       I   1979     300000          2        2.1
TRS-80<sub>M3</sub>             P   1980       1200      0.015       0.04
Sun-1                 P   1980      30000          1      0.484
CDC<sub>Cyber</sub>-205         I   1981      9e+06         16       73.2
Vic<sub>20</sub>                P   1981        279      0.005       0.04
IBM<sub>PC</sub>              +<P   1982       3500     0.0635      0.238
Sun-2               +<P   1982      20000          2      0.741
Commodore<sub>64</sub>         +P   1982        500     0.0825        0.2
TRS-80<sub>M4</sub>             P   1983       1000     0.0635        0.2
Vax<sub>11</sub>/750          -<P   1983      50000          4      0.799
Macintosh-128K      +<P   1984       2500      0.125       0.52
Vax<sub>11</sub>/785            P   1984     200000     0.0156       2.26
Cray-2/4              M   1985      1e+07   1.95e+03        824
L.Edge<sub>XT</sub>-7.16        P   1985       1995       0.25       0.26
Atari<sub>800XL</sub>           P   1985        850       0.64      0.165
Sun-3               -<P   1986      10000          4       2.05
DEC<sub>VAX</sub><sub>8650</sub>          P   1986     125000         16       7.71
MIT<sub>XT</sub>-8              P   1986        500       0.25      0.534
Mac<sub>II</sub>               +P   1987       3000          2        2.5
Sun-4                 R   1987      10000         16       1.87
Mac-IIx               P   1988       9295          4        3.9
CompuAdd<sub>386</sub>-16       P   1988       2095          1        2.8
PC<sub>Brand</sub><sub>386</sub>-25       P   1988       2450          1        4.3
Wang<sub>VS</sub><sub>10000</sub>         P   1989     510000         16        103
Macintosh<sub>SE30</sub>        P   1989       6495          5        3.9
Solbourne<sub>5</sub>/500       P   1989      50000          2       25.5
Stardent<sub>3000</sub>         P   1990      89000         32       27.3
Dell<sub>320LX</sub>            P   1990       2900          1       12.5
Mac<sub>IIfx</sub>             -P   1990       9869          4       10.0
Amiga<sub>3000</sub>            P   1990       3300          2       12.5
Gateway-486DX2/66    +P   1991       3900          8       30.9
ACT<sub>468</sub>/33            P   1991       3400          4       21.8
Mac-Quadra-900        P   1991       3299          8       22.0
AST<sub>Bravo</sub>             P   1992       1400          2       12.9
IBM<sub>PS</sub>/2<sub>55</sub>-041       P   1992       2000          4       10.6
NEC<sub>Powermate</sub>         P   1992       4800          4       21.8
IBM<sub>Valuepoint</sub>        P   1993       3600          4       26.1
Acer<sub>Power</sub>            P   1993       3500          4       44.5
DECpc<sub>LPv</sub>             P   1993       2900          4       16.6
IBM<sub>433</sub>/DX/Si         P   1994       1800          4       26.1
Gateway<sub>2000</sub><sub>486</sub>      P   1994       1000          2       16.2
PowerMac<sub>7100</sub>/66      R   1994       2899          8        100
PowerMac<sub>8500</sub>/120     R   1995       3999         16        180
PowerMac<sub>9500</sub>/132     R   1995       5299         16        200
Intel<sub>Xpress</sub>/60       R   1995       2000          8         70
Gateway<sub>P5</sub>-75         P   1996       2000         16         92
Power<sub>Tower</sub><sub>180e</sub>     \*R   1996       3295         16        300
PowerMac<sub>7600</sub>/132     R   1996       2999         16        160
Gateway<sub>G6</sub>-200       \*P   1997       2949         64        350
Power<sub>Center</sub><sub>210</sub>      R   1997       2500         32        375
Mac<sub>G3</sub>/266            R   1997       2000         32        500
iMac<sub>G3</sub>/233          \*R   1998       1300         32        450
AcerPower8000/450B    P   1998       2250        128        475
Mac<sub>G3</sub>/333            R   1998       2300         64        650
Pentium<sub>II</sub>/455       \*P   1999       2000         64        750
Pentium<sub>III</sub>/500       R   1999       2500        128        820
Mac<sub>G4</sub>/450           \*R   1999       2500        128        856
IBM<sub>ASCI</sub><sub>White</sub>       \*M   2000      110e6        4e6       10e6
Sony<sub>Playstation</sub><sub>II</sub>  \*R   2000        300         32       6000
Mac<sub>G4</sub>/500<sub>dual</sub>      \*M   2000       3500        256       1500
CerfCube              R   2001        500         32        230
Mac<sub>G4</sub>/867            R   2001       2500        128       1300
Dell<sub>Workst</sub><sub>340</sub>/2G    P   2001       3000        256       3320
iMac<sub>G4</sub>/700           R   2002       1600        256       1100
Dell<sub>Workst</sub><sub>340</sub>/2.5   P   2002       2500        256       4500
Athlon<sub>XP</sub><sub>2.6GHz</sub>      P   2002       3000        256       4144
Mac<sub>G4</sub>/Dual-1.25GHz   M   2003       2000        512       2500
Dell<sub>D</sub><sub>8300</sub><sub>P4</sub>/3.0    P   2003       2500       2048       4439
Mac<sub>G5</sub>/Dual-2.0       M   2003       3500       1536       7413
Dell<sub>P4</sub>-530<sub>3.0</sub>       P   2004       1200        512       5100
Mac<sub>G5</sub>/Dual-2.5       M   2004       3500       2048      10000
VAtech<sub>SysX</sub><sub>2.3G</sub>      M   2004        6e6      4.5e6       20e6
Athlon64<sub>FX55</sub>-2.6     P   2004       2000       1024       6800
Mac<sub>Mini</sub><sub>G4</sub>-1.25      P   2005        500        256       1850
Opteron<sub>252</sub>-2.6       M   2005       1500       1024       7000
Mac<sub>G5</sub>/Quad-2.5       M   2005       3500       2048      24000
iMac-Core<sub>Duo</sub><sub>2.0x2</sub>   M   2006       1700        512      15000
Mac<sub>Pro</sub><sub>Xeon</sub><sub>2.66x4</sub>   M   2006       2500       1024      30000
Mac<sub>Mini</sub><sub>Duo</sub><sub>1.83x2</sub>   M   2006        800        512       9000
Mac<sub>Pro</sub>/2<sub>3GHzx8</sub>      M   2007       4000       2048      50000
Sun<sub>Blackbox</sub>          M   2007        5e5        1e6        5e6
IBM<sub>Blue</sub><sub>Gene</sub>/P       M   2007       13e5        2e6       14e6
Mac<sub>Pro</sub>/2.8GHzx8      M   2008       3500       4096      60000
IBM<sub>Roadrunner</sub>(LANL)  M   2008      133e6      100e6        1e9
Cray/XT5<sub>Jaguar</sub>(ORNL) M   2008      100e6      400e6        1e9
Mac<sub>Mini</sub><sub>Duo</sub><sub>2x2</sub>      M   2009        600       1024      11000
Acer<sub>Aspire</sub><sub>X1700</sub>     M   2009        480       4096      10000
Mac<sub>Nehalem</sub><sub>2.66x8</sub>    M   2009       4500       8192      78000
Cray/XT5<sub>Jaguar</sub>(ORNL) M   2010      100e6      400e6     1.75e9
Mac<sub>Westmere</sub><sub>2.93x12</sub>  M   2010       7000      16384     121000
Tianhe-1A(China)      M   2010      100e6      262e6     2.67e9
iPad-2                P   2011        500        512       1600
iMac<sub>21</sub><sub>i5</sub><sub>2.5x4</sub>      M   2011       1200       4096      40000
MacBook<sub>Pro</sub><sub>15</sub><sub>2.2x4</sub>  M   2011       1200       4096      51000
Fujitsu<sub>K</sub><sub>Computer</sub>    M   2012        1e9        1e9       10e9
Raspberry<sub>Pi</sub>          P   2012         25        256       1276
iPad-2012             M   2012        600       1024       4150
iPhone-5C             M   2013        500       1024       9210
iPhone-5S             M   2013        600       1024      18200
MacBookAir-11(2013)   M   2013       1100       4096      58240
MacPro12core2.7GHz    M   2013       7000      32768     488250
MacBookAir-11(2014)   M   2014        900       4096      62153
iPadAir2-A8X(2014)    M   2014        600       2048      58201
iMac27i7-4GHz         M   2014       2900      16384     213291
Raspberry<sub>Pi</sub><sub>2</sub>        M   2015         35       1024       9700
iPod<sub>Touch</sub>-A8(2015)   M   2015        200       1024      34600
>
> Machine           Type  Date    Dollars     Mbytes       MIPS

aliases should be in bench tests

<gwern> also, huge performance hit. 7-8s with HEAD and 2s with .23
<sm> you want '<sup>expenses</sup>:research' there, eg
<gwern> did you benchmark these alias changes?                  [16:04]
<sm> I was wondering about that, thanks for the test :/
<gwern> (I guess that's a 'no')
<sm> I ran the usual benchmarks, but I guess aliases were not exercised much
<sm> how many txns (hledger stat) and aliases have you ?        [16:05]
<gwern> 1910, and 35                                            [16:06]
<sm> thanks                                                     [16:07]
<sm> I'll add aliases to the bench tests
<sm> I wonder if it's quicker once you make your aliases precise
<gwern> strictifying all the aliases with ^$ doesn't fix the performance problem

balance could be faster

caching or keep-in-memory mode

Another thing I do is to use a cache for the frequent cases where the user runs multiple queries on a file that hasn't changed. This dramatically speeds up the query time. The web app keeps all the data in memory. It only needs to reload and pay the 4+ seconds cost when I save the file to disk.

Ah, and the bean-query tool starts in interactive mode if you don't provide a query on the command-line. That also keeps all the directive in memory and one can run multiple queries from the prompt most of which feel nearly instant. (The user can type the "reload" command to reparse the input file if it has changed.)

time/space logging

You can use the -v option on bean-check to get the breakdown of time taken by each step. Here's bean-check on my file (about 8-10 years of data):

BEANCOUNT<sub>DISABLE</sub><sub>LOAD</sub><sub>CACHE</sub>=1 bean-check -v $L
INFO    : Operation: 'beancount.parser.parser.parse<sub>file</sub>'             Time:
               739 ms
INFO    : Operation: 'beancount.parser.parser'                        Time:
         740 ms
INFO    : Operation: 'beancount.ops.pad'                              Time:
          74 ms
INFO    : Operation: 'beancount.ops.documents'                        Time:
          74 ms
INFO    : Operation: 'beancount.plugins.ira<sub>contribs</sub>'                 Time:
          17 ms
INFO    : Operation: 'beancount.plugins.implicit<sub>prices</sub>'              Time:
         181 ms
INFO    : Operation: 'beancount.plugins.sellgains'                    Time:
          20 ms
INFO    : Operation: 'office.payees'                                  Time:
        1292 ms
INFO    : Operation: 'beancount.plugins.check<sub>commodity</sub>'              Time:
          25 ms
INFO    : Operation: 'beancount.ops.balance'                          Time:
         556 ms
INFO    : Operation: 'function: validate<sub>open</sub><sub>close</sub>'                  Time:
                 5 ms
INFO    : Operation: 'function: validate<sub>active</sub><sub>accounts</sub>'             Time:
                38 ms
INFO    : Operation: 'function: validate<sub>currency</sub><sub>constraints</sub>'        Time:
                24 ms
INFO    : Operation: 'function: validate<sub>duplicate</sub><sub>balances</sub>'          Time:
                 8 ms
INFO    : Operation: 'function: validate<sub>duplicate</sub><sub>commodities</sub>'       Time:
                 4 ms
INFO    : Operation: 'function: validate<sub>documents</sub><sub>paths</sub>'             Time:
                 4 ms
INFO    : Operation: 'function: validate<sub>check</sub><sub>transaction</sub><sub>balances</sub>'  Time:
               237 ms
INFO    : Operation: 'function: validate<sub>data</sub><sub>types</sub>'                  Time:
                88 ms
INFO    : Operation: 'beancount.ops.validate'                         Time:
         409 ms
INFO    : Operation: 'beancount.loader (total)'                       Time:
  4347 ms

csv: conversion of WF checking is slow

web: sometimes really slow

eg on http://localhost:5000/register?q=inacct%3A%27assets%3Apersonal%3Abank%3Awells+fargo%3Achecking%27+

things to try

make all fields strict

http://stackoverflow.com/questions/8576795/advantages-of-strict-fields-in-data-types

String -> Text

INLINE pragmas

johnw, I doubled the speed of my parsec parser by adding INLINE pragmas to all definitions :P

ekg

import Control.Monad
import System.Remote.Monitoring

main :: IO ()
main = do
  ekg <- forkServer "localhost" 8000
  putStrLn "Started server on <http://localhost:8000>"
  forever $ getLine >>= putStrLn
ekg has several large dependencies so sometimes its desirable to optionally enable it with a cabal configuration flag so that it’s not included unless we want a development build. We just qualify our build-depends to include it in the dependencies if the flag is set via cabal configure -fekg.

flag ekg
  manual: True
  default: True
  description: Compile with ekg monitoring.

build-depends:
  if flag(ekg)
    build-depends:
      ekg >= 0.4 && < 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment