memory-profile
Skill6 starsChanged 25 days agoMITView on GitHub
Run memory profiling on physical devices and compare against baselines.
- Reads credentials
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- benchSkill
- figma-implementSkill
- ios-routerSkill
- pmSkill
- review-l10nSkill
- review-prSkill
- run-e2eSkill
- run-pr-e2eSkill
- start-taskSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 72
Use the device→model mapping from the table above.
- Very specific: line 98
Check if physical devices are connected (adb devices).
- Very specific: line 101
Run profiling on each device with the device's TEST_MODELS from the mapping (do not use a single global model)
- Distinctive: line 118
No checkpoint should be zero or absurdly large.
- Distinctive: line 119
Run twice; per-checkpoint deltas should be <10% (if not, something is unstable — investigate before committing).
- Distinctive: line 122
Do this on a device under its normal load profile (screen on, typical background apps) — not a freshly-rebooted, zero-background state — so …
- Very specific: line 146
Always kill stale Appium first: lsof -ti:4723 | xargs kill -9 2>/dev/null || true
- Distinctive: line 147
Always ensure the correct model is loaded on LM Studio before running remote-server tests
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Memory Profiling
You are running the memory profiling pipeline for PocketPal AI.
Input
Request: $ARGUMENTS
What This Pipeline Does
Profiles memory usage across 7 app lifecycle checkpoints (app_launch, models_screen, chat_screen, model_loaded, chat_active, post_chat_idle, model_unloaded), then compares results against stored baselines to detect regressions.
Infrastructure
E2E Spec
e2e/specs/memory-profile.spec.ts— the E2E test that drives the profiling- Uses
TEST_MODELSenv var to select the model (default: smollm2-135m) - Writes report to
<report-dir>/memory-profile.json
Scripts (in e2e/scripts/)
memory-profile.sh— orchestration script (build → run spec → compare)memory-compare.ts— compares two reports, flags regressions (exit 1 if >10% AND >200 MB)
Baselines (in e2e/baselines/memory/)
Named <device_id>-<model_id>.json. (Sibling e2e/baselines/benchmark/ holds the unrelated benchmark-matrix baselines.) Current baselines:
iphone-13-pro-qwen3-1.7b.json— iPhone 13 Pro (device ID:agh) — trackedpixel-9-qwen3-1.7b.json— Pixel 9 (device ID:pixel-9-real) — trackediphone-17-pro-sim-tts.json,pixel-emulator-tts.json— TTS baselines fortts-memory-profilexiaomi-22126rn91y-qwen3-0.6b.json— Xiaomi 22126RN91Y — not yet captured, see "Capturing a new baseline" below
Devices & model mapping
Different phones need different baseline models so the baseline is neither RAM-starved (Xiaomi with a 1.7B model OOMs) nor noise-floored (Pixel 9 with a 135M model is dominated by runtime jitter). Mapping:
| Device ID | Platform | RAM tier | Model for baseline |
agh (iPhone 13 Pro) | ios | 6 GB | qwen3-1.7b |
pixel-9-real | android | 16 GB | qwen3-1.7b |
xiaomi-22126rn91y-real | android | ~4 GB (low) | qwen3-0.6b |
Do not change the existing iPhone/Pixel mappings — they've been tracked against these models for a while; swapping models invalidates all historical baselines. Any new device gets its own row.
Override per-run with --model <id> if needed; available model IDs are in e2e/fixtures/models.ts.
Builds Required
- iOS real device:
yarn ios:build:ipa(outputsios/build/PocketPal.ipa) - Android:
yarn android:build:e2e(outputs the e2e-flavor APK; whate2e/scripts/memory-profile.shbuilds) - iOS simulator:
yarn ios:build:e2e(outputs .app)
These can be built in parallel. Use --skip-build if binaries already exist.
On the PR's CI APK
CI-APK rows run post-PR on the draft PR's bridge APK from e2e-tests.yml: TEST_MODELS=<model-id> tools/run-pr-e2e.sh <PR> --e2e --specs memory-profile -- --devices <device-id> (/run-pr-e2e), or tools/fetch-pr-apk.sh --e2e <PR> then run with --skip-build. If e2e-tests.yml has not run for the PR's head branch, dispatch it: tools/ghb workflow run e2e-tests.yml --repo a-ghorbani/pocketpal-ai --ref <head-branch>.
How to Run
Via the E2E runner (preferred)
Use the device→model mapping from the table above. One invocation per device:
cd <worktree>/e2e
TEST_MODELS=qwen3-1.7b yarn e2e:ios --skip-build --spec memory-profile --devices agh
TEST_MODELS=qwen3-1.7b yarn e2e:android --skip-build --spec memory-profile --devices pixel-9-real
TEST_MODELS=qwen3-0.6b yarn e2e:android --skip-build --spec memory-profile --devices xiaomi-22126rn91y-realReports land in timestamped dirs under e2e/reports/<timestamp>/<device-id>/memory-profile.json.
Via the orchestration script
cd <project-root>
e2e/scripts/memory-profile.sh --platform ios --skip-build --model qwen3-1.7b --baseline e2e/baselines/memory/iphone-13-pro-qwen3-1.7b.jsonComparing results
npx tsx e2e/scripts/memory-compare.ts <baseline.json> <current.json>Typical Workflow
- Check if physical devices are connected (
adb devices). Claim a phone through agistry before driving it and release it after (a pipeline stage uses theDEVICEits orchestrator claimed); iOS runs go throughios-router(this host has no iOS toolchain). - For each device you'll run against, look up the model from the mapping table and ensure LM Studio has it loaded (if relevant):
./tools/lmstudio.sh ensure "qwen/qwen3-1.7b"(etc.) (LMSTUDIO_API_KEYorREMOTE_SERVER_API_KEYfrom the environment when the server needs a key; defaults tolm-studio) - Build IPA and APK (in parallel if both platforms needed, skip if already built)
- Run profiling on each device with the device's
TEST_MODELSfrom the mapping (do not use a single global model) - Compare each result against the matching baseline in
e2e/baselines/memory/ - Present results side by side (baseline vs current, per checkpoint, deltas)
Capturing a new baseline (e.g. new device or new model)
Baselines are committed to the pocketpal-ai repo (e2e/baselines/memory/ is tracked). Adding one is a small task, not a one-off local capture:
/start-task "Capture memory-profile baseline for <device>"— gets a worktree and task branch.- In the worktree, run the memory-profile spec against the target device with that device's mapped model:
cd worktrees/TASK-xxx/e2e TEST_MODELS=<model-id> yarn e2e:android --skip-build \ --spec memory-profile --devices <device-id> - Sanity-check the produced
reports/<ts>/<device-id>/memory-profile.json:- Peak memory should be well under the device's RAM.
- No checkpoint should be zero or absurdly large.
- Run twice; per-checkpoint deltas should be <10% (if not, something is unstable — investigate before committing).
- Copy the clean report to
e2e/baselines/memory/<device-id>-<model-id>.json, commit, open a PR to pocketpal-ai.
Do this on a device under its normal load profile (screen on, typical background apps) — not a freshly-rebooted, zero-background state — so the baseline reflects what users will actually see.
Presenting Results
Show a table with both platforms:
| Checkpoint | iOS Baseline | iOS Current | iOS Delta | Android Baseline | Android Current | Android Delta |
Include peak memory summary and PASS/FAIL status from the comparison script.
LM Studio Model Manager
tools/lmstudio.sh manages models on the LM Studio server. Key commands:
status— show loaded modelslist— list all downloaded modelsensure <model-key>— load model if not already loaded (unloads others first)load <model-key>— force load (unloads all first)
Reads LMSTUDIO_API_KEY or REMOTE_SERVER_API_KEY from the environment (default lm-studio). The operator exports it; agents never read the e2e env file for it. If it is missing, ask the operator.
Notes
- Always kill stale Appium first:
lsof -ti:4723 | xargs kill -9 2>/dev/null || true - Always ensure the correct model is loaded on LM Studio before running remote-server tests
- iOS and Android runs are independent — run them in parallel or sequentially
yarn installandpod installmay be needed after merges that change native deps- The comparison script exits 0 (pass) or 1 (regression) — both thresholds must be exceeded to fail
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

