Skip to content

ledgermill 0.2.0

Choose a tag to compare

@srod srod released this 15 Nov 15:27
· 65 commits to main since this release
v0.2.0
1da4bce

Added

  • Beancount: arithmetic in a number ((1 + 2) * 3, 10 / 4, -(2 - 5)) in a posting's units, a price, a
    cost, a balance and its tolerance, a price directive and metadata. The values, places and exponents
    are the reference's (28 digits, half to even); an inexact quotient has a tolerance of its own. A division
    by zero is a division-by-zero finding that leaves out its entry. A malformed expression ((1 + )) is a
    parse-error and, like any parse error, leaves the file with no transactions. A sign in front of a sign and a ~
    tolerance that is a sum, both without parentheses, are still refused (number-expression). format()
    aligns expressions as bean-format does. See spec/beancount/number-expressions.md.
  • Beancount: plugin "beancount.plugins.auto_accounts" is built: every account used and never opened gets an open
    on the day of its first use, so a journal with no open lines is valid. Every other plugin is still refused
    (unsupported-syntax), and the finding now names it in details.name. An indented plugin line is
    accepted, though the reference rejects it (a gap of every indented directive). See
    spec/beancount/auto-accounts.md.
  • Beancount: plugin "beancount.plugins.implicit_prices" is built: a price annotation (@, @@) and the
    cost of a posting that opens a lot add price entries, on the transaction's date and line, so prices(),
    value() and holdings() follow them. A price annotation wins over a cost, a cost that reduces a lot
    makes no price (with NONE booking every costed posting opens a lot, so each makes one), equal entries of
    one run are dropped, and every plugin line of the root file runs it once more. A configuration string is still refused.
    See spec/beancount/implicit-prices.md.
  • fuzz.ts --beancount writes arithmetic in numbers now and then.
  • fuzz.ts --beancount and --multi switch implicit_prices and auto_accounts on now and then (with auto_accounts, some or all open lines
    dropped) and the summary counts the journals that had each.
  • Beancount: a posting flag * straight before the account (*Assets:Bank) is read.

Changed

  • The Beancount files of one load are one ledger, read in the order given, as the reference reads a file
    that includes the others: accounts, open and close, pads, balance assertions, lots and prices apply
    across the files. An account opened twice is a duplicate-open finding on the open that comes second when the
    entries of all the files are walked by date and then line; a
    balance assertion in one file adds up the postings of all. The first file is the root: its booking_method
    and plugin lines serve all the files, and those of the others do nothing. A refused construct in
    any Beancount file makes the whole Beancount ledger refused. The hledger files are still one ledger of their own and
    the two merge as before; format() still takes one file. Before, each Beancount file was a ledger of its
    own. See spec/beancount/several-files.md. The harness reads the reference through a root that includes the
    files.
  • format() reads the original file once. A Beancount file used to be loaded three times and parsed
    once more, an hledger file parsed and then loaded again; a format is now two loads, the original
    and the result. On 10,000 transactions, against 0.1.3 from npm on one desktop (median of 7 runs,
    alternated): Beancount 287 ms to 179 ms, hledger 154 ms to 104 ms. The formatted text is the same.
  • hledger: a load copies less. The drafts of a transaction are built once, and a posting's amounts
    are moved, not copied, into what at_cost(), value() and holdings() keep; the lists of a
    load get their size up front. A native load of 10,000 transactions takes about 9% less time
    (45.6 ms to 41.6 ms); in the wasm the gain is within what the bench can tell apart (46.9 ms to
    45.6 ms for load and transactions()).
  • hledger: a number whose mantissa fits in 64 bits is held as a machine integer, a larger one as a big integer
    as before (the timings below were measured with a 128-bit integer; see the next entry), so the arithmetic on an ordinary amount needs no big integer and allocates nothing for
    it. Against the commit before, on 10,000 transactions: a native load takes 11% less time (39.2 ms to 34.7 ms, median of 7
    alternated rounds); in the wasm load and transactions() take 7% less (45.2 ms to 42.3 ms,
    median of 11 runs) and holdings() 12% less (5.41 ms to 4.75 ms); the wasm is 17 KB larger before
    compression. Every answer is the same: eight probes with numbers on both sides of the limit
    (in spec/hledger/probes/: decimal-across-64-bit, the four decimal-*-across-128-bit, decimal-inferred-prices-255,
    decimal-many-places and decimal-small-around-zero) are compared with hledger.
  • hledger: a number is 24 bytes in the wasm, not 48. A 128-bit integer is 16-aligned on wasm32 and doubled
    the size of every number a ledger keeps, so the wasm memory of a 10,000-transaction load grew by 15 MB
    (memory.buffer.byteLength 40.2 MB to 55.2 MB). The machine integer is 64 bits now and the big one is
    boxed: 42.9 MB on the same ledger, under the 50 MB target. Every answer is the same.
  • Beancount: a load of several files builds the flat posting list after freeing what reading and
    booking held, as it did before the files became one ledger. Built at the peak, the rows raised the wasm
    memory of a 10,000-transaction load by 3.2 MB (43.5 MB to 46.7 MB); it is back to 43.5 MB.
  • hledger: a posting's amount is read once. It was read a second time only to find where it ends,
    for format(); the first read says so unless a D directive could give the amount a commodity.
    Balancing a transaction borrows the commodity names it used to copy. Against the commit before,
    on 10,000 transactions: a native load takes 18% less time (36.7 ms to 30.1 ms, median of 9
    alternated rounds); in the wasm load and transactions() take 13% less (42.0 ms to 36.7 ms,
    median of 11 runs) and format() 12% less (103.5 ms to 91.4 ms). Every answer is the same.

Fixed

  • Beancount: holdings() of several files adds the postings in the reference's order, by date and then
    line with the file not in the key. It added them by date and then file, so a sum held to 28 significant digits
    that rounds at each step could end one digit off when files shared a day. See
    spec/beancount/several-files.md.

Release gate

From the release-gate workflow on commit 50041d8 (run 43723414894, 2026-11-15), the head of the
merged memory PR when it ran, CI on that PR's last commit 898b6df (run 43725983534), and the
owner's own runs. The only code change between the two commits adds a drop, with tests and docs.

  • Random hledger journals (5,000): 0 mismatches (2,212 that hledger accepts; the rest rejected by
    both, 45 skipped, all conversion-postings)
  • Random Beancount journals (5,000): 0 mismatches (3,709 that bean-check accepts)
  • Random price networks (5,000): 0 mismatches
  • Random Beancount journals with pairs priced both ways (5,000): 0 mismatches
  • Random sets of several ledgers (5,000): 0 mismatches (1,755 sets the reference accepts; 68
    skipped, all conversion-postings)
  • Corpus comparison: 13,723 pass, 0 fail, 52 skip
  • Desktop bench against 0.1.3 from npm (CI runner, 10,000 transactions): every operation within
    0.48–1.09× of 0.1.3 (the 0.48 is hledger format, 185.5 to 89.5 ms; the 1.09 is Beancount
    holdings, 7.69 to 8.38 ms); load+transactions 41.2 ms (hledger), 102.6 ms (Beancount); start
    14.7 ms
  • Stress test, 100,000 transactions: ok, no crash (peak wasm memory 637.2 MB hledger, 611.5 MB Beancount)
  • Similarity check score: max 0.088 (JPlag against rustledger 0.24.0; fail at 0.15), 0 fail,
    8 warn; copydetect max 0.251 (information only)
  • Real journals: pass (21 pass, 0 fail; two of the owner's hledger journals, each alone and as one set)
  • Device targets: not met (Beancount load+transactions on the owner's phone, Android 10 and Chrome
    157, on the build of 50041d8: worst of 3 is 542.2 ms (runs 436.5, 421.7, 542.2); 0.1.3 from npm
    on the same phone, alternated: 446.6, 440.8, 536.7 ms, also above 500 ms). Every other target met:
    hledger load+transactions worst 263.9 ms, start 34.3 ms, value 51.5 ms (Beancount, worst),
    holdings 39.1 ms (worst), memory 42.9 MB hledger and 43.5 MB Beancount (0.1.3 on the same phone:
    48.3 MB and 43.5 MB)