Skip to content
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
61 changes: 61 additions & 0 deletions .github/workflows/ios-harness-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: iOS Release Harness smoke

on:
workflow_dispatch:

permissions:
contents: read

jobs:
smoke:
runs-on: xcode-27
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
with:
path: app
submodules: recursive
persist-credentials: false

- name: Check out the shared mount and update workloads from PR 774
uses: actions/checkout@v7
with:
ref: 3c59941560a1a1077fe982df802f644b08205bf6
path: workloads
sparse-checkout: scripts/performance/scenarios
persist-credentials: false

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.4

- name: Build the Release example with the shared workloads
run: |
python3 app/scripts/performance/ios/harness/stage.py app workloads/scripts/performance/scenarios/render.tsx
cd app
bun install
cd apps/example
echo 'ARCHS = arm64' > "$RUNNER_TEMP/simulator.xcconfig"
export XCODE_XCCONFIG_FILE="$RUNNER_TEMP/simulator.xcconfig"
bun run nitro-ui ios --release --build-only > "$RUNNER_TEMP/build.log" 2>&1 || { tail -100 "$RUNNER_TEMP/build.log"; exit 1; }

- name: Run both Harness tests three times on iOS 27
run: |
device=$(xcrun simctl create "Nitro UI Harness" com.apple.CoreSimulator.SimDeviceType.iPhone-17 com.apple.CoreSimulator.SimRuntime.iOS-27-0)
trap 'xcrun simctl delete "$device"' EXIT
xcrun simctl bootstatus "$device" -b
app="app/apps/example/.nitro/build/Build/Products/Release-iphonesimulator/NitroUI Example.app"
test -f "$app/main.hbc"
id=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$app/Info.plist")
xcrun simctl install "$device" "$app"
python3 app/scripts/performance/ios/harness/run.py "$device" "$id" "$RUNNER_TEMP/harness"

- uses: actions/upload-artifact@v7
if: always()
with:
name: ios-release-harness-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/harness/
${{ runner.temp }}/build.log
if-no-files-found: warn
retention-days: 7
6 changes: 6 additions & 0 deletions scripts/performance/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ Both apps used Nitro UI commit `9c13ee891421`. The table shows the change at 32
The Intel job waited 36m46s and took 24m21s to run both experiments. The ARM job used an iPhone 17 simulator on iOS 27.0, waited 1h43m for a runner and took 11m48s to run. At 32 pairs the hosted intervals still allowed both zero change and a 5% slowdown. The local simulator used iOS 27.0 on an iPhone 18 Pro device model. Both local comparisons reached the five-point precision target by 16 pairs. [Intel run](https://github.com/margelo/nitro-ui/actions/runs/47147452527) · [ARM run](https://github.com/margelo/nitro-ui/actions/runs/47147360586)

A second completed Intel comparison ran identical builds for 64 pairs in 9m01s of measured launches. Wall time was −1.78% [−15.25%, +4.23%]. Main-thread CPU time was +1.29% [−7.47%, +7.47%]. Wall time ruled out a 5% slowdown in that run. CPU time still allowed one, and neither metric reached a five-point interval radius. One earlier attempt stopped after three complete pairs when CoreSimulator exceeded its 60-second launch timeout. The repeat allowed 180 seconds for the launch command. No failed samples were retried or pooled. [64-pair result](https://github.com/margelo/nitro-ui/actions/runs/47164590706) · [Incomplete attempt](https://github.com/margelo/nitro-ui/actions/runs/47157888129)

## Release Harness renderer smoke

The manual **iOS Release Harness smoke** workflow launches the full example app three times on the same iPhone 17 simulator. Each fresh process runs the two React workloads from [PR #774](https://github.com/margelo/nitro-ui/pull/774). The first mounts 256 rows and checks every native label. The second keeps 64 views mounted through 31 renders and checks their identities and final properties. PerfKit 0.2.1 measures elapsed time and CPU time on the Hermes thread. Each launch produces a JSON report with its assertions, timings and compiled framework ID.

The workflow checks out the workload at a pinned commit while the Android suite is in review. The staging script copies its TSX into a disposable checkout, updates the two pre-rename package imports, and selects it through the example Xcode target's entry. Three launches verify the integration. A regression estimate requires paired runs of two builds.
57 changes: 57 additions & 0 deletions scripts/performance/ios/harness/entry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'nitro-ui-runtime'
import { useEffect } from 'react'
import { it } from 'nitro-ui-harness'
import { Application, renderRoot, ViewController, Window } from 'nitro-ui-renderer'
import { ThreadBenchmark, type ThreadBenchmarkResult } from '@callstack/performance-analytics-react-nitro'
import { finishCollection, resetCollection } from '../../../../packages/nitro-ui-harness/src/collect'
import { execute, serializeError } from '../../../../packages/nitro-ui-harness/src/execute'
import { cleanup, HarnessRoot } from '../../../../packages/nitro-ui-harness/src/render'
import { prepareMount, prepareUpdate } from './render'

async function send(report: unknown) {
const body = JSON.stringify(report)
await fetch('http://127.0.0.1:19875/report', { method: 'POST', body: body })
}

async function run() {
const framework: unknown = Reflect.get(globalThis, '__nitroUIFramework')
if (__DEV__ || typeof framework !== 'object' || framework === null || !('id' in framework) || typeof framework.id !== 'string') {
throw new Error('Expected the compiled production Static Hermes framework')
}
const collected = resetCollection()
const windows: ThreadBenchmarkResult[] = []
for (const [name, prepare] of [['mount', prepareMount], ['update', prepareUpdate]] as const) {
it(name, async () => {
const scenario = await prepare()
const timer = new ThreadBenchmark(name)
await scenario.run()
const result = timer.end()
await scenario.verify()
windows.push(result)
})
}
finishCollection()
const tests: { name: string[], status: string, errors: unknown }[] = []
const errors = await execute(collected, {
testNamePattern: undefined, testTimeout: 60000,
async onTestStart() {},
async onTestResult(name, status, _, errors) {
tests.push({ name: name, status: status, errors: errors })
},
afterEachTest: cleanup, takeUncaughtErrors: () => [],
})
await send({ frameworkId: framework.id, tests: tests, errors: errors, windows: windows })
}

function SmokeRoot() {
useEffect(() => {
run().catch((error: unknown) => send({ error: serializeError(error) }))
}, [])
return <HarnessRoot />
}

Application.registerRoot((scene) => {
const controller = new ViewController()
renderRoot(<SmokeRoot />, controller)
return new Window(scene, controller)
})
83 changes: 83 additions & 0 deletions scripts/performance/ios/harness/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Launch an installed Release benchmark three times and save its Harness results."""

import argparse
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
from pathlib import Path
import subprocess
import time


class ReportHandler(BaseHTTPRequestHandler):
def do_POST(self):
if self.path != "/report":
self.send_error(404)
return
length = int(self.headers["Content-Length"])
if length < 1 or length > 65536:
self.send_error(400)
return
payload = self.rfile.read(length)
self.server.result = json.loads(payload)
self.send_response(200)
self.end_headers()


def capture(server, device, bundle, log):
command = ["xcrun", "simctl", "launch", "--terminate-running-process", "--console", device, bundle]
server.result = None
with log.open("wb") as stream:
process = subprocess.Popen(command, stdout=stream, stderr=subprocess.STDOUT)
try:
deadline = time.monotonic() + 150
while server.result is None and time.monotonic() < deadline and process.poll() is None:
server.handle_request()
finally:
subprocess.run(["xcrun", "simctl", "terminate", device, bundle], check=False, timeout=60)
process.wait(timeout=30)
if server.result is None:
raise RuntimeError(f"No report from {bundle}. See {log}.")
return server.result


def verify(report):
if report.get("error") or report["errors"]:
raise ValueError(f"Harness reported an error: {report}")
framework = report["frameworkId"]
if len(framework) != 64:
raise ValueError("Missing compiled Static Hermes framework identity")
tests = [(test["name"], test["status"], test["errors"]) for test in report["tests"]]
if tests != [(["mount"], "passed", []), (["update"], "passed", [])]:
raise ValueError(f"Expected both renderer workloads to pass: {tests}")
windows = report["windows"]
if [window["name"] for window in windows] != ["mount", "update"]:
raise ValueError("Missing or unexpected SDK timing windows")
if windows[0]["threadId"] != windows[1]["threadId"]:
raise ValueError("The workloads ran on different Hermes threads")
for window in windows:
if window["threadId"] <= 0 or window["elapsedMs"] <= 0 or window["threadCpuMs"] <= 0:
raise ValueError(f"Missing SDK thread timing: {window}")
if window["countersAvailable"] is not False:
raise ValueError(f"Unexpected simulator hardware counter availability: {window}")


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("device", help="UDID of one booted simulator")
parser.add_argument("bundle", help="Installed example bundle identifier")
parser.add_argument("output", type=Path, help="New directory for launch logs and raw measurements")
args = parser.parse_args()
args.output.mkdir(parents=True, exist_ok=False)
with HTTPServer(("127.0.0.1", 19875), ReportHandler) as server:
server.timeout = 1
for launch in range(1, 4):
log = args.output / f"launch-{launch}.log"
report = capture(server, args.device, args.bundle, log)
contents = json.dumps(report, indent=2, allow_nan=False)
(args.output / f"launch-{launch}.json").write_text(contents + "\n")
verify(report)
print(f"Launch {launch}: {report['windows']}", flush=True)


if __name__ == "__main__":
main()
32 changes: 32 additions & 0 deletions scripts/performance/ios/harness/stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Stage the shared renderer suite in an expendable example app checkout."""

import argparse
import hashlib
import json
from pathlib import Path
import shutil

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("checkout", type=Path)
parser.add_argument("workload", type=Path, help="The Android suite's scenarios/render.tsx")
args = parser.parse_args()
app = args.checkout / "apps/example"
destination = app / "src/performance"
destination.mkdir()
workload = args.workload.read_text()
# PR #774 predates the package rename. Stage its existing TSX bodies and assertions.
workload = workload.replace("'react-nitro-harness'", "'nitro-ui-harness'")
workload = workload.replace("'react-nitro-renderer'", "'nitro-ui-renderer'")
staged = destination / "render.tsx"
staged.write_text(workload)
entry = Path(__file__).with_name("entry.tsx")
shutil.copyfile(entry, destination / entry.name)
# The example Xcode target explicitly passes --entry src/index.tsx.
(app / "src/index.tsx").write_text("import './performance/entry'\n")
manifest = app / "package.json"
package = json.loads(manifest.read_text())
package["dependencies"]["@callstack/performance-analytics-react-nitro"] = "0.2.1"
contents = json.dumps(package, indent=2)
manifest.write_text(contents + "\n")
digest = hashlib.sha256(staged.read_bytes()).hexdigest()
print(f"Staged mount/update workload SHA-256 {digest}")
Loading