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 SCCs to Profile PlutusTx Plugin Steps #6843

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/plinth-plugin-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "ƛ Plinth Plugin Benchmark"

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- 'release/*'

permissions:
deployments: write
contents: write

jobs:
run:
if: !always()
name: Run
runs-on: [self-hosted, plutus-benchmark]
steps:
- name: Checkout
uses: actions/checkout@main

- name: Run Benchmarks
run: nix develop --no-warn-dirty --accept-flake-config --command \
bash ./scripts/run-plinth-plugin-benchmarks.sh

# We need this otherwise the next step will fail with:
# `pre-commit` not found. Did you forget to activate your virtualenv?
# This is because github-action-benchmark will call git commit outside nix develop.
- name: Disable Git Hooks
run: git config core.hooksPath no-hooks

- name: Deploy Results
uses: benchmark-action/[email protected]
with:
name: Plutus Benchmarks
tool: 'customSmallerIsBetter'
output-file-path: output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
comment-on-alert: true
alert-comment-cc-users: '@IntersectMBO/plutus-core'
alert-threshold: '105%'
12 changes: 8 additions & 4 deletions plutus-tx-plugin/src/PlutusTx/Plugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -560,26 +560,30 @@ runCompiler moduleName opts expr = do
(opts ^. posInlineConstants)

-- GHC.Core -> Pir translation.
pirT <- original <$> (PIR.runDefT annMayInline $ compileExprWithDefs expr)
pirT <- {-# SCC "plinth-plugin-core-to-pir-step" #-}
original <$> (PIR.runDefT annMayInline $ compileExprWithDefs expr)
let pirP = PIR.Program noProvenance plcVersion pirT
when (opts ^. posDumpPir) . liftIO $
dumpFlat (void pirP) "initial PIR program" (moduleName ++ "_initial.pir-flat")

-- Pir -> (Simplified) Pir pass. We can then dump/store a more legible PIR program.
spirP <- flip runReaderT pirCtx $ PIR.compileToReadable pirP
spirP <- {-# SCC "plinth-plugin-pir-to-simp-step" #-}
flip runReaderT pirCtx $ PIR.compileToReadable pirP
when (opts ^. posDumpPir) . liftIO $
dumpFlat (void spirP) "simplified PIR program" (moduleName ++ "_simplified.pir-flat")

-- (Simplified) Pir -> Plc translation.
plcP <- flip runReaderT pirCtx $ PIR.compileReadableToPlc spirP
plcP <- {-# SCC "plinth-plugin-simp-to-plc-step" #-}
flip runReaderT pirCtx $ PIR.compileReadableToPlc spirP
when (opts ^. posDumpPlc) . liftIO $
dumpFlat (void plcP) "typed PLC program" (moduleName ++ ".tplc-flat")

-- We do this after dumping the programs so that if we fail typechecking we still get the dump.
when (opts ^. posDoTypecheck) . void $
liftExcept $ PLC.inferTypeOfProgram plcTcConfig (plcP $> annMayInline)

uplcP <- flip runReaderT plcOpts $ PLC.compileProgram plcP
uplcP <- {-# SCC "plinth-plugin-plc-to-uplc-step" #-}
flip runReaderT plcOpts $ PLC.compileProgram plcP
dbP <- liftExcept $ traverseOf UPLC.progTerm UPLC.deBruijnTerm uplcP
when (opts ^. posDumpUPlc) . liftIO $
dumpFlat
Expand Down
8 changes: 8 additions & 0 deletions scripts/run-plinth-plugin-benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -euo pipefail

cabal clean
cabal update
cabal build all --enable-profiling --enable-library-profiling