Skip to content

Comments

Costing for improved integer/bytestring conversions#7491

Open
kwxm wants to merge 5 commits intomasterfrom
kwxm/costing/improved-bytestring-conversions
Open

Costing for improved integer/bytestring conversions#7491
kwxm wants to merge 5 commits intomasterfrom
kwxm/costing/improved-bytestring-conversions

Conversation

@kwxm
Copy link
Contributor

@kwxm kwxm commented Dec 16, 2025

This updates the cost model to reflect the improved performance of integerToByteString and byteStringToInteger due to #7439: the execution times of both functions are now linear in the sizes of their inputs instead of quadratic: see the builtinCostModel JSON files.

For small inputs values (less than size 2 or 3, so about 20 bytes) the new costs are slightly higher than the old ones (possibly due to randomness in the benchmarking process), but for larger inputs the new versions are dramatically faster: see the attached PNGs (blue points are benchmark times for the old versions, green ones are for the new versions).

The costing functions in this PR are provisional and may be updated before the new cost model is deployed on the chain.

byteStringToInteger integerToByteString

@github-actions
Copy link
Contributor

Execution Budget Golden Diff

ffc6471 (master) vs 855bb45

output

plutus-benchmark/bitwise/test/9.6/Ed25519.golden.eval

Metric Old New Δ%
CPU 1_628_853_655_874 1_628_939_350_255 +0.01%

This comment will get updated when changes are made.

@zliu41
Copy link
Member

zliu41 commented Feb 13, 2026

/benchmark flat-decode

@github-actions
Copy link
Contributor

Click here to check the status of your benchmark.

@github-actions
Copy link
Contributor

Comparing benchmark results of 'flat-decode' on 'ffc6471d8' (base) and '855bb4561' (PR)

Results table
Script ffc6471 855bb45 Change
list/bool/100 2.068 μs 2.047 μs -1.0%
list/bool/200 3.206 μs 3.172 μs -1.1%
list/bool/300 4.333 μs 4.234 μs -2.3%
list/bool/400 5.460 μs 5.505 μs +0.8%
list/bool/500 6.598 μs 6.537 μs -0.9%
list/bool/600 7.519 μs 7.444 μs -1.0%
list/bool/700 8.462 μs 8.473 μs +0.1%
list/bool/800 9.863 μs 9.864 μs +0.0%
list/bool/900 11.01 μs 11.00 μs -0.1%
list/bool/1000 12.18 μs 12.28 μs +0.8%
list/bool/1100 13.53 μs 13.30 μs -1.7%
list/bool/1200 14.38 μs 14.34 μs -0.3%
list/bool/1300 15.84 μs 15.86 μs +0.1%
list/bool/1400 16.35 μs 16.43 μs +0.5%
list/bool/1500 17.74 μs 18.04 μs +1.7%
list/bool/1600 18.72 μs 19.07 μs +1.9%
list/bool/1700 19.76 μs 20.04 μs +1.4%
list/bool/1800 21.43 μs 21.53 μs +0.5%
list/bool/1900 22.71 μs 22.67 μs -0.2%
list/bool/2000 29.70 μs 29.60 μs -0.3%
list/integer/small/100 9.582 μs 9.218 μs -3.8%
list/integer/small/200 18.08 μs 17.61 μs -2.6%
list/integer/small/300 26.89 μs 25.71 μs -4.4%
list/integer/small/400 35.81 μs 34.44 μs -3.8%
list/integer/small/500 44.42 μs 42.25 μs -4.9%
list/integer/small/600 53.38 μs 51.19 μs -4.1%
list/integer/small/700 61.58 μs 59.00 μs -4.2%
list/integer/small/800 70.51 μs 66.54 μs -5.6%
list/integer/small/900 77.92 μs 74.18 μs -4.8%
list/integer/small/1000 88.28 μs 84.45 μs -4.3%
list/integer/small/1100 97.59 μs 92.81 μs -4.9%
list/integer/small/1200 106.0 μs 101.6 μs -4.2%
list/integer/small/1300 113.5 μs 109.3 μs -3.7%
list/integer/small/1400 122.8 μs 118.5 μs -3.5%
list/integer/small/1500 131.7 μs 127.5 μs -3.2%
list/integer/small/1600 139.4 μs 134.5 μs -3.5%
list/integer/small/1700 147.4 μs 142.6 μs -3.3%
list/integer/small/1800 159.3 μs 152.2 μs -4.5%
list/integer/small/1900 166.8 μs 159.7 μs -4.3%
list/integer/small/2000 183.0 μs 175.8 μs -3.9%
list/integer/big/100 219.3 μs 218.4 μs -0.4%
list/integer/big/200 452.1 μs 437.0 μs -3.3%
list/integer/big/300 674.4 μs 655.4 μs -2.8%
list/integer/big/400 903.3 μs 875.2 μs -3.1%
list/integer/big/500 1.139 ms 1.103 ms -3.2%
list/integer/big/600 1.381 ms 1.330 ms -3.7%
list/integer/big/700 1.617 ms 1.566 ms -3.2%
list/integer/big/800 1.852 ms 1.793 ms -3.2%
list/integer/big/900 2.108 ms 2.032 ms -3.6%
list/integer/big/1000 2.340 ms 2.199 ms -6.0%
list/integer/big/1100 2.571 ms 2.481 ms -3.5%
list/integer/big/1200 2.825 ms 2.706 ms -4.2%
list/integer/big/1300 3.037 ms 2.949 ms -2.9%
list/integer/big/1400 3.307 ms 3.191 ms -3.5%
list/integer/big/1500 3.505 ms 3.422 ms -2.4%
list/integer/big/1600 3.778 ms 3.630 ms -3.9%
list/integer/big/1700 4.003 ms 3.877 ms -3.1%
list/integer/big/1800 4.242 ms 4.065 ms -4.2%
list/integer/big/1900 4.736 ms 4.622 ms -2.4%
list/integer/big/2000 5.036 ms 4.850 ms -3.7%
list/bytestring/small/100 7.762 μs 8.074 μs +4.0%
list/bytestring/small/200 15.28 μs 14.78 μs -3.3%
list/bytestring/small/300 26.01 μs 25.23 μs -3.0%
list/bytestring/small/400 33.54 μs 32.70 μs -2.5%
list/bytestring/small/500 44.00 μs 44.68 μs +1.5%
list/bytestring/small/600 56.51 μs 55.95 μs -1.0%
list/bytestring/small/700 73.83 μs 75.99 μs +2.9%
list/bytestring/small/800 91.16 μs 84.87 μs -6.9%
list/bytestring/small/900 106.0 μs 112.5 μs +6.1%
list/bytestring/small/1000 123.2 μs 126.0 μs +2.3%
list/bytestring/small/1100 147.3 μs 147.4 μs +0.1%
list/bytestring/small/1200 170.5 μs 168.7 μs -1.1%
list/bytestring/small/1300 193.8 μs 192.3 μs -0.8%
list/bytestring/small/1400 222.2 μs 218.6 μs -1.6%
list/bytestring/small/1500 234.4 μs 233.2 μs -0.5%
list/bytestring/small/1600 267.0 μs 266.2 μs -0.3%
list/bytestring/small/1700 304.9 μs 309.3 μs +1.4%
list/bytestring/small/1800 345.1 μs 343.5 μs -0.5%
list/bytestring/small/1900 387.7 μs 390.0 μs +0.6%
list/bytestring/small/2000 438.1 μs 434.5 μs -0.8%
list/bytestring/big/100 6.153 μs 5.879 μs -4.5%
list/bytestring/big/200 11.12 μs 10.70 μs -3.8%
list/bytestring/big/300 16.49 μs 15.96 μs -3.2%
list/bytestring/big/400 21.39 μs 20.87 μs -2.4%
list/bytestring/big/500 26.96 μs 25.81 μs -4.3%
list/bytestring/big/600 32.35 μs 30.98 μs -4.2%
list/bytestring/big/700 37.49 μs 35.86 μs -4.3%
list/bytestring/big/800 43.20 μs 41.82 μs -3.2%
list/bytestring/big/900 47.54 μs 45.79 μs -3.7%
list/bytestring/big/1000 53.02 μs 51.12 μs -3.6%
list/bytestring/big/1100 60.66 μs 58.57 μs -3.4%
list/bytestring/big/1200 68.40 μs 65.46 μs -4.3%
list/bytestring/big/1300 78.04 μs 74.10 μs -5.0%
list/bytestring/big/1400 88.47 μs 84.27 μs -4.7%
list/bytestring/big/1500 98.71 μs 95.67 μs -3.1%
list/bytestring/big/1600 111.4 μs 107.3 μs -3.7%
list/bytestring/big/1700 137.9 μs 136.2 μs -1.2%
list/bytestring/big/1800 138.3 μs 144.3 μs +4.3%
list/bytestring/big/1900 172.5 μs 170.7 μs -1.0%
list/bytestring/big/2000 196.6 μs 193.2 μs -1.7%
array/bool/100 2.839 μs 2.796 μs -1.5%
array/bool/200 4.518 μs 4.461 μs -1.3%
array/bool/300 6.378 μs 6.350 μs -0.4%
array/bool/400 7.819 μs 7.784 μs -0.4%
array/bool/500 9.499 μs 9.392 μs -1.1%
array/bool/600 11.42 μs 11.42 μs 0.0%
array/bool/700 12.96 μs 12.93 μs -0.2%
array/bool/800 14.49 μs 14.43 μs -0.4%
array/bool/900 16.07 μs 16.06 μs -0.1%
array/bool/1000 17.61 μs 17.58 μs -0.2%
array/bool/1100 20.00 μs 20.11 μs +0.5%
array/bool/1200 21.60 μs 21.67 μs +0.3%
array/bool/1300 22.89 μs 23.05 μs +0.7%
array/bool/1400 24.74 μs 24.77 μs +0.1%
array/bool/1500 26.13 μs 26.18 μs +0.2%
array/bool/1600 27.98 μs 28.09 μs +0.4%
array/bool/1700 29.29 μs 29.25 μs -0.1%
array/bool/1800 30.86 μs 30.82 μs -0.1%
array/bool/1900 32.43 μs 32.62 μs +0.6%
array/bool/2000 40.98 μs 40.83 μs -0.4%
array/integer/small/100 10.37 μs 9.962 μs -3.9%
array/integer/small/200 19.24 μs 18.61 μs -3.3%
array/integer/small/300 29.06 μs 27.85 μs -4.2%
array/integer/small/400 37.70 μs 36.07 μs -4.3%
array/integer/small/500 46.31 μs 45.18 μs -2.4%
array/integer/small/600 55.42 μs 53.55 μs -3.4%
array/integer/small/700 65.67 μs 62.95 μs -4.1%
array/integer/small/800 75.45 μs 71.04 μs -5.8%
array/integer/small/900 84.52 μs 81.76 μs -3.3%
array/integer/small/1000 92.69 μs 89.42 μs -3.5%
array/integer/small/1100 103.5 μs 100.1 μs -3.3%
array/integer/small/1200 111.2 μs 107.8 μs -3.1%
array/integer/small/1300 121.2 μs 116.7 μs -3.7%
array/integer/small/1400 131.1 μs 126.2 μs -3.7%
array/integer/small/1500 139.8 μs 135.6 μs -3.0%
array/integer/small/1600 148.9 μs 144.3 μs -3.1%
array/integer/small/1700 157.9 μs 152.5 μs -3.4%
array/integer/small/1800 167.4 μs 160.6 μs -4.1%
array/integer/small/1900 175.9 μs 169.7 μs -3.5%
array/integer/small/2000 195.0 μs 192.2 μs -1.4%
array/integer/big/100 226.7 μs 219.1 μs -3.4%
array/integer/big/200 456.0 μs 439.7 μs -3.6%
array/integer/big/300 676.9 μs 659.1 μs -2.6%
array/integer/big/400 914.6 μs 877.8 μs -4.0%
array/integer/big/500 1.160 ms 1.104 ms -4.8%
array/integer/big/600 1.381 ms 1.335 ms -3.3%
array/integer/big/700 1.612 ms 1.562 ms -3.1%
array/integer/big/800 1.841 ms 1.785 ms -3.0%
array/integer/big/900 2.095 ms 2.042 ms -2.5%
array/integer/big/1000 2.334 ms 2.258 ms -3.3%
array/integer/big/1100 2.569 ms 2.491 ms -3.0%
array/integer/big/1200 2.802 ms 2.705 ms -3.5%
array/integer/big/1300 3.051 ms 2.926 ms -4.1%
array/integer/big/1400 3.278 ms 3.159 ms -3.6%
array/integer/big/1500 3.496 ms 3.390 ms -3.0%
array/integer/big/1600 3.744 ms 3.618 ms -3.4%
array/integer/big/1700 3.977 ms 3.937 ms -1.0%
array/integer/big/1800 4.205 ms 4.047 ms -3.8%
array/integer/big/1900 4.709 ms 4.629 ms -1.7%
array/integer/big/2000 4.958 ms 4.781 ms -3.6%
array/bytestring/small/100 9.172 μs 8.445 μs -7.9%
array/bytestring/small/200 17.96 μs 17.82 μs -0.8%
array/bytestring/small/300 27.02 μs 27.54 μs +1.9%
array/bytestring/small/400 36.10 μs 35.42 μs -1.9%
array/bytestring/small/500 51.11 μs 50.16 μs -1.9%
array/bytestring/small/600 60.70 μs 61.40 μs +1.2%
array/bytestring/small/700 77.47 μs 77.69 μs +0.3%
array/bytestring/small/800 94.24 μs 93.83 μs -0.4%
array/bytestring/small/900 113.1 μs 111.3 μs -1.6%
array/bytestring/small/1000 129.9 μs 128.7 μs -0.9%
array/bytestring/small/1100 156.5 μs 155.7 μs -0.5%
array/bytestring/small/1200 178.9 μs 177.0 μs -1.1%
array/bytestring/small/1300 200.4 μs 200.8 μs +0.2%
array/bytestring/small/1400 229.7 μs 229.7 μs 0.0%
array/bytestring/small/1500 253.6 μs 240.4 μs -5.2%
array/bytestring/small/1600 279.0 μs 273.7 μs -1.9%
array/bytestring/small/1700 317.8 μs 312.6 μs -1.6%
array/bytestring/small/1800 363.1 μs 351.7 μs -3.1%
array/bytestring/small/1900 401.7 μs 397.9 μs -0.9%
array/bytestring/small/2000 449.7 μs 443.4 μs -1.4%
array/bytestring/big/100 7.575 μs 6.650 μs -12.2%
array/bytestring/big/200 14.45 μs 12.37 μs -14.4%
array/bytestring/big/300 18.41 μs 17.63 μs -4.2%
array/bytestring/big/400 24.50 μs 23.63 μs -3.6%
array/bytestring/big/500 29.80 μs 28.99 μs -2.7%
array/bytestring/big/600 36.49 μs 35.03 μs -4.0%
array/bytestring/big/700 42.05 μs 40.37 μs -4.0%
array/bytestring/big/800 47.23 μs 45.65 μs -3.3%
array/bytestring/big/900 53.31 μs 51.13 μs -4.1%
array/bytestring/big/1000 59.73 μs 57.18 μs -4.3%
array/bytestring/big/1100 67.49 μs 64.57 μs -4.3%
array/bytestring/big/1200 77.98 μs 74.77 μs -4.1%
array/bytestring/big/1300 90.63 μs 92.43 μs +2.0%
array/bytestring/big/1400 97.50 μs 93.53 μs -4.1%
array/bytestring/big/1500 114.6 μs 104.4 μs -8.9%
array/bytestring/big/1600 120.6 μs 116.9 μs -3.1%
array/bytestring/big/1700 147.9 μs 143.2 μs -3.2%
array/bytestring/big/1800 161.3 μs 157.2 μs -2.5%
array/bytestring/big/1900 181.0 μs 179.6 μs -0.8%
array/bytestring/big/2000 197.5 μs 204.5 μs +3.5%
ffc6471 855bb45 Change
TOTAL 113.4 ms 109.9 ms -3.1%

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