Skip to content
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

Add benchmarks and update Plutarch version #5

Merged
merged 12 commits into from
Jan 22, 2025
Merged

Add benchmarks and update Plutarch version #5

merged 12 commits into from
Jan 22, 2025

Conversation

colll78
Copy link
Collaborator

@colll78 colll78 commented Jan 9, 2025

I have introduced benchmarks and updated the Plutarch version. The benchmark results are extremely promising. The custom library functions blow the standard library ones out of the water:

Benchmarks
  Drops
    recursive: OK
      CPU  | 428202982
      MEM  | 1720902
      SIZE | 1059
    fast:      OK
      CPU  | 74222124
      MEM  | 197578
      SIZE | 1178
  Lengths
    recursive: OK
      CPU  | 406465594
      MEM  | 1585632
      SIZE | 1054
    fast:      OK
      CPU  | 77547272
      MEM  | 207642
      SIZE | 1204
  Is Unique
    pow2:      OK
      CPU  | 1742922097
      MEM  | 6293626
      SIZE | 1060
    bit trick: OK
      CPU  | 36945112
      MEM  | 91088
      SIZE | 977
  Find
    optional:  OK
      CPU  | 5876532
      MEM  | 23990
      SIZE | 445
    bool:      OK
      CPU  | 5425382
      MEM  | 21658
      SIZE | 427

Recursive is the std lib equivalent when it exists, fast is our optimized implementation. The results are astonishing, our implementations are often dozens of times more efficient even for trivial functions like length.

Copy link
Collaborator

@j-mueller j-mueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module layout makes sense. It just needs a bit of cleaning up (export lists, comments, generally more haddocks on top-level definitions)


## Target Performance

The target performance for our library is a reduction of 30% ex-units across the above benchmarks.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something missing in the report?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report (M1) was just providing benchmarks for Plinth / Aiken and establishing our target benchmarks (which we stated must be an improvement upon existing benchmarks). What we actually achieved was (in most cases) much better than the above target (often 80%+ reduction in ex-units).

{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}

module Plutarch.Core.FieldBinds where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing export list

{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE OverloadedRecordDot #-}
module Plutarch.Core.Time where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing export list

@@ -0,0 +1,134 @@
{-# LANGUAGE OverloadedRecordDot #-}

module Plutarch.Core.ValidationLogic where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing export list

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PartialTypeSignatures #-}

module Plutarch.Core.Value where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export list

import Plutarch.MerkleTree.Helpers (pcombine, pnibble, pnibbles,
psuffix)
import Plutarch.MerkleTree.Merkling (pmerkle_16, pnull_hash,
psparse_merkle_16)
import Plutarch.Prelude
import PlutusLedgerApi.V2 (BuiltinByteString)
import PlutusTx.Builtins.Internal (BuiltinByteString (BuiltinByteString))
--import PlutusLedgerApi.V2 (BuiltinByteString)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete comment


instance PUnsafeLiftDecl PMerklePatriciaForestry where
type PLifted PMerklePatriciaForestry = MerklePatriciaForestry
-- instance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

-- type AsHaskell PMerklePatriciaForestry = BuiltinByteString
-- type PlutusRepr PMerklePatriciaForestry = PLiftedClosed PMerklePatriciaForestry

instance {-# OVERLAPPING #-} PLiftable PMerklePatriciaForestry where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the overlappable pragma here?

{-# INLINEABLE fromPlutarch #-}
fromPlutarch = fromPlutarchUni

-- deriving via
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete comment

@j-mueller
Copy link
Collaborator

Also the build is failing because of some warnings

@@ -16,7 +16,7 @@ repository cardano-haskell-packages

index-state:
, hackage.haskell.org 2024-10-10T00:52:24Z
, cardano-haskell-packages 2024-10-24T10:49:32Z
, cardano-haskell-packages 2024-10-09T22:38:57Z
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we going backwards in time here?

@colll78 colll78 merged commit c3799ed into main Jan 22, 2025
2 checks passed
@colll78 colll78 deleted the polish branch January 22, 2025 20:28
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