Skip to content
Merged
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
39 changes: 9 additions & 30 deletions .github/workflows/benchmark-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
pull_request:
branches: [ master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
BENCHMARK_DISABLE_JEMALLOC: true

Expand Down Expand Up @@ -124,35 +120,18 @@ jobs:

- name: Compare PR and master
if: ${{ env.hasBenchmark == '1' }}
id: benchmark
run: |
cd JAMTests
echo "# 📊 Benchmark Results"
echo "Generated on: $(date)"
echo ""
echo "exitStatus=1" >> $GITHUB_ENV
echo "# 📊 Benchmark Results" >> $GITHUB_STEP_SUMMARY
echo "Generated on: $(date)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

# Check if master baseline exists for comparison
if [ -f ".benchmarkBaselines/BenchmarkTestVectors/master/results.json" ]; then
echo "## 🔄 Comparison with Master Branch"
echo ""
swift package benchmark baseline check master pull_request --format markdown
echo "exitStatus=0" >> $GITHUB_ENV
swift package benchmark baseline compare master pull_request --no-progress --format markdown >> $GITHUB_STEP_SUMMARY 2>&1 || true
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Threshold Check" >> $GITHUB_STEP_SUMMARY
swift package benchmark baseline check master pull_request --format markdown >> $GITHUB_STEP_SUMMARY 2>&1 || true
else
echo "## 🆕 First Benchmark Run"
echo ""
echo "⚠️ Master baseline not found. This appears to be the first benchmark run."
echo "The following results will become the baseline for future comparisons:"
echo ""

# Run benchmarks to generate results for first time
echo "### Benchmark Results:"
swift package benchmark --format markdown 2>&1 || true
echo "exitStatus=0" >> $GITHUB_ENV
echo "⚠️ Master baseline not found. Running benchmarks for this PR:" >> $GITHUB_STEP_SUMMARY
swift package benchmark --format markdown >> $GITHUB_STEP_SUMMARY 2>&1 || true
fi
continue-on-error: true

- name: Exit with correct status
if: ${{ env.hasBenchmark == '1' }}
run: |
exit ${{ env.exitStatus }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ Tools/openrpc.json
tmp

*.pvm

.benchmarkBaselines
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extension Ref where T == ProtocolConfig {
maxWorkItems: 16,
maxDepsInWorkReport: 8,
maxTicketsPerExtrinsic: 3,
maxLookupAnchorAge: 14400,
maxLookupAnchorAge: 24,
transferMemoSize: 128,
ticketEntriesPerValidator: 3,
maxAuthorizationsPoolItems: 8,
Expand Down
1 change: 1 addition & 0 deletions Codec/Sources/Codec/IntegerCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension Collection<UInt8> where SubSequence == Self {
IntegerCodec.decode { self.next() }
}

// NOTE: for data, use decodeUInt* methods in Data+Utils.swift for better performance
public mutating func decode<T: UnsignedInteger>(length: Int) -> T? {
guard length > 0, length <= count else { return nil }

Expand Down
Binary file removed JAMTests/fuzz/0.7.0/1756548916/00000081.bin
Binary file not shown.
748 changes: 0 additions & 748 deletions JAMTests/fuzz/0.7.0/1756548916/00000081.json

This file was deleted.

Binary file removed JAMTests/fuzz/0.7.0/1756548916/00000082.bin
Binary file not shown.
746 changes: 0 additions & 746 deletions JAMTests/fuzz/0.7.0/1756548916/00000082.json

This file was deleted.

Binary file removed JAMTests/fuzz/0.7.0/1757063641/00000179.bin
Binary file not shown.
205 changes: 0 additions & 205 deletions JAMTests/fuzz/0.7.0/1757063641/00000179.json

This file was deleted.

Binary file removed JAMTests/fuzz/0.7.0/1757063641/00000180.bin
Binary file not shown.
254 changes: 0 additions & 254 deletions JAMTests/fuzz/0.7.0/1757063641/00000180.json

This file was deleted.

2 changes: 1 addition & 1 deletion Node/Tests/NodeTests/chainfiles/spec-tiny.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"10000000000000000000000000000000000000000000000000000000000000" : "0x00"
},
"id" : "tiny",
"protocol_parameters" : "0x0a00000000000000010000000000000064000000000000000200200000000c000000809698000000000080f0fa020000000000ca9a3b00000000002d3101000000000800100008000300403800000300080006005000040080000500060000fa0000017cd20000093d0004000000000c00000204000000c0000080000000000c00000a000000"
"protocol_parameters" : "0x0a00000000000000010000000000000064000000000000000200200000000c000000809698000000000080f0fa020000000000ca9a3b00000000002d3101000000000800100008000300180000000300080006005000040080000500060000fa0000017cd20000093d0004000000000c00000204000000c0000080000000000c00000a000000"
}
7 changes: 5 additions & 2 deletions PolkaVM/Sources/PolkaVM/InstructionTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ public class InstructionTable {
guard data.count >= 1 else {
return nil
}

let opcode = data[data.startIndex]
// logger.trace("parsed opcode: \(opcode)")

guard let instType = table[Int(opcode)] else {
return nil
}

// logger.trace("initializing \(instType)")
return try? instType.init(data: data[relative: 1...])

let instructionData = data.subdata(in: (data.startIndex + 1) ..< data.endIndex)
return try? instType.init(data: instructionData)
}
}
23 changes: 18 additions & 5 deletions PolkaVM/Sources/PolkaVM/Instructions/Instructions+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ extension Instructions {
let lY = min(4, max(0, data.count - Int(lX) - minus))

let start = startIdx + 1
let vX: T = decodeImmediate((try? data.at(relative: start ..< (start + lX))) ?? Data())
let vY: U = decodeImmediate((try? data.at(relative: (start + lX) ..< (start + lX + lY))) ?? Data())
let vX: T = decodeImmediate(data.subdata(in: data.startIndex + start ..< data.startIndex + (start + lX)))
let vY: U = decodeImmediate(data.subdata(in: data.startIndex + (start + lX) ..< data.startIndex + (start + lX + lY)))
return (vX, vY)
}

Expand Down Expand Up @@ -69,14 +69,27 @@ extension Instructions {
return .exit(.panic(.invalidDynamicJump))
}

var targetAlignedData = jumpTable[relative: start ..< end]
var targetAlignedData = jumpTable.subdata(in: jumpTable.startIndex + start ..< jumpTable.startIndex + end)

#if DEBUG
logger.trace("djump target data (\(targetAlignedData.map(\.self)))")
#endif

guard let targetAligned: UInt32 = targetAlignedData.decode(length: entrySize) else {
return .exit(.panic(.invalidDynamicJump))
let targetAligned: UInt32
switch entrySize {
case 1:
targetAligned = UInt32(targetAlignedData.decodeUInt8())
case 2:
targetAligned = UInt32(targetAlignedData.decodeUInt16())
case 3:
targetAligned = targetAlignedData.decodeUInt24()
case 4:
targetAligned = targetAlignedData.decodeUInt32()
default:
guard let decoded: UInt32 = targetAlignedData.decode(length: entrySize) else {
return .exit(.panic(.invalidDynamicJump))
}
targetAligned = decoded
}

#if DEBUG
Expand Down
Loading