-
Notifications
You must be signed in to change notification settings - Fork 485
Refactor: make budget metrics and compiled code size metrics usable independently of each other; #7172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
5c769f5
to
d5fe363
Compare
@@ -1,6 +1,6 @@ | |||
CPU: 218_533 | |||
Memory: 1_032 | |||
Term Size: 10 | |||
Flat Size: 37 | |||
Flat Size: 28 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have verified: Flat-serialised representation of this program takes 28 bytes:
58 1a 01 01 00 32 93 57 46 00 38 01 60 00 4b d6 08 14 12 0d 08 85 43 21 d1 08 94 51
…ndependently of each other;
d5fe363
to
9d9fcbd
Compare
uplc <- toUPlc compiledCode | ||
let | ||
termSize = UPLC.programSize uplc | ||
flatSize = UPLC.serialisedSize $ UPLC.UnrestrictedProgram uplc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here type of uplc
is UPLC.Program TPLC.Name uni fun ()
which will naturally have a different size of flat encoding
countFlatBytes :: CompiledCode ann -> Integer | ||
countFlatBytes = | ||
fromIntegral . BS.length . \case | ||
SerializedCode plcBytes _pir _ -> plcBytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plcBytes
is flat encoding of UPLC.Program UPLC.NamedDeBruijn uni fun SrcSpans
import UntypedPlutusCore qualified as UPLC | ||
import UntypedPlutusCore.Evaluation.Machine.Cek as Cek | ||
|
||
type Term = UPLC.Term PLC.NamedDeBruijn DefaultUni DefaultFun () | ||
type Program = UPLC.Program PLC.NamedDeBruijn DefaultUni DefaultFun () | ||
|
||
-- | The size of a 'CompiledCodeIn' as measured in Flat bytes. | ||
countFlatBytes :: CompiledCode ann -> Integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can go do PlutusTx.Code
as well
Closes https://github.com/IntersectMBO/plutus-private/issues/1657
sizePlc
->countAstNodes
countFlatBytes
.Reworking the way the
CompiledCode
's Flat size is measured led to smaller sizes in many golden files.I believe that current implementation is as close as possible to the
PlutusLedgerApi.Common.serialiseCompiledCode
.