Performance
A PAM Desktop application is two processes: a Rust host and a PHP worker. Neither does anything while the interface is idle, and most expensive work (layout, animation, scrolling, decoding, I/O) happens in the host on dedicated threads. The defaults are lean; this page shows the measured costs and the habits that keep your own code from undoing them.
Measured costs
Section titled “Measured costs”A point-of-sale application written with PAM Desktop was measured against its Electron 37 counterpart on Linux, both with the same 2,500-product catalog, in the same container (Ubuntu 24.04, Xvfb at 1200×800, 4 CPUs, software rendering, no network). Medians:
| PAM Desktop | Electron | |
|---|---|---|
| Cold start, login screen complete | 138 ms | 1,563 ms |
| Route change (median of 17 screens) | 41 ms | 322 ms |
| Key press to visible change, median / p95 | 12.8 / 20.5 ms | 17.6 / 122 ms |
| Memory idle (all processes) | 75 MB | 322 MB |
| Memory after scrolling 2,500 products | 143 MB | 657 MB |
| CPU idle, visible / minimized (% of one core) | 0.2 / 0.0 | 1.9 / 1.0 |
Package: directory / .tar.gz |
120 / 42 MB | 468 / 144 MB |
Scrolling a long list is where Electron still leads in software rendering: about 55 updates per second against 59, because rows joining the list are laid out on the UI thread. With a GPU both are hardware composited. These numbers come from one application on Linux; measure your own application on the systems you support.
What the framework does by default
Section titled “What the framework does by default”- Nothing runs while idle. PHP sleeps in a blocking read, the frame clock runs only while something animates, all deadlines share one wake-up timer, and pool threads exit after 30 seconds without work.
- Compiled PHP is cached between launches with OPcache’s file cache in the cache directory, so from the second launch neither your code nor the framework is compiled again.
- Templates are precompiled into bundles for the mode the installed application runs in.
- Images are decoded at the size they are shown, shared between elements, and released in a bounded LRU (48 images, 96 MiB).
- Hidden media pauses at once and releases its decoder after 5 seconds.
- Lists mount only rows near the viewport.
- No OpenGL probe without a GPU. On a virtual machine or a headless session the GTK host skips loading the OpenGL stack, saving about 60 MB.
- Freed memory goes back to the system half a second after the windows stop painting.
Rules for your code
Section titled “Rules for your code”Render only what is visible
Section titled “Render only what is visible”Use a virtualized list for anything that can exceed a screenful. A ScrollView around a Column of a thousand rows builds, lays out and keeps all of them.
Size images
Section titled “Size images”Give every Image a width and height, and request thumbnails from your server instead of full-size originals. The decode is bounded by the box, but the download is the whole file.
Stop work nobody sees
Section titled “Stop work nobody sees”- Start timers with
$this->timers(): they stop on unmount and pause in the background by default. - Stop polling, sockets and watches in
paused()and resume inresumed(), or listen toApp::onStateChange(). - Call
DeviceStatus::unwatch()and close WebSockets inunmount(). - Remove endless animations once their content has loaded.
- Check
DeviceStatusand slow down optional work whenlowPowerModeis on.
public function mount(): void{ $this->timers()->every(30_000, fn () => $this->refresh()); // suspended while minimized}
public function paused(): void{ $this->socket?->close();}
public function resumed(): void{ $this->connect();}Keep handlers short
Section titled “Keep handlers short”A handler blocks the next frame of content until it returns, though never an animation or a scroll. Use the asynchronous modules for disk, network and SQLite instead of blocking PHP functions (file_get_contents() on a URL, sleep(), a synchronous PDO query on a large table).
Let the host do the motion
Section titled “Let the host do the motion”Use transitions, animation programs, gesture drags, media clock bindings and :hover styles. They run in the host without waking PHP. Never animate with a timer.
Paginate data
Section titled “Paginate data”SQLite returns at most 1,000 rows per query; load pages with LIMIT and OFFSET as the user scrolls.
Measuring
Section titled “Measuring”PAM_DESKTOP_PROFILE=1 pam desktop devPAM_DESKTOP_PROFILE=1 prints, per interaction, the time of the PHP handler and render, the host layout, the native view work and the painted frame. On Linux, read resident memory and CPU of the two processes with ps or top; the PHP worker is the process running pam-desktop-worker. Measure release bundles, not dev: development adds the file watcher and the error overlay.
Bundle size
Section titled “Bundle size”The PHP runtime is the largest part of a bundle. pam desktop build ships only the shared PHP extensions your code refers to; intl alone brings about 29 MB of ICU data and gd its image codecs. List an extension in extensions only when you really load it dynamically, and use exclude for development-only files. See Distribution.