Skip to content

Speed up SubTx serialisation tests and update Cabal caching - #1401

Draft
carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/feature/haskell-ci-performance
Draft

carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/feature/haskell-ci-performance

Conversation

@carbolymer

@carbolymer carbolymer commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Context

Detailed Haddock and changelog explanation prepared locally at 4de7e7daf; awaiting push.

This halves the random codec sample count from 400 to 200. The original generators and the 0–99 size range remain, but the previous statistical coverage is not preserved.

Reducing the random sample count lowers the chance of detecting rare serialisation regressions, including bugs triggered by unusual combinations of transaction fields. Regressions that the larger sample would catch may pass CI. The fixed boundary inputs do not compensate for the reduced chance of finding bugs in other transactions.

Run each of the four independent SubTx codec properties for 50 trials. Map Hedgehog sizes 0–49 to floor(99 * size / 49), capped at 99, so the 50 sampled sizes span 0–99. These are not the original size distribution or the same original samples. The shared generators and package dependencies match the baseline; signing and other properties remain unchanged.

Add two deterministic guard-count cases and one deterministic Coin case that iterates ten donation amounts. The inputs target these exact encoding changes:

Inputs Why these values
23 and 24 guards The pinned ledger OSet encoder uses definite-length encoding through 23 entries and indefinite-length encoding from 24.
Donation 0 and 1 Zero omits the treasury donation field; one includes it.
Coin 23 and 24 The unsigned CBOR integer changes from an inline value to one payload byte.
Coin 255 and 256 The integer payload grows from one byte to two.
Coin 65535 and 65536 The integer payload grows from two bytes to four.
Coin 4294967295 and 4294967296 The integer payload grows from four bytes to eight.

Each input checks the actual guard count and donation value, then all four signed/unsigned CBOR and TextEnvelope roundtrips. These are roundtrip fixtures, with no independent golden-byte or ledger-validity assertion. They do not replace the 200 removed random trials.

Update the Cabal cache action to cabal-cache-0.0.1.1, which skips saving after an exact cache hit.

How to trust this PR

Local measurements with GHC 9.6.7:

Measurement Before After
SubTx, replay seed 1 103.015 s 45.050 s
SubTx, replay seed 2 97.412 s 55.243 s
Full API and RPC suites together 106.860 s 93.130 s

The SubTx rows compare the original four 100-trial properties with the revised four 50-trial properties plus the three deterministic unit tests. Each targeted before/after pair uses the same replay seed, one test thread, one RTS capability and CPU affinity 0–1. Compiler and external dependency derivations match the baseline. The full-suite before/after pair also uses an identical replay seed, with four test threads and four capabilities per suite and CPU affinity 0–3.

All 347 API tests and 171 RPC tests passed. Measurements exclude builds and setup; no GitHub workflow duration was measured.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added and existing tests are updated
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@carbolymer carbolymer self-assigned this Oct 28, 2026
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs Fixed
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs Fixed
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs Fixed
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs Fixed
@carbolymer carbolymer changed the title Mgalazyn/feature/haskell ci performance Speed up SubTx serialisation tests and update Cabal caching Oct 28, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/feature/haskell-ci-performance branch from faaebc8 to d86fd8f Compare October 29, 2026 15:21
prop_roundtrip_sub_tx_coin_boundaries :: Property
prop_roundtrip_sub_tx_coin_boundaries = H.propertyOnce $ do
let amounts :: [Integer]
amounts = [0, 1, 23, 24, 255, 256, 65535, 65536, 4294967295, 4294967296]
prop_roundtrip_sub_tx_coin_boundaries :: Property
prop_roundtrip_sub_tx_coin_boundaries = H.propertyOnce $ do
let amounts :: [Integer]
amounts = [0, 1, 23, 24, 255, 256, 65535, 65536, 4294967295, 4294967296]
prop_roundtrip_sub_tx_coin_boundaries :: Property
prop_roundtrip_sub_tx_coin_boundaries = H.propertyOnce $ do
let amounts :: [Integer]
amounts = [0, 1, 23, 24, 255, 256, 65535, 65536, 4294967295, 4294967296]
prop_roundtrip_sub_tx_coin_boundaries :: Property
prop_roundtrip_sub_tx_coin_boundaries = H.propertyOnce $ do
let amounts :: [Integer]
amounts = [0, 1, 23, 24, 255, 256, 65535, 65536, 4294967295, 4294967296]
@carbolymer
carbolymer force-pushed the mgalazyn/feature/haskell-ci-performance branch from d86fd8f to 4922c41 Compare October 29, 2026 15:36
Run each of the four codec properties for 50 independent trials across
the original 0-99 size range. Keep the shared generators unchanged and
add deterministic guard-count and Coin-width boundary cases.

Use cabal-cache 0.0.1.1 to avoid redundant saves after exact restores.
Document the reduced random sample count in the maintenance fragment.
@carbolymer
carbolymer force-pushed the mgalazyn/feature/haskell-ci-performance branch from 4922c41 to 4de7e7d Compare October 29, 2026 15:44

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants