LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
LordBench, first part (0.8.6 in development): the sandboxed lord-bench helper (CPU, memory, GPU offscreen, storage and sustained workloads, fixed-size records checked by lord-server), thermal/throttle/battery guards and recorded conditions (bench/lbcond.c), lord.sysinfo.bench and System Information's Performance tab with verdicts against a reference VM; Flatpak/Flathub design review (docs/FLATPAK.md, no code)
Federico Pereira4fbed94cefa1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 47fd902..da2121d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,48 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),releases (`v0.8.4.1-beta`) in its app update check and its release list. `SHA256SUMS` (11 files) is signed with therelease key. The site's downloads (`lordos.media`) now point to 0.8.5.+### Added++- **LordBench, first part (in development for 0.8.6; `docs/BENCHMARK.md`, "Built so far"):** System Information has a+ **Performance** tab with a Quick test (about half a minute) and a Full test (adds storage and three minutes of+ sustained load). The work runs in **`lord-bench`**, a new sandboxed helper launched by lord-server like `lord-doc`+ and `lord-media` (its own folder only, no arguments, `sandbox_apply_helper` before any work, scope+ `lordos-bench.scope`, 2 GB cap), which gets only the GPU's render node and an unnamed scratch file opened by+ lord-server and answers only with fixed-size records lord-server checks.+ - **Workloads**, each the median of three runs with its spread, on one core and on all:+ - SHA-256 and a 256×256 matrix product;+ - the package engine's xz decoder on a fixed 2 MB text generated at build time;+ - QuickJS running a fixed script;+ - memory copy and triad bandwidth and a 64 MB pointer-chase latency;+ - OpenGL ES 2 offscreen at 1920×1080 on the render node: the 3D scene, fill rate, texture upload and 8 layers;+ - (Full only) sequential write and read and random 4 KiB reads on up to 1 GB;+ - (Full only) a sustained all-core load sampled every 10 s with the temperature.+ - **Guards**, read by lord-server:+ - refused on battery below 30 %;+ - waits for a quiet CPU, at most 30 s; otherwise the run is marked busy;+ - stops within 2 °C of the passive trip point (10 °C of the critical one without one);+ - the peak tests also stop when the x86 throttle counters grow or the Raspberry Pi firmware reports throttling;+ - in the sustained test, throttling is recorded with its time and temperature instead.+ - **Results:** shown as "×N" of each reference machine per category, never one score, with three verdicts:+ - performance;+ - compatibility, from the Compatibility tab;+ - stability: stops, failed measurements, throttling, under-voltage, a sustained drop and a busy start.++ Each result also shows the change against the previous run and the conditions that differ, every recorded+ condition, the boot time per LordOS version and **Save to Documents**. Nothing is sent anywhere.+ - **Recorded conditions:** temperatures and trip points, power, governor, platform profile, GPU kind, disk kind,+ composition and display modes. No names or identities.+ - **Reference:** the only reference machine so far is VM 116 (8 vCPU Xeon Silver 4108, llvmpipe). A Full run there+ measured 977 MB/s SHA-256 and 19.7 GFLOP/s on all cores, and 20.2 GB/s memory copy. The Pi 5 and x86 PC+ references come when they are measured.+ - **Tests:** `tests/lordbench_test.c` (260 checks: records, workloads, fake sysfs trees of an x86 laptop and a Pi 5,+ boot history) and `tests/sysinfo_perf_test.mjs` (30 checks).+ - **Not built yet:** the desktop-impact mode, the compositor and video workloads, and `lordos-sysreport bench`.+- **Flatpak and Flathub design review** (`docs/FLATPAK.md`, no code): a launcher-owned scope per Flatpak app so the+ firewall and restrictions see it as itself, `flatpak run` arguments built in C, per-user installs through a closed+ set of commands in their own network scope with Flathub's key pinned, and the exceptions to `AGENTS.md` the+ maintainer has to approve before any code.+### Fixed- **Raspberry Pi image on an x86-64 host with an aarch64 `server/build`:** `tools/iso/mkdeb.sh` checks thediff --git a/apps/sysinfo/index.jsx b/apps/sysinfo/index.jsxindex 4597cf9..bbe6da3 100644--- a/apps/sysinfo/index.jsx+++ b/apps/sysinfo/index.jsx@@ -2,7 +2,7 @@// makes of it. Overview, Hardware (a source list and a detail pane) and Compatibility. The report// comes from lord.sysinfo.report() (server/src/sysreport, the same collector as lordos-sysreport and// lordos-fetch), read once on open and again with Refresh; model.js works out the GPU layers and the-// Compatibility panel. Nothing here holds serial numbers, addresses or names: the report has none.+// Compatibility panel; Performance (0.8.6, performance.jsx) runs LordBench. Nothing here holds serial numbers, addresses or names: the report has none.import {View, Text, ScrollView, Button, useTheme, useLocale, LordOSLogo, systemReport, systemInfo, lordosVersion, formatBytes, formatNumber,Toolbar, ToolbarSpacer, ToolbarButton, Segmented, SidebarItem, GroupBox, FormRow, EmptyState, Hairline, spacing, typeScale,@@ -10,6 +10,7 @@ import {} from '@lordos/sdk';import { useMemo, useState } from 'react';import { evaluate as evaluateChecks, evaluateProbe, evaluateBench, PENDING as PENDING_CHECKS, PROBE_CHECKS } from './checks.js';+import Performance from './performance.jsx';import { cardLayers, sessionLayers, compatibility, hardwareSections, throttleFlags, machineName, compositionReason, reportFileName, reportJson, parseMemoryLines } from './model.js';// The app's icon: a chip on the brand gradient.@@ -533,11 +534,11 @@ export default function SystemInformation() {<Toolbar><ToolbarSpacer /><Segmented appearance="neutral" value={tab} onChange={setTab}- options={[['overview', tr('sysinfo.tab.overview')], ['hardware', tr('sysinfo.tab.hardware')], ['compat', tr('sysinfo.tab.compat')], ['checks', tr('sysinfo.tab.checks')], ['report', tr('sysinfo.tab.report')]]} />+ options={[['overview', tr('sysinfo.tab.overview')], ['hardware', tr('sysinfo.tab.hardware')], ['compat', tr('sysinfo.tab.compat')], ['checks', tr('sysinfo.tab.checks')], ['perf', tr('sysinfo.tab.perf')], ['report', tr('sysinfo.tab.report')]]} /><ToolbarSpacer /><ToolbarButton icon="↻" title={tr('sysinfo.refresh')} onClick={() => setN(n + 1)} /></Toolbar>- {tab === 'overview' ? <Overview r={r} info={info} /> : tab === 'hardware' ? <Hardware r={r} /> : tab === 'compat' ? <Compatibility r={r} /> : tab === 'checks' ? <Checks r={r} /> : <Report r={r} />}+ {tab === 'overview' ? <Overview r={r} info={info} /> : tab === 'hardware' ? <Hardware r={r} /> : tab === 'compat' ? <Compatibility r={r} /> : tab === 'checks' ? <Checks r={r} /> : tab === 'perf' ? <Performance r={r} /> : <Report r={r} />}</View>);}diff --git a/apps/sysinfo/perf.js b/apps/sysinfo/perf.jsnew file mode 100644index 0000000..245936b--- /dev/null+++ b/apps/sysinfo/perf.js@@ -0,0 +1,124 @@+// LordBench's model (0.8.6, docs/BENCHMARK.md "0.8.6 — LordBench"): the measurements by category, how a+// result compares with the reference machines (×N of each, never one score), the three verdicts+// (performance, compatibility, stability), and what changed against the previous result. Pure+// functions over the result JSON lord.sysinfo.bench writes (server/src/bench/lbrun.c); tested in+// server/tests/sysinfo_perf_test.mjs.+import { REFERENCES } from './references.js';++export const CATEGORIES = [+ { id: 'cpu', ids: ['cpu.sha256.1', 'cpu.sha256.n', 'cpu.matmul.1', 'cpu.matmul.n', 'cpu.xz.1', 'cpu.xz.n', 'cpu.js.1', 'cpu.js.n'] },+ { id: 'memory', ids: ['mem.copy', 'mem.triad', 'mem.latency'] },+ { id: 'gpu', ids: ['gpu.scene', 'gpu.fill', 'gpu.upload', 'gpu.layers'] },+ { id: 'storage', ids: ['disk.seqwrite', 'disk.seqread', 'disk.random4k'] },+ { id: 'sustained', ids: ['sustained.start', 'sustained.end'] },+];++export { REFERENCES };++// ×N of the reference for one measurement (latency: the reference's time over ours); null if either+// is missing+export function ratio(res, ref, id) {+ const a = res && res.results && res.results[id], b = ref && ref.results && ref.results[id];+ if (!a || !b || !(a.value > 0) || !(b.value > 0)) return null;+ return a.lowerBetter ? b.value / a.value : a.value / b.value;+}++// per category, the geometric mean of the ratios it has; null when none+export function categoryRatios(res, ref) {+ const out = {};+ for (const c of CATEGORIES) {+ const rs = c.ids.map((id) => ratio(res, ref, id)).filter((x) => x != null);+ out[c.id] = rs.length ? Math.exp(rs.reduce((s, x) => s + Math.log(x), 0) / rs.length) : null;+ }+ return out;+}++// the references a result can be compared with: the same LordBench version+export function comparableReferences(res) {+ return REFERENCES.filter((r) => res && r.lordbench === res.lordbench);+}++// ---- verdicts ----++const throttled = (c) => c && c.rpiThrottled != null && (c.rpiThrottled & 0x7) !== 0;++export function stability(res) {+ if (!res) return { state: 'unknown', notes: [] };+ const notes = [];+ let state = 'pass';+ const warn = (id, vars = {}) => { notes.push({ id, vars }); if (state === 'pass') state = 'warn'; };+ if (res.status === 'failed') { state = 'fail'; notes.push({ id: 'failed', vars: { why: res.stopReason || '' } }); }+ else if (res.status === 'stopped') warn(res.stopReason === 'thermal' ? 'stoppedThermal' : res.stopReason === 'throttled' ? 'stoppedThrottled' : 'stopped');+ const failed = Object.entries(res.skipped || {}).filter(([, why]) => why === 'failed').map(([id]) => id);+ if (failed.length) warn('measureFailed', { count: failed.length });+ const b = res.before || {}, a = res.after || {};+ if (b.throttleEvents != null && a.throttleEvents != null && a.throttleEvents > b.throttleEvents) warn('throttleSeen', { count: a.throttleEvents - b.throttleEvents });+ if (throttled(a)) warn('piThrottled');+ if (a.rpiThrottled != null && (a.rpiThrottled & 1)) warn('underVoltage');+ const s = res.results || {};+ if (s['sustained.start'] && s['sustained.end']) {+ const drop = 1 - s['sustained.end'].value / s['sustained.start'].value;+ if (drop > 0.1) warn('sustainedDrop', { pct: Math.round(drop * 100) });+ }+ if (res.sustained && res.sustained.throttleAtS != null) warn('sustainedThrottle', { s: res.sustained.throttleAtS, temp: res.sustained.throttleTempC });+ if (res.quiet && !res.quiet.quiet) warn('notQuiet', { pct: Math.round(res.quiet.busyPct) });+ return { state, notes };+}++// the Compatibility panel's rows (model.js compatibility()), counted by state+export function compatibilityVerdict(rows) {+ const count = { works: 0, limits: 0, no: 0, absent: 0, unchecked: 0 };+ for (const r of rows || []) if (count[r.state] != null) count[r.state]++;+ const state = count.no ? 'fail' : count.limits ? 'warn' : rows && rows.length ? 'pass' : 'unknown';+ return { state, count };+}++// ---- comparing two results ----++// conditions that change the numbers; listed next to a comparison when they differ+export function conditionDiffs(a, b) {+ if (!a || !b) return [];+ const pick = (r) => ({+ power: r.before && r.before.power, governor: r.before && r.before.governor, profile: r.before && r.before.platformProfile,+ gpuKind: r.gpuKind, storage: r.storage && r.storage.kind, threads: r.threads, live: r.live, lordos: r.lordos, kernel: r.kernel,+ composition: r.session && r.session.composition,+ });+ const x = pick(a), y = pick(b);+ return Object.keys(x).filter((k) => x[k] !== y[k] && (x[k] != null || y[k] != null)).map((k) => ({ id: k, now: x[k], before: y[k] }));+}++// change against the previous result, per measurement (+ is better), only with the same LordBench+// version and mode+export function changes(now, prev) {+ if (!now || !prev || now.lordbench !== prev.lordbench || now.mode !== prev.mode) return null;+ const out = {};+ for (const id of Object.keys(now.results || {})) {+ const r = ratio(now, prev, id);+ if (r != null) out[id] = r - 1;+ }+ return out;+}++// the sustained test's samples as [seconds, GFLOP/s, °C or null]+export function sustainedSeries(res) {+ return (res && res.sustained && Array.isArray(res.sustained.samples) ? res.sustained.samples : [])+ .filter((s) => Array.isArray(s) && s.length === 3 && s[1] >= 0);+}++// the refresh budget of the slowest active display, ms (for the compositor's frame times)+export function refreshBudget(res) {+ const ds = (res && res.session && res.session.displays) || [];+ const hz = ds.map((d) => (d.mode && d.mode.refresh ? d.mode.refresh / 1000 : 0)).filter((x) => x > 0);+ return hz.length ? 1000 / Math.min(...hz) : null;+}++export function fileName(at, taken) {+ const d = new Date((at || 0) * 1000);+ const p = (n) => String(n).padStart(2, '0');+ const base = `lordbench-${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;+ for (let i = 1; i < 100; i++) {+ const name = i === 1 ? `${base}.json` : `${base}-${i}.json`;+ if (!taken(name)) return name;+ }+ return null;+}diff --git a/apps/sysinfo/performance.jsx b/apps/sysinfo/performance.jsxnew file mode 100644index 0000000..09aac5d--- /dev/null+++ b/apps/sysinfo/performance.jsx@@ -0,0 +1,242 @@+// System Information → Performance (0.8.6, docs/BENCHMARK.md "0.8.6 — LordBench"). Quick (about half a+// minute) or Full (storage on a scratch file and a sustained load too) runs of the lord-bench helper+// through lord.sysinfo.bench (server/src/bench/lbrun.c); while it runs this view polls every 500 ms. The+// result is shown by category as "×N" of each reference machine (perf.js, references.js), with the+// three verdicts, the conditions it ran under, the change since the previous run and the boot times+// per version. Nothing is sent anywhere; Save writes the JSON to Documents.+import {+ View, Text, ScrollView, Button, useTheme, useLocale, GroupBox, FormRow, formatNumber, spacing, typeScale, fs, userDirs, wm,+} from '@lordos/sdk';+import { useEffect, useMemo, useState } from 'react';+import { CATEGORIES, categoryRatios, comparableReferences, stability, compatibilityVerdict, conditionDiffs, changes, sustainedSeries, fileName } from './perf.js';+import { compatibility } from './model.js';++const VERDICT_COLOR = { pass: '#30d158', warn: '#ff9f0a', fail: '#ff453a', unknown: '#8e8e93' };+const key = (id) => id.replace(/\./g, '_');+const SUSTAINED_S = 180;++const bench = () => (globalThis.lord && lord.sysinfo && lord.sysinfo.bench) || null;+function readSaved(which) { try { const b = bench(); return b ? b.saved(which) : null; } catch (e) { return null; } }++function fmt(v) {+ if (v == null) return '—';+ return formatNumber(v, v >= 100 ? 0 : v >= 10 ? 1 : 2);+}++function useBench() {+ const [st, setSt] = useState(() => {+ let p = null;+ try { p = bench() && bench().poll(); } catch (e) { p = null; }+ return p || { state: 'unavailable' };+ });+ const running = st.state === 'waiting' || st.state === 'running';+ useEffect(() => {+ if (!running) return undefined;+ const id = setInterval(() => { try { const p = bench().poll(); if (p) setSt(p); } catch (e) { /* keep the last */ } }, 500);+ return () => clearInterval(id);+ }, [running]);+ const start = (mode) => {+ let ok = false;+ try { ok = !!bench().start(mode, mode === 'full' ? SUSTAINED_S : 0); } catch (e) { ok = false; }+ if (ok) setSt({ state: 'waiting', step: '', progress: 0 });+ else setSt((x) => ({ ...x, error: 'start' }));+ };+ const cancel = () => { try { bench().cancel(); } catch (e) { /* nothing to cancel */ } };+ return [st, running, start, cancel];+}++function Bar({ value }) {+ const t = useTheme();+ return (+ <View style={{ height: 6, borderRadius: 3, overflow: 'hidden', backgroundColor: t.mode === 'dark' ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.08)' }}>+ <View style={{ width: `${Math.round(Math.max(0, Math.min(1, value)) * 100)}%`, height: 6, backgroundColor: t.accent || '#0a84ff' }} />+ </View>+ );+}++function Verdict({ label, state, detail }) {+ const t = useTheme();+ const { t: tr } = useLocale();+ return (+ <View style={{ flexDirection: 'row', alignItems: 'flex-start', gap: spacing.m, minHeight: 40, paddingVertical: 8 }}>+ <View style={{ width: 10, height: 10, marginTop: 5, borderRadius: 5, backgroundColor: VERDICT_COLOR[state] || '#8e8e93' }} />+ <Text style={{ width: 150, fontSize: typeScale.body, color: t.text, textAlign: 'start' }}>{label}</Text>+ <Text style={{ width: 110, fontSize: typeScale.callout, fontWeight: 600, color: VERDICT_COLOR[state], textAlign: 'start' }}>{tr(`sysinfo.perf.verdictState.${state}`)}</Text>+ <Text style={{ flex: 1, minWidth: 0, fontSize: typeScale.callout, color: t.textDim, textAlign: 'start', lineHeight: 1.4 }}>{detail}</Text>+ </View>+ );+}++function Measurement({ id, res, refs, change }) {+ const t = useTheme();+ const { t: tr } = useLocale();+ const m = res.results && res.results[id];+ const skipped = res.skipped && res.skipped[id];+ const vs = refs.map((r) => {+ const a = m && r.results[id];+ if (!a || !(m.value > 0)) return null;+ const x = m.lowerBetter ? a.value / m.value : m.value / a.value;+ return tr('sysinfo.perf.timesRef', { x: formatNumber(x, 2), ref: tr(`sysinfo.perf.ref.${r.id}`) });+ }).filter(Boolean).join(' · ');+ const ch = change != null && Math.abs(change) >= 0.005+ ? tr(change > 0 ? 'sysinfo.perf.better' : 'sysinfo.perf.worse', { pct: formatNumber(Math.abs(change) * 100, 0) }) : '';+ return (+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.m, minHeight: 32, paddingVertical: 4 }}>+ <Text style={{ width: 230, fontSize: typeScale.body, color: t.text, textAlign: 'start' }}>{tr(`sysinfo.perf.m.${key(id)}`)}</Text>+ <Text style={{ width: 130, fontSize: typeScale.body, fontWeight: 600, color: m ? t.text : t.textDim, textAlign: 'end', fontVariantNumeric: 'tabular-nums' }}>+ {m ? `${fmt(m.value)} ${m.unit}` : '—'}</Text>+ <Text style={{ flex: 1, minWidth: 0, fontSize: typeScale.callout, color: t.textDim, textAlign: 'start' }}>{m ? vs : skipped ? tr(`sysinfo.perf.skip.${skipped}`) : ''}</Text>+ <Text style={{ width: 110, fontSize: typeScale.callout, color: change > 0 ? '#30d158' : '#ff9f0a', textAlign: 'end' }}>{ch}</Text>+ </View>+ );+}++function Row({ label, value }) {+ const t = useTheme();+ return (+ <FormRow label={label} labelWidth={190} minHeight={28}>+ <Text style={{ fontSize: typeScale.body, color: value ? t.text : t.textDim, textAlign: 'start' }}>{value || '—'}</Text>+ </FormRow>+ );+}++function Conditions({ res }) {+ const { t: tr } = useLocale();+ const b = res.before || {}, a = res.after || {};+ const temp = (c) => (c.tempC != null ? tr('sysinfo.perf.tempC', { v: formatNumber(c.tempC, 0) }) : '');+ const trips = [b.passiveC ? tr('sysinfo.perf.passive', { v: formatNumber(b.passiveC, 0) }) : '', b.criticalC ? tr('sysinfo.perf.critical', { v: formatNumber(b.criticalC, 0) }) : ''].filter(Boolean).join(' · ');+ const ds = ((res.session && res.session.displays) || []).map((d) => (d.mode ? `${d.mode.w}×${d.mode.h} @ ${formatNumber(d.mode.refresh / 1000, 0)} Hz${d.scale && d.scale !== 100 ? ` (${d.scale} %)` : ''}` : '')).filter(Boolean).join(', ');+ return (+ <GroupBox title={tr('sysinfo.perf.conditions')} footer={tr('sysinfo.perf.conditionsFooter')}>+ <Row label={tr('sysinfo.perf.c.versions')} value={`LordOS ${res.lordos} · ${tr('sysinfo.perf.kernel', { v: res.kernel })} · LordBench ${res.lordbench}`} />+ <Row label={tr('sysinfo.perf.c.threads')} value={tr('sysinfo.perf.threadsOf', { n: res.threads, cpus: res.cpus })} />+ <Row label={tr('sysinfo.perf.c.quiet')} value={tr(res.quiet && res.quiet.quiet ? 'sysinfo.perf.quietYes' : 'sysinfo.perf.quietNo', { pct: formatNumber((res.quiet && res.quiet.busyPct) || 0, 0), s: formatNumber((res.quiet && res.quiet.waitedS) || 0, 0) })} />+ <Row label={tr('sysinfo.perf.c.temps')} value={[temp(b) && tr('sysinfo.perf.startEnd', { a: temp(b), b: temp(a) || '—' }), trips].filter(Boolean).join(' · ')} />+ <Row label={tr('sysinfo.perf.c.power')} value={[tr(`sysinfo.perf.power.${b.power || 'unknown'}`), b.batteryPct != null ? `${b.batteryPct} %` : '', b.platformProfile || ''].filter(Boolean).join(' · ')} />+ <Row label={tr('sysinfo.perf.c.cpufreq')} value={[b.governor, b.freqMaxMHz ? tr('sysinfo.perf.maxMHz', { v: formatNumber(b.freqMaxMHz, 0) }) : ''].filter(Boolean).join(' · ')} />+ <Row label={tr('sysinfo.perf.c.gpu')} value={[res.gpuKind ? tr(`sysinfo.perf.gpuKind.${res.gpuKind}`) : '', res.session && res.session.renderer].filter(Boolean).join(' · ')} />+ <Row label={tr('sysinfo.perf.c.displays')} value={[ds, res.session && res.session.composition ? tr('sysinfo.perf.composition', { c: res.session.composition }) : ''].filter(Boolean).join(' · ')} />+ <Row label={tr('sysinfo.perf.c.storage')} value={res.storage && res.storage.kind !== 'none' ? tr('sysinfo.perf.storageOn', { kind: tr(`sysinfo.perf.disk.${res.storage.kind}`), mb: res.storage.mb }) : tr('sysinfo.perf.storageNone')} />+ <Row label={tr('sysinfo.perf.c.live')} value={tr(res.live ? 'sysinfo.perf.liveYes' : 'sysinfo.perf.liveNo')} />+ </GroupBox>+ );+}++function Boots() {+ const { t: tr } = useLocale();+ const rows = useMemo(() => { try { return bench() ? bench().boots() : null; } catch (e) { return null; } }, []);+ if (!rows || !rows.length) return null;+ return (+ <GroupBox title={tr('sysinfo.perf.boots')} footer={tr('sysinfo.perf.bootsFooter')}>+ {rows.slice(-6).reverse().map((r) => (+ <Row key={r.version} label={r.version} value={r.boots+ ? tr('sysinfo.perf.bootLine', { median: formatNumber(r.median, 1), min: formatNumber(r.min, 1), max: formatNumber(r.max, 1), n: r.boots })+ + (r.first != null ? ` · ${tr('sysinfo.perf.bootFirst', { s: formatNumber(r.first, 1) })}` : '')+ : tr('sysinfo.perf.bootOnlyFirst', { s: formatNumber(r.first, 1) })} />+ ))}+ </GroupBox>+ );+}++function Result({ res, report }) {+ const t = useTheme();+ const { t: tr } = useLocale();+ const refs = useMemo(() => comparableReferences(res), [res]);+ const prev = useMemo(() => { const s0 = readSaved(0); return s0 && s0.at === res.at ? readSaved(1) : s0; }, [res]);+ const prevComparable = prev && prev.at !== res.at ? prev : null;+ const ch = useMemo(() => changes(res, prevComparable), [res, prevComparable]);+ const diffs = useMemo(() => (ch ? conditionDiffs(res, prevComparable) : []), [res, prevComparable, ch]);+ const stab = useMemo(() => stability(res), [res]);+ const compat = useMemo(() => compatibilityVerdict(compatibility(report)), [report]);+ const perfText = refs.map((r) => {+ const cr = categoryRatios(res, r);+ const parts = CATEGORIES.filter((c) => cr[c.id] != null).map((c) => tr('sysinfo.perf.catTimes', { cat: tr(`sysinfo.perf.cat.${c.id}`), x: formatNumber(cr[c.id], 2) }));+ return parts.length ? tr('sysinfo.perf.againstRef', { ref: tr(`sysinfo.perf.ref.${r.id}`), list: parts.join(', ') }) : '';+ }).filter(Boolean).join('\n') || tr('sysinfo.perf.noRefs');+ const series = sustainedSeries(res);+ const [msg, setMsg] = useState(null);+ const save = () => {+ const dir = userDirs().documents;+ try { fs.mkdir(dir); } catch (e) { /* already there */ }+ const name = fileName(res.at, (n) => { try { return !!fs.stat(`${dir}/${n}`); } catch (e) { return false; } });+ try {+ if (!name) throw new Error('name');+ fs.write(`${dir}/${name}`, `${JSON.stringify(res, null, 2)}\n`);+ setMsg({ ok: true, text: tr('sysinfo.report.saved', { name }), dir });+ } catch (e) { setMsg({ ok: false, text: tr('sysinfo.report.saveFailed') }); }+ };+ return (+ <View style={{ gap: spacing.l }}>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.s }}>+ <Text style={{ flex: 1, fontSize: typeScale.callout, color: t.textDim, textAlign: 'start' }}>+ {tr('sysinfo.perf.ranAt', { mode: tr(`sysinfo.perf.mode.${res.mode}`), time: new Date(res.at * 1000).toLocaleString(), s: formatNumber(res.seconds, 0) })}+ {res.status !== 'done' ? ` · ${tr(`sysinfo.perf.status.${res.status}`)}${res.stopReason ? ` (${tr(`sysinfo.perf.why.${res.stopReason}`)})` : ''}` : ''}</Text>+ <Button label={tr('sysinfo.report.save')} onClick={save} />+ </View>+ {msg ? (+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.s }}>+ <Text style={{ fontSize: typeScale.callout, color: msg.ok ? '#30d158' : '#ff453a', textAlign: 'start' }}>{msg.text}</Text>+ {msg.dir ? <Button small plain label={tr('sysinfo.report.showInFiles')} onClick={() => wm.open('files', { new: true, args: { path: msg.dir } })} /> : null}+ </View>+ ) : null}+ <GroupBox title={tr('sysinfo.perf.verdicts')} footer={tr('sysinfo.perf.verdictsFooter')}>+ <Verdict label={tr('sysinfo.perf.v.performance')} state={refs.length ? 'pass' : 'unknown'} detail={perfText} />+ <Verdict label={tr('sysinfo.perf.v.compatibility')} state={compat.state}+ detail={tr('sysinfo.perf.compatCount', { works: compat.count.works, limits: compat.count.limits, no: compat.count.no })} />+ <Verdict label={tr('sysinfo.perf.v.stability')} state={stab.state}+ detail={stab.notes.length ? stab.notes.map((n) => tr(`sysinfo.perf.note.${n.id}`, n.vars)).join(' ') : tr('sysinfo.perf.note.none')} />+ </GroupBox>+ {CATEGORIES.map((c) => (+ <GroupBox key={c.id} title={tr(`sysinfo.perf.cat.${c.id}`)}>+ {c.ids.map((id) => <Measurement key={id} id={id} res={res} refs={refs} change={ch ? ch[id] : null} />)}+ {c.id === 'sustained' && series.length ? (+ <Text style={{ fontSize: typeScale.caption, color: t.textDim, textAlign: 'start', paddingVertical: 6, lineHeight: 1.5 }}>+ {series.map(([s, g, temp]) => tr(temp == null ? 'sysinfo.perf.sampleNoTemp' : 'sysinfo.perf.sample', { s: formatNumber(s, 0), g: formatNumber(g, 1), temp: temp == null ? '' : formatNumber(temp, 0) })).join(' · ')}</Text>+ ) : null}+ </GroupBox>+ ))}+ {diffs.length ? (+ <GroupBox title={tr('sysinfo.perf.diffs')}>+ {diffs.map((d) => <Row key={d.id} label={tr(`sysinfo.perf.diff.${d.id}`)} value={tr('sysinfo.perf.diffLine', { now: String(d.now ?? '—'), before: String(d.before ?? '—') })} />)}+ </GroupBox>+ ) : null}+ <Conditions res={res} />+ </View>+ );+}++export default function Performance({ r }) {+ const t = useTheme();+ const { t: tr } = useLocale();+ const [st, running, start, cancel] = useBench();+ const res = st.result || (running ? null : readSaved(0));+ if (st.state === 'unavailable') return <View style={{ padding: spacing.xl }}><Text style={{ color: t.textDim, textAlign: 'start' }}>{tr('sysinfo.perf.unavailable')}</Text></View>;+ return (+ <ScrollView style={{ flex: 1 }}>+ <View style={{ padding: spacing.xl, gap: spacing.l }}>+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.m }}>+ <View style={{ flex: 1, gap: 2 }}>+ <Text style={{ fontSize: typeScale.headline, fontWeight: 600, color: t.text, textAlign: 'start' }}>LordBench</Text>+ <Text style={{ fontSize: typeScale.callout, color: t.textDim, textAlign: 'start', lineHeight: 1.4 }}>{tr('sysinfo.perf.intro')}</Text>+ </View>+ {running ? <Button label={tr('sysinfo.perf.cancel')} onClick={cancel} /> : [+ <Button key="f" label={tr('sysinfo.perf.full')} onClick={() => start('full')} />,+ <Button key="q" primary label={tr('sysinfo.perf.quick')} onClick={() => start('quick')} />,+ ]}+ </View>+ {!running ? <Text style={{ fontSize: typeScale.caption, color: t.textDim, textAlign: 'start', lineHeight: 1.4 }}>{tr('sysinfo.perf.fullNote', { min: SUSTAINED_S / 60 })}</Text> : null}+ {st.error ? <Text style={{ fontSize: typeScale.callout, color: '#ff453a', textAlign: 'start' }}>{tr('sysinfo.perf.startFailed')}</Text> : null}+ {running ? (+ <View style={{ gap: spacing.s }}>+ <Text style={{ fontSize: typeScale.body, color: t.text, textAlign: 'start' }}>+ {st.state === 'waiting' ? tr('sysinfo.perf.waiting') : tr('sysinfo.perf.measuring', { what: st.step ? tr(`sysinfo.perf.m.${key(st.step)}`) : '…' })}</Text>+ <Bar value={st.progress || 0} />+ <Text style={{ fontSize: typeScale.caption, color: t.textDim, textAlign: 'start' }}>{tr('sysinfo.perf.keepStill')}</Text>+ </View>+ ) : null}+ {res ? <Result res={res} report={r} /> : !running ? <Text style={{ fontSize: typeScale.callout, color: t.textDim, textAlign: 'start' }}>{tr('sysinfo.perf.none')}</Text> : null}+ {!running ? <Boots /> : null}+ </View>+ </ScrollView>+ );+}diff --git a/apps/sysinfo/references.js b/apps/sysinfo/references.jsnew file mode 100644index 0000000..fb59b00--- /dev/null+++ b/apps/sysinfo/references.js@@ -0,0 +1,21 @@+// LordBench's reference machines (docs/BENCHMARK.md, "Results without one magic number"): a result is+// shown as "×N" of each one measured with the same LordBench version. Every entry is a real Full run,+// copied from the lordbench.json it wrote, with the machine described in sysinfo.perf.ref.<id>.+// Planned: a Raspberry Pi 5 8 GB and a modest x86 PC; they are added when they have been measured.+export const REFERENCES = [+ {+ // VM 116 on Proxmox VE: 8 vCPU (host CPU, Xeon Silver 4108 at 1.8 GHz), 4 GB, virtio disk, no+ // GPU passthrough (Mesa llvmpipe); LordOS 0.8.5 + LordBench 1, 2026-10-27, Full with 30 s sustained+ id: 'vm', lordbench: 1, mode: 'full',+ results: {+ 'cpu.sha256.1': { value: 166.557 }, 'cpu.sha256.n': { value: 976.519 },+ 'cpu.matmul.1': { value: 3.41756 }, 'cpu.matmul.n': { value: 19.6958 },+ 'cpu.xz.1': { value: 60.9097 }, 'cpu.xz.n': { value: 353.612 },+ 'cpu.js.1': { value: 58.2072 }, 'cpu.js.n': { value: 335.649 },+ 'mem.copy': { value: 20.157 }, 'mem.triad': { value: 22.7711 }, 'mem.latency': { value: 90.1192 },+ 'gpu.scene': { value: 793.718 }, 'gpu.fill': { value: 394.575 }, 'gpu.upload': { value: 9676.24 }, 'gpu.layers': { value: 22.6118 },+ 'disk.seqwrite': { value: 219.028 }, 'disk.seqread': { value: 517.082 }, 'disk.random4k': { value: 5619.17 },+ 'sustained.start': { value: 19.7626 }, 'sustained.end': { value: 19.7667 },+ },+ },+];diff --git a/assets/locales/en/sysinfo.json b/assets/locales/en/sysinfo.jsonindex b8e8d23..b488031 100644--- a/assets/locales/en/sysinfo.json+++ b/assets/locales/en/sysinfo.json@@ -240,6 +240,147 @@"off": "Off","on": "On","paperRef": "paper {ref}",+ "perf.againstRef": "Against {ref}: {list}.",+ "perf.better": "{pct} % better",+ "perf.bootFirst": "first boot {s} s",+ "perf.bootLine": "median {median} s (from {min} to {max} s, {n} boots)",+ "perf.bootOnlyFirst": "only the first boot so far: {s} s",+ "perf.boots": "Boot time",+ "perf.bootsFooter": "From the kernel's start to the first frame on the screen, recorded at every boot. The first boot after an update is kept apart: it builds caches.",+ "perf.c.cpufreq": "Processor frequency",+ "perf.c.displays": "Displays",+ "perf.c.gpu": "Graphics",+ "perf.c.live": "System",+ "perf.c.power": "Power",+ "perf.c.quiet": "Before starting",+ "perf.c.storage": "Storage test",+ "perf.c.temps": "Temperature",+ "perf.c.threads": "Threads",+ "perf.c.versions": "Versions",+ "perf.cancel": "Stop",+ "perf.cat.cpu": "Processor",+ "perf.cat.gpu": "Graphics",+ "perf.cat.memory": "Memory",+ "perf.cat.storage": "Storage",+ "perf.cat.sustained": "Sustained load",+ "perf.catTimes": "{cat} ×{x}",+ "perf.compatCount": "{works} working, {limits} with limits, {no} not working (Compatibility tab).",+ "perf.composition": "composition: {c}",+ "perf.conditions": "Conditions",+ "perf.conditionsFooter": "What affects the numbers, recorded with every result. Results are compared only with the same LordBench version.",+ "perf.critical": "critical at {v} °C",+ "perf.diff.composition": "Screen composition",+ "perf.diff.governor": "CPU governor",+ "perf.diff.gpuKind": "Renderer",+ "perf.diff.kernel": "Kernel",+ "perf.diff.live": "Live session",+ "perf.diff.lordos": "LordOS version",+ "perf.diff.power": "Power",+ "perf.diff.profile": "Power profile",+ "perf.diff.storage": "Disk",+ "perf.diff.threads": "Threads",+ "perf.diffLine": "{now} (before: {before})",+ "perf.diffs": "Different from the previous run",+ "perf.disk.hdd": "Hard disk",+ "perf.disk.nvme": "NVMe",+ "perf.disk.ram": "Memory (tmpfs or the live session), not a disk",+ "perf.disk.sd": "SD card or eMMC",+ "perf.disk.ssd": "SSD",+ "perf.disk.unknown": "Unknown disk",+ "perf.disk.usb": "USB drive",+ "perf.disk.virtual": "Virtual disk",+ "perf.full": "Full test",+ "perf.fullNote": "The quick test takes about half a minute. The full test also measures the disk with a temporary file of up to 1 GB (deleted at the end) and keeps every core busy for {min} minutes; on an SD card it adds wear.",+ "perf.gpuKind.hardware": "hardware GPU",+ "perf.gpuKind.software": "software renderer (on the CPU)",+ "perf.gpuKind.virtual": "virtual GPU (the host draws)",+ "perf.intro": "Measures this computer with LordBench, in an isolated helper, under recorded conditions. Each result is compared with reference machines measured the same way, never folded into one score. Nothing is sent anywhere.",+ "perf.keepStill": "Other programs change the numbers: leave the computer alone until it ends. It stops by itself near the temperature limit.",+ "perf.kernel": "kernel {v}",+ "perf.liveNo": "installed",+ "perf.liveYes": "live session from the USB stick",+ "perf.m.cpu_js_1": "JavaScript, one core",+ "perf.m.cpu_js_n": "JavaScript, all cores",+ "perf.m.cpu_matmul_1": "Matrix multiply, one core",+ "perf.m.cpu_matmul_n": "Matrix multiply, all cores",+ "perf.m.cpu_sha256_1": "SHA-256, one core",+ "perf.m.cpu_sha256_n": "SHA-256, all cores",+ "perf.m.cpu_xz_1": "Package decompression, one core",+ "perf.m.cpu_xz_n": "Package decompression, all cores",+ "perf.m.disk_random4k": "Random 4 KiB reads",+ "perf.m.disk_seqread": "Sequential read",+ "perf.m.disk_seqwrite": "Sequential write",+ "perf.m.gpu_fill": "Fill rate",+ "perf.m.gpu_layers": "8 screen-size layers",+ "perf.m.gpu_scene": "3D scene at 1920×1080",+ "perf.m.gpu_upload": "Texture upload",+ "perf.m.mem_copy": "Memory bandwidth (copy)",+ "perf.m.mem_latency": "Memory latency",+ "perf.m.mem_triad": "Memory bandwidth (triad)",+ "perf.m.sustained_end": "All cores, last 10 s",+ "perf.m.sustained_start": "All cores, first 10 s",+ "perf.maxMHz": "up to {v} MHz",+ "perf.measuring": "Measuring: {what}",+ "perf.mode.full": "Full test",+ "perf.mode.quick": "Quick test",+ "perf.noRefs": "No reference machine measured with this LordBench version yet.",+ "perf.none": "No results yet on this computer.",+ "perf.note.failed": "The run failed.",+ "perf.note.measureFailed": "{count} measurement(s) failed.",+ "perf.note.none": "Ran to the end with no throttling, no stops and no failed measurement.",+ "perf.note.notQuiet": "The computer was busy before starting ({pct} % CPU): the numbers may be low.",+ "perf.note.piThrottled": "The board reports throttling.",+ "perf.note.stopped": "The run was stopped.",+ "perf.note.stoppedThermal": "Stopped near the temperature limit.",+ "perf.note.stoppedThrottled": "Stopped: the processor slowed down to cool.",+ "perf.note.sustainedDrop": "Under sustained load it lost {pct} % of its speed.",+ "perf.note.sustainedThrottle": "Under sustained load it throttled after {s} s at {temp} °C.",+ "perf.note.throttleSeen": "The processor throttled {count} time(s) during the run.",+ "perf.note.underVoltage": "The board reports low supply voltage: use a better power supply.",+ "perf.passive": "slows down at {v} °C",+ "perf.power.battery": "on battery",+ "perf.power.mains": "plugged in",+ "perf.power.unknown": "no battery reported",+ "perf.quick": "Quick test",+ "perf.quietNo": "busy ({pct} % CPU after {s} s)",+ "perf.quietYes": "quiet ({pct} % CPU, waited {s} s)",+ "perf.ranAt": "{mode} · {time} · {s} s",+ "perf.ref.vm": "the reference VM",+ "perf.sample": "{s} s: {g} GFLOP/s, {temp} °C",+ "perf.sampleNoTemp": "{s} s: {g} GFLOP/s",+ "perf.skip.failed": "failed",+ "perf.skip.memory": "not enough memory",+ "perf.skip.mode": "full test only",+ "perf.skip.nodev": "no device",+ "perf.startEnd": "{a} at start, {b} at the end",+ "perf.startFailed": "LordBench couldn't start (another run, or the lord-bench helper is missing).",+ "perf.status.cancelled": "cancelled",+ "perf.status.done": "done",+ "perf.status.failed": "failed",+ "perf.status.stopped": "stopped",+ "perf.storageNone": "not measured",+ "perf.storageOn": "{kind}, a {mb} MB temporary file",+ "perf.tempC": "{v} °C",+ "perf.threadsOf": "{n} of {cpus} processors",+ "perf.timesRef": "×{x} {ref}",+ "perf.unavailable": "LordBench isn't available in this session.",+ "perf.v.compatibility": "Compatibility",+ "perf.v.performance": "Performance",+ "perf.v.stability": "Stability",+ "perf.verdictState.fail": "Problems",+ "perf.verdictState.pass": "Measured",+ "perf.verdictState.unknown": "No reference",+ "perf.verdictState.warn": "With notes",+ "perf.verdicts": "Verdicts",+ "perf.verdictsFooter": "Three separate answers: how fast against similar machines, what works, and whether it stayed stable under load.",+ "perf.waiting": "Waiting for the computer to be quiet (up to 30 s)…",+ "perf.why.battery": "on battery below 30 %",+ "perf.why.helper": "the helper ended early",+ "perf.why.protocol": "the helper sent something unexpected",+ "perf.why.thermal": "near the temperature limit",+ "perf.why.throttled": "the processor slowed down to cool",+ "perf.why.timeout": "it took too long",+ "perf.worse": "{pct} % worse","pi.powerOk": "No under-voltage since boot","pi.throttleOk": "Never slowed down since boot","pi.throttledNow": "Slowed down now (heat or power)",@@ -312,6 +453,7 @@"tab.compat": "Compatibility","tab.hardware": "Hardware","tab.overview": "Overview",+ "tab.perf": "Performance","tab.report": "Report","thisComputer": "This computer","thisSession": "This session",diff --git a/assets/locales/es/sysinfo.json b/assets/locales/es/sysinfo.jsonindex 3faff60..3fee10a 100644--- a/assets/locales/es/sysinfo.json+++ b/assets/locales/es/sysinfo.json@@ -240,6 +240,147 @@"off": "Desactivado","on": "Activado","paperRef": "documento {ref}",+ "perf.againstRef": "Frente a {ref}: {list}.",+ "perf.better": "{pct} % mejor",+ "perf.bootFirst": "primer arranque {s} s",+ "perf.bootLine": "mediana {median} s (de {min} a {max} s, {n} arranques)",+ "perf.bootOnlyFirst": "por ahora solo el primer arranque: {s} s",+ "perf.boots": "Tiempo de arranque",+ "perf.bootsFooter": "Desde que arranca el kernel hasta el primer cuadro en pantalla, registrado en cada arranque. El primer arranque después de una actualización va aparte: arma cachés.",+ "perf.c.cpufreq": "Frecuencia del procesador",+ "perf.c.displays": "Pantallas",+ "perf.c.gpu": "Gráficos",+ "perf.c.live": "Sistema",+ "perf.c.power": "Energía",+ "perf.c.quiet": "Antes de empezar",+ "perf.c.storage": "Prueba de disco",+ "perf.c.temps": "Temperatura",+ "perf.c.threads": "Hilos",+ "perf.c.versions": "Versiones",+ "perf.cancel": "Detener",+ "perf.cat.cpu": "Procesador",+ "perf.cat.gpu": "Gráficos",+ "perf.cat.memory": "Memoria",+ "perf.cat.storage": "Almacenamiento",+ "perf.cat.sustained": "Carga sostenida",+ "perf.catTimes": "{cat} ×{x}",+ "perf.compatCount": "{works} funcionan, {limits} con límites, {no} no funcionan (pestaña Compatibilidad).",+ "perf.composition": "composición: {c}",+ "perf.conditions": "Condiciones",+ "perf.conditionsFooter": "Lo que afecta a los números, registrado con cada resultado. Solo se comparan resultados de la misma versión de LordBench.",+ "perf.critical": "crítica a {v} °C",+ "perf.diff.composition": "Composición de la pantalla",+ "perf.diff.governor": "Governor de CPU",+ "perf.diff.gpuKind": "Renderizador",+ "perf.diff.kernel": "Kernel",+ "perf.diff.live": "Sesión live",+ "perf.diff.lordos": "Versión de LordOS",+ "perf.diff.power": "Energía",+ "perf.diff.profile": "Perfil de energía",+ "perf.diff.storage": "Disco",+ "perf.diff.threads": "Hilos",+ "perf.diffLine": "{now} (antes: {before})",+ "perf.diffs": "Distinto de la prueba anterior",+ "perf.disk.hdd": "Disco rígido",+ "perf.disk.nvme": "NVMe",+ "perf.disk.ram": "Memoria (tmpfs o la sesión live), no un disco",+ "perf.disk.sd": "Tarjeta SD o eMMC",+ "perf.disk.ssd": "SSD",+ "perf.disk.unknown": "Disco desconocido",+ "perf.disk.usb": "Unidad USB",+ "perf.disk.virtual": "Disco virtual",+ "perf.full": "Prueba completa",+ "perf.fullNote": "La prueba rápida dura alrededor de medio minuto. La completa también mide el disco con un archivo temporal de hasta 1 GB (se borra al terminar) y mantiene todos los núcleos ocupados durante {min} minutos; en una tarjeta SD suma desgaste.",+ "perf.gpuKind.hardware": "GPU por hardware",+ "perf.gpuKind.software": "renderizador por software (en la CPU)",+ "perf.gpuKind.virtual": "GPU virtual (dibuja el anfitrión)",+ "perf.intro": "Mide este equipo con LordBench, en un ayudante aislado y con las condiciones registradas. Cada resultado se compara con máquinas de referencia medidas de la misma forma, nunca en un único puntaje. No se envía nada a ningún lado.",+ "perf.keepStill": "Otros programas cambian los números: no uses el equipo hasta que termine. Se detiene sola cerca del límite de temperatura.",+ "perf.kernel": "kernel {v}",+ "perf.liveNo": "instalado",+ "perf.liveYes": "sesión live desde el pendrive",+ "perf.m.cpu_js_1": "JavaScript, un núcleo",+ "perf.m.cpu_js_n": "JavaScript, todos los núcleos",+ "perf.m.cpu_matmul_1": "Producto de matrices, un núcleo",+ "perf.m.cpu_matmul_n": "Producto de matrices, todos los núcleos",+ "perf.m.cpu_sha256_1": "SHA-256, un núcleo",+ "perf.m.cpu_sha256_n": "SHA-256, todos los núcleos",+ "perf.m.cpu_xz_1": "Descompresión de paquetes, un núcleo",+ "perf.m.cpu_xz_n": "Descompresión de paquetes, todos los núcleos",+ "perf.m.disk_random4k": "Lecturas aleatorias de 4 KiB",+ "perf.m.disk_seqread": "Lectura secuencial",+ "perf.m.disk_seqwrite": "Escritura secuencial",+ "perf.m.gpu_fill": "Tasa de relleno",+ "perf.m.gpu_layers": "8 capas del tamaño de la pantalla",+ "perf.m.gpu_scene": "Escena 3D a 1920×1080",+ "perf.m.gpu_upload": "Subida de texturas",+ "perf.m.mem_copy": "Ancho de banda de memoria (copia)",+ "perf.m.mem_latency": "Latencia de memoria",+ "perf.m.mem_triad": "Ancho de banda de memoria (tríada)",+ "perf.m.sustained_end": "Todos los núcleos, últimos 10 s",+ "perf.m.sustained_start": "Todos los núcleos, primeros 10 s",+ "perf.maxMHz": "hasta {v} MHz",+ "perf.measuring": "Midiendo: {what}",+ "perf.mode.full": "Prueba completa",+ "perf.mode.quick": "Prueba rápida",+ "perf.noRefs": "Todavía no hay máquinas de referencia medidas con esta versión de LordBench.",+ "perf.none": "Todavía no hay resultados en este equipo.",+ "perf.note.failed": "La prueba falló.",+ "perf.note.measureFailed": "{count} medición(es) fallaron.",+ "perf.note.none": "Llegó al final sin bajar la velocidad, sin detenerse y sin mediciones fallidas.",+ "perf.note.notQuiet": "El equipo estaba ocupado antes de empezar ({pct} % de CPU): los números pueden ser bajos.",+ "perf.note.piThrottled": "La placa informa que bajó la velocidad.",+ "perf.note.stopped": "La prueba se detuvo.",+ "perf.note.stoppedThermal": "Se detuvo cerca del límite de temperatura.",+ "perf.note.stoppedThrottled": "Se detuvo: el procesador bajó la velocidad para enfriarse.",+ "perf.note.sustainedDrop": "Bajo carga sostenida perdió el {pct} % de su velocidad.",+ "perf.note.sustainedThrottle": "Bajo carga sostenida bajó la velocidad a los {s} s, a {temp} °C.",+ "perf.note.throttleSeen": "El procesador bajó la velocidad {count} vez/veces durante la prueba.",+ "perf.note.underVoltage": "La placa informa bajo voltaje de alimentación: usá una fuente mejor.",+ "perf.passive": "baja la velocidad a {v} °C",+ "perf.power.battery": "con batería",+ "perf.power.mains": "enchufado",+ "perf.power.unknown": "sin batería informada",+ "perf.quick": "Prueba rápida",+ "perf.quietNo": "ocupado ({pct} % de CPU después de {s} s)",+ "perf.quietYes": "en reposo ({pct} % de CPU, esperó {s} s)",+ "perf.ranAt": "{mode} · {time} · {s} s",+ "perf.ref.vm": "la VM de referencia",+ "perf.sample": "{s} s: {g} GFLOP/s, {temp} °C",+ "perf.sampleNoTemp": "{s} s: {g} GFLOP/s",+ "perf.skip.failed": "falló",+ "perf.skip.memory": "memoria insuficiente",+ "perf.skip.mode": "solo en la completa",+ "perf.skip.nodev": "sin dispositivo",+ "perf.startEnd": "{a} al empezar, {b} al terminar",+ "perf.startFailed": "LordBench no pudo arrancar (hay otra prueba en curso o falta el ayudante lord-bench).",+ "perf.status.cancelled": "cancelada",+ "perf.status.done": "terminada",+ "perf.status.failed": "falló",+ "perf.status.stopped": "detenida",+ "perf.storageNone": "no se midió",+ "perf.storageOn": "{kind}, un archivo temporal de {mb} MB",+ "perf.tempC": "{v} °C",+ "perf.threadsOf": "{n} de {cpus} procesadores",+ "perf.timesRef": "×{x} {ref}",+ "perf.unavailable": "LordBench no está disponible en esta sesión.",+ "perf.v.compatibility": "Compatibilidad",+ "perf.v.performance": "Rendimiento",+ "perf.v.stability": "Estabilidad",+ "perf.verdictState.fail": "Problemas",+ "perf.verdictState.pass": "Medido",+ "perf.verdictState.unknown": "Sin referencia",+ "perf.verdictState.warn": "Con observaciones",+ "perf.verdicts": "Veredictos",+ "perf.verdictsFooter": "Tres respuestas separadas: qué tan rápido es frente a máquinas parecidas, qué funciona y si se mantuvo estable bajo carga.",+ "perf.waiting": "Esperando a que el equipo esté en reposo (hasta 30 s)…",+ "perf.why.battery": "con batería por debajo del 30 %",+ "perf.why.helper": "el ayudante terminó antes de tiempo",+ "perf.why.protocol": "el ayudante envió algo inesperado",+ "perf.why.thermal": "cerca del límite de temperatura",+ "perf.why.throttled": "el procesador bajó la velocidad para enfriarse",+ "perf.why.timeout": "tardó demasiado",+ "perf.worse": "{pct} % peor","pi.powerOk": "Sin bajo voltaje desde el arranque","pi.throttleOk": "Nunca se limitó desde el arranque","pi.throttledNow": "Limitada ahora (calor o alimentación)",@@ -312,6 +453,7 @@"tab.compat": "Compatibilidad","tab.hardware": "Hardware","tab.overview": "Resumen",+ "tab.perf": "Rendimiento","tab.report": "Informe","thisComputer": "Este equipo","thisSession": "Esta sesión",diff --git a/assets/locales/pt/sysinfo.json b/assets/locales/pt/sysinfo.jsonindex 9a97368..97d4795 100644--- a/assets/locales/pt/sysinfo.json+++ b/assets/locales/pt/sysinfo.json@@ -240,6 +240,147 @@"off": "Desativado","on": "Ativado","paperRef": "documento {ref}",+ "perf.againstRef": "Frente a {ref}: {list}.",+ "perf.better": "{pct} % melhor",+ "perf.bootFirst": "primeira inicialização {s} s",+ "perf.bootLine": "mediana {median} s (de {min} a {max} s, {n} inicializações)",+ "perf.bootOnlyFirst": "por enquanto só a primeira inicialização: {s} s",+ "perf.boots": "Tempo de inicialização",+ "perf.bootsFooter": "Do início do kernel até o primeiro quadro na tela, registrado a cada inicialização. A primeira inicialização após uma atualização fica à parte: ela monta caches.",+ "perf.c.cpufreq": "Frequência do processador",+ "perf.c.displays": "Telas",+ "perf.c.gpu": "Gráficos",+ "perf.c.live": "Sistema",+ "perf.c.power": "Energia",+ "perf.c.quiet": "Antes de começar",+ "perf.c.storage": "Teste de disco",+ "perf.c.temps": "Temperatura",+ "perf.c.threads": "Threads",+ "perf.c.versions": "Versões",+ "perf.cancel": "Parar",+ "perf.cat.cpu": "Processador",+ "perf.cat.gpu": "Gráficos",+ "perf.cat.memory": "Memória",+ "perf.cat.storage": "Armazenamento",+ "perf.cat.sustained": "Carga contínua",+ "perf.catTimes": "{cat} ×{x}",+ "perf.compatCount": "{works} funcionam, {limits} com limites, {no} não funcionam (aba Compatibilidade).",+ "perf.composition": "composição: {c}",+ "perf.conditions": "Condições",+ "perf.conditionsFooter": "O que afeta os números, registrado com cada resultado. Só se comparam resultados da mesma versão do LordBench.",+ "perf.critical": "crítica a {v} °C",+ "perf.diff.composition": "Composição da tela",+ "perf.diff.governor": "Governor da CPU",+ "perf.diff.gpuKind": "Renderizador",+ "perf.diff.kernel": "Kernel",+ "perf.diff.live": "Sessão live",+ "perf.diff.lordos": "Versão do LordOS",+ "perf.diff.power": "Energia",+ "perf.diff.profile": "Perfil de energia",+ "perf.diff.storage": "Disco",+ "perf.diff.threads": "Threads",+ "perf.diffLine": "{now} (antes: {before})",+ "perf.diffs": "Diferente do teste anterior",+ "perf.disk.hdd": "Disco rígido",+ "perf.disk.nvme": "NVMe",+ "perf.disk.ram": "Memória (tmpfs ou a sessão live), não um disco",+ "perf.disk.sd": "Cartão SD ou eMMC",+ "perf.disk.ssd": "SSD",+ "perf.disk.unknown": "Disco desconhecido",+ "perf.disk.usb": "Unidade USB",+ "perf.disk.virtual": "Disco virtual",+ "perf.full": "Teste completo",+ "perf.fullNote": "O teste rápido leva cerca de meio minuto. O completo também mede o disco com um arquivo temporário de até 1 GB (apagado no fim) e mantém todos os núcleos ocupados por {min} minutos; num cartão SD aumenta o desgaste.",+ "perf.gpuKind.hardware": "GPU por hardware",+ "perf.gpuKind.software": "renderizador por software (na CPU)",+ "perf.gpuKind.virtual": "GPU virtual (o hospedeiro desenha)",+ "perf.intro": "Mede este computador com o LordBench, num auxiliar isolado e com as condições registradas. Cada resultado é comparado com máquinas de referência medidas da mesma forma, nunca numa única pontuação. Nada é enviado a lugar nenhum.",+ "perf.keepStill": "Outros programas mudam os números: não use o computador até terminar. Ele para sozinho perto do limite de temperatura.",+ "perf.kernel": "kernel {v}",+ "perf.liveNo": "instalado",+ "perf.liveYes": "sessão live a partir do pendrive",+ "perf.m.cpu_js_1": "JavaScript, um núcleo",+ "perf.m.cpu_js_n": "JavaScript, todos os núcleos",+ "perf.m.cpu_matmul_1": "Produto de matrizes, um núcleo",+ "perf.m.cpu_matmul_n": "Produto de matrizes, todos os núcleos",+ "perf.m.cpu_sha256_1": "SHA-256, um núcleo",+ "perf.m.cpu_sha256_n": "SHA-256, todos os núcleos",+ "perf.m.cpu_xz_1": "Descompressão de pacotes, um núcleo",+ "perf.m.cpu_xz_n": "Descompressão de pacotes, todos os núcleos",+ "perf.m.disk_random4k": "Leituras aleatórias de 4 KiB",+ "perf.m.disk_seqread": "Leitura sequencial",+ "perf.m.disk_seqwrite": "Escrita sequencial",+ "perf.m.gpu_fill": "Taxa de preenchimento",+ "perf.m.gpu_layers": "8 camadas do tamanho da tela",+ "perf.m.gpu_scene": "Cena 3D em 1920×1080",+ "perf.m.gpu_upload": "Envio de texturas",+ "perf.m.mem_copy": "Largura de banda da memória (cópia)",+ "perf.m.mem_latency": "Latência da memória",+ "perf.m.mem_triad": "Largura de banda da memória (tríade)",+ "perf.m.sustained_end": "Todos os núcleos, últimos 10 s",+ "perf.m.sustained_start": "Todos os núcleos, primeiros 10 s",+ "perf.maxMHz": "até {v} MHz",+ "perf.measuring": "Medindo: {what}",+ "perf.mode.full": "Teste completo",+ "perf.mode.quick": "Teste rápido",+ "perf.noRefs": "Ainda não há máquinas de referência medidas com esta versão do LordBench.",+ "perf.none": "Ainda não há resultados neste computador.",+ "perf.note.failed": "O teste falhou.",+ "perf.note.measureFailed": "{count} medição(ões) falharam.",+ "perf.note.none": "Chegou ao fim sem reduzir a velocidade, sem parar e sem medições com falha.",+ "perf.note.notQuiet": "O computador estava ocupado antes de começar ({pct} % de CPU): os números podem estar baixos.",+ "perf.note.piThrottled": "A placa informa redução de velocidade.",+ "perf.note.stopped": "O teste foi interrompido.",+ "perf.note.stoppedThermal": "Parou perto do limite de temperatura.",+ "perf.note.stoppedThrottled": "Parou: o processador reduziu a velocidade para esfriar.",+ "perf.note.sustainedDrop": "Sob carga contínua perdeu {pct} % da velocidade.",+ "perf.note.sustainedThrottle": "Sob carga contínua reduziu a velocidade após {s} s, a {temp} °C.",+ "perf.note.throttleSeen": "O processador reduziu a velocidade {count} vez(es) durante o teste.",+ "perf.note.underVoltage": "A placa informa tensão de alimentação baixa: use uma fonte melhor.",+ "perf.passive": "reduz a velocidade a {v} °C",+ "perf.power.battery": "na bateria",+ "perf.power.mains": "na tomada",+ "perf.power.unknown": "sem bateria informada",+ "perf.quick": "Teste rápido",+ "perf.quietNo": "ocupado ({pct} % de CPU depois de {s} s)",+ "perf.quietYes": "em repouso ({pct} % de CPU, esperou {s} s)",+ "perf.ranAt": "{mode} · {time} · {s} s",+ "perf.ref.vm": "a VM de referência",+ "perf.sample": "{s} s: {g} GFLOP/s, {temp} °C",+ "perf.sampleNoTemp": "{s} s: {g} GFLOP/s",+ "perf.skip.failed": "falhou",+ "perf.skip.memory": "memória insuficiente",+ "perf.skip.mode": "só no completo",+ "perf.skip.nodev": "sem dispositivo",+ "perf.startEnd": "{a} no início, {b} no fim",+ "perf.startFailed": "O LordBench não pôde iniciar (outro teste em curso ou falta o auxiliar lord-bench).",+ "perf.status.cancelled": "cancelado",+ "perf.status.done": "concluído",+ "perf.status.failed": "falhou",+ "perf.status.stopped": "interrompido",+ "perf.storageNone": "não medido",+ "perf.storageOn": "{kind}, um arquivo temporário de {mb} MB",+ "perf.tempC": "{v} °C",+ "perf.threadsOf": "{n} de {cpus} processadores",+ "perf.timesRef": "×{x} {ref}",+ "perf.unavailable": "O LordBench não está disponível nesta sessão.",+ "perf.v.compatibility": "Compatibilidade",+ "perf.v.performance": "Desempenho",+ "perf.v.stability": "Estabilidade",+ "perf.verdictState.fail": "Problemas",+ "perf.verdictState.pass": "Medido",+ "perf.verdictState.unknown": "Sem referência",+ "perf.verdictState.warn": "Com observações",+ "perf.verdicts": "Veredictos",+ "perf.verdictsFooter": "Três respostas separadas: quão rápido é frente a máquinas parecidas, o que funciona e se ficou estável sob carga.",+ "perf.waiting": "Esperando o computador ficar em repouso (até 30 s)…",+ "perf.why.battery": "na bateria abaixo de 30 %",+ "perf.why.helper": "o auxiliar terminou antes da hora",+ "perf.why.protocol": "o auxiliar enviou algo inesperado",+ "perf.why.thermal": "perto do limite de temperatura",+ "perf.why.throttled": "o processador reduziu a velocidade para esfriar",+ "perf.why.timeout": "demorou demais",+ "perf.worse": "{pct} % pior","pi.powerOk": "Sem subtensão desde a inicialização","pi.throttleOk": "Nunca foi limitada desde a inicialização","pi.throttledNow": "Limitada agora (calor ou alimentação)",@@ -312,6 +453,7 @@"tab.compat": "Compatibilidade","tab.hardware": "Hardware","tab.overview": "Resumo",+ "tab.perf": "Desempenho","tab.report": "Relatório","thisComputer": "Este computador","thisSession": "Esta sessão",diff --git a/docs/BENCHMARK.md b/docs/BENCHMARK.mdindex f7c0297..ece51ce 100644--- a/docs/BENCHMARK.md+++ b/docs/BENCHMARK.md@@ -1,6 +1,6 @@# System Information, LordBench and hardware reports (proposal)-**Status: design proposal. Built and released in 0.8.5-beta (2026-10-27; see "Work plan for 0.8.5" below): the collector, `lordos-sysreport report|fetch`, the System Information app (Overview, Hardware, Compatibility, Checks, Report), the Sandbox Probe and the shared measurement library `server/src/bench`. LordBench (0.8.6), community reports (0.8.7) and the `checks`/`bench` subcommands of `lordos-sysreport` are not built.** It plans three releases and a later stage:+**Status: design proposal. Built and released in 0.8.5-beta (2026-10-27; see "Work plan for 0.8.5" below): the collector, `lordos-sysreport report|fetch`, the System Information app (Overview, Hardware, Compatibility, Checks, Report), the Sandbox Probe and the shared measurement library `server/src/bench`. LordBench (0.8.6) is in development: the `lord-bench` helper, its CPU, memory, GPU, storage and sustained workloads, the guards and System Information's Performance tab are built (see "Built so far" under 0.8.6); the desktop-impact mode, the compositor and video workloads and two of the three reference machines are not. Community reports (0.8.7) and the `checks`/`bench` subcommands of `lordos-sysreport` are not built.** It plans three releases and a later stage:| Release | What ||---|---|@@ -43,8 +43,8 @@ server/src/bench/ LordBench workloads (library)- **`lord-bench`** is the helper the app starts for workloads, launched like `lord-doc` and`lord-media`: fixed path (`<lord-server dir>/lord-bench`), no arguments, minimal environment,channel on fd 3, `sandbox_apply_helper()` before any work; it gets only the render node and a- temporary file as fds. It links libc and Mesa's EGL/GLES (already used by the GPU path), nothing- new. The CLI links the same library directly.+ temporary file as fds. It links libc, Mesa's GBM/EGL/GLES (already used by the GPU path) and the+ vendored QuickJS (one of its workloads), nothing new. The CLI links the same library directly.## 0.8.5 — System Information@@ -193,6 +193,88 @@ Three separate verdicts, never folded into one score:- **Compatibility**: from the Compatibility panel.- **Stability**: errors and crashes during the run, frames missed under load, throttling.+### Built so far (in development for 0.8.6, 2026-10-27)++Unreleased; the latest release is 0.8.5-beta. Checked on VM 116 (Proxmox VE, 8 vCPU of a Xeon Silver+4108, 4 GB, virtio disk, no GPU passthrough: Mesa's llvmpipe) from a terminal (`build/lordbench-cli`) and+in an isolated headless session through System Information → Performance.++- **`lord-bench`** (`server/src/bench/lbmain.c`, `mk/lordbench.mk`): launched by lord-server+ (`bench/lbrun.c`) from its own folder only (owned by root or the user, not writable by others), no+ arguments, `LANG` only (and `LORDOS_SESSIOND` in a lord-sessiond session), the channel on fd 3. It+ receives one fixed-size request (`LbGo`, `bench/lbproto.h`) with at most two fds lord-server opened: the+ GPU's render node (`/dev/dri/renderD128…`) and, for Full, an unnamed scratch file (`O_TMPFILE` in+ `~/.cache`, at most 1 GB and a quarter of the free space). Then it locks itself in with+ `sandbox_apply_helper` before any work (scope `lordos-bench.scope`, 2 GB memory cap, read-only+ `/usr/lib`, `/usr/share`, `/sys/dev/char`, `/sys/devices` for Mesa, DRM and dma-buf ioctls only when+ it got the render node, no sockets, no exec, threads only). It answers only with fixed-size records+ (`LbMsg`: a measurement id, a value and its spread); lord-server checks each one (`lb_msg_valid`: the+ magic, a known kind and id, finite values in range) and writes the JSON itself. Stopping is a SIGKILL.+- **Workloads** (`bench/lbwork.c`, `bench/lbgpu.c`), each repeated three times and reported as the+ median with its spread (max − min), on one core and on all of them:+ - CPU: SHA-256 (`pkg/crypto.c`, with the CPU's SHA instructions when present); a 256×256+ double-precision matrix product; decompressing a fixed 2 MB text with the package engine's own xz+ decoder (`pkg/xz.c`; the text is generated at build time by `bench/lbcorpus.c` and compressed with+ `xz -9`), instead of the deflate in the design above; QuickJS running a fixed script (strings, JSON,+ sorting, objects, a regular expression), one runtime per thread. The layout, paint and shaping+ workloads are not built.+ - Memory: copy and triad bandwidth on all cores (32 MB arrays in Quick, 128 MB in Full) and the+ latency of a dependent pointer chase over 64 MB.+ - GPU: OpenGL ES 2 offscreen on the render node (GBM + EGL, a surfaceless context, a 1920×1080+ framebuffer object; every frame ends with `glFinish`): the 3D scene of the Test Bench+ (`bench/glscene.c`), fill rate with 16 blended full-screen quads, 1920×1080 RGBA texture uploads and+ 8 blended screen-size layers.+ - Storage (Full only): sequential write with `fdatasync`, sequential read after dropping the page+ cache for that file, random 4 KiB reads for 3 s; the file is emptied at the end and, being unnamed,+ disappears with the fd.+ - Sustained (Full only, 3 minutes from the app): the matrix product on every core, a sample every+ 10 s with the temperature lord-server read at that moment.+- **Guards and conditions** (`bench/lbcond.c`, read by lord-server, never by the helper): the hottest+ thermal zone (or the CPU's coretemp/k10temp/zenpower hwmon sensor) and the lowest passive and+ critical trip points; the x86 thermal throttle counters; the Raspberry Pi firmware's `get_throttled`+ flags and its `rpi_volt` under-voltage alarm; cpufreq, governor and ACPI platform profile; batteries+ (a device's own battery, such as a mouse's, is ignored) and mains. A run is refused on battery below+ 30 %, waits for 10 s in a row below 15 % CPU (at most 30 s, then it runs marked "busy"), stops within+ 2 °C of the passive trip point (or 10 °C of the critical one when there is no passive), and in the peak+ tests stops when the throttle counters grow or the Pi says it is throttling now; in the sustained test+ throttling is recorded with its time and temperature instead. The kind of disk under the scratch file+ is recorded (NVMe, SD/eMMC, SSD, HDD, USB, virtual, or RAM in the live session). Unit tests on fake+ sysfs trees (`tests/lordbench_test.c`, 260 checks): an x86 laptop on battery, a Raspberry Pi 5.+- **The result** (`~/.local/state/lordos/lordbench.json`, the previous one kept as+ `lordbench-prev.json`; a refused run keeps the last result): LordBench's version, the mode, status and+ stop reason, LordOS and kernel versions, live or installed, threads, the quiet wait, conditions before+ and after, the disk kind, the GPU kind (hardware, virtual or software), the sandbox mask, this+ session's composition and each active display's connector, mode, refresh, scale and rotation (no+ names, vendors or identities), every measurement with its unit, what was skipped and why, and the+ sustained samples. `lord.sysinfo.bench.boots()` groups lord-sessiond's boot history by version+ (median, range, the first boot after an update apart).+- **System Information → Performance** (`apps/sysinfo/performance.jsx`, model in `perf.js`, tested in+ `server/tests/sysinfo_perf_test.mjs`): Quick and Full, progress by measurement, then the three verdicts+ (performance as "×N" per category against each reference measured with the same LordBench version;+ compatibility counted from the Compatibility tab; stability from the status, failed measurements,+ throttling, under-voltage, a sustained drop above 10 % and a busy start), every measurement with its+ "×N" and its change against the previous run, the conditions that differ from the previous run, the+ conditions, the boot times per version, and **Save to Documents** (the JSON). Nothing is sent.+- **Reference machines** (`apps/sysinfo/references.js`): only VM 116 so far (a Full run with a 30 s+ sustained test, numbers below). The Raspberry Pi 5 8 GB and the modest x86 PC are added when measured.++VM 116, Full, LordBench 1 (2026-10-27): SHA-256 167 MB/s on one core and 977 MB/s on eight; matrix+product 3.4 and 19.7 GFLOP/s; xz 61 and 354 MB/s; QuickJS 58 and 336 runs/s; memory copy 20.2 GB/s,+triad 22.8 GB/s, latency 90 ns; llvmpipe: scene 794 fps, fill 395 Mpixel/s, upload 9,676 MB/s, 8 layers+22.6 fps; virtio disk: 219 MB/s write, 517 MB/s read, 5,619 random reads/s; sustained 19.8 GFLOP/s from+start to end. A Quick run took 33 s, a Full run with 30 s sustained 117 s.++The same Full run from System Information in the isolated headless session (3 minutes of sustained load;+its home is on tmpfs, so the storage test measured memory and says so, ×24 the reference's virtio disk):++++Not built yet: the desktop-impact mode (the helper already takes the low-priority flag, `LB_GO_LOW`;+the scripted scene and the frame-time and input-latency measurement while it runs are missing), the+compositor workload (lord-server's own frame counters during a scripted window drag), the video+workload (clips decoded in `lord-media`, hardware and software, and the remote desktop's encoders),+rebooting N times for the boot time, repeating the helper-sandbox self-test inside `lord-bench` (`sec.helper-sandbox`), the Pi 5 and x86 PC references, and `lordos-sysreport bench`.+## 0.8.7 — Community hardware reports- **Share on GitHub** saves the report as a small HTML page and opens it with the default browserdiff --git a/docs/FLATPAK.md b/docs/FLATPAK.mdnew file mode 100644index 0000000..5d167ee--- /dev/null+++ b/docs/FLATPAK.md@@ -0,0 +1,648 @@+# Flatpak and Flathub in LordOS: design review++**Status (2026-10-27, for 0.8.6): design review only. No code has been written and nothing below is+built.** The roadmap item ([ROADMAP.md](ROADMAP.md), "Flatpak and Flathub (0.8.6, approved by the+maintainer on 2026-10-27; needs a design review before code)") asks for a Flathub section in the+Store without giving up LordOS's security model. This document goes through the four problems the+roadmap lists, gives the options for each with their trade-offs against `AGENTS.md`, recommends+one, and lists exactly which new exceptions the maintainer has to approve before any code is+written. Every statement is marked as one of:++- **Checked** — read on 2026-10-27 from Flatpak's source at the tag Debian 13 ships (1.16.6), from+ Debian 13's package metadata, from Flathub's live repository, or from LordOS's own code and docs.+ Not run.+- **Design** — a proposal, not built.+- **Unverified** — an assumption that the test plan has to confirm on a VM before it can be claimed.++Nothing here has been run on a VM. No compatibility with any Flathub app is claimed.++## Summary++**Recommendation:**++- **Flatpak stays optional.** The Debian `flatpak` package is installed only when the user turns+ Flathub on in the Store, through the existing package engine (`pkg-install`, without Recommends),+ like Chrome or Spotify. LordOS never links libflatpak, libostree or bubblewrap. Its own isolation+ stays its own code: the root-owned app scope, `lord-netperm`'s kernel programs and the launcher's+ view. Flatpak's sandbox (bubblewrap) is an extra layer inside it, never the only one.+- **Identity:** a Flatpak app is started only by LordOS's launcher, in a root-owned+ `app-lordos-fp-<id>.scope`, which the firewall, the Monitor, the PipeWire guard and the+ notification server read as the app `flatpak:<id>`. `flatpak run` can't move itself out (its+ transient-scope call needs `/run/user/<uid>/systemd/private`, which the launcher's view doesn't+ contain; the call failing is not fatal in Flatpak). No identity is ever taken from a unit name+ under `user@`.+- **Launching:** the launcher never runs the `Exec` line of a Flatpak export. It takes a validated+ Flatpak app id of an installed app and builds the `flatpak run` command line itself in C: a fixed+ set of options plus LordOS's restrictions and a fixed list of things LordOS never grants. The+ command-line options win over the app's metadata and over the user's override files.+- **Permissions:** the Store shows what the app declares (its `[Context]`) and what LordOS changes.+ LordOS's existing restrictions (Settings → Privacy) apply to Flatpak apps through the same+ kernel paths as to Linux apps. No portal beyond the Settings portal LordOS already serves in+ 0.8.6; a LordOS portal is a later phase with its own review.+- **Installing:** per user (`flatpak --user`), no root and no new admin action. The Flathub remote+ comes from a `.flatpakrepo` file LordOS ships (its GPG key pinned), the catalog is Flathub's+ signed appstream data that `flatpak` itself verifies, and every `flatpak` command lord-server runs+ is one of a closed list, run in its own firewall component `lordos:flathub`.+- **Seven approvals are needed** (see "Exceptions to approve"): the Flatpak launch path, the+ `flatpak:<id>` identity and scope name, the closed list of `flatpak` management commands with+ network, the dependency-policy wording, masking two Flatpak services, the `lord.fs` deny list,+ and a sandboxed parser for the catalog.++The largest limits, said up front: apps that start sub-sandboxes through Flatpak's portal (most+Chromium/Electron apps, through zypak) would lose those processes' per-app identity and probably+don't work in phase 1; file chooser dialogs show only what the app's sandbox already sees; and a+device-restricted Flatpak app has no D-Bus at all, as Linux apps don't today.++## What Debian 13 ships (Checked)++| Package | Version in trixie (sources.debian.org, 2026-10-27) | Notes |+|---|---|---|+| `flatpak` | 1.16.6-1~deb13u2 | Depends: `bubblewrap (>= 0.10)`, `fuse3`, `xdg-dbus-proxy`, `adduser` and its libraries (libostree among them). Recommends: `xdg-desktop-portal`, `xdg-desktop-portal-gtk`, `polkitd`, `libpam-systemd`… |+| `bubblewrap` | 0.12.0-1~deb13u1 | **not setuid**: Debian's README says the setuid mode "is no longer possible"; it needs unprivileged user namespaces (`kernel.unprivileged_userns_clone`, 1 by default) |++The `flatpak` package also installs (file list from packages.debian.org):++- `/usr/libexec/flatpak-session-helper` (`org.freedesktop.Flatpak` on the session bus, user unit+ `flatpak-session-helper.service`): host command execution (`flatpak-spawn --host`) for apps+ allowed to talk to that name, and the `/run/host/monitor` files;+- `/usr/libexec/flatpak-portal` (`org.freedesktop.portal.Flatpak`, user unit+ `flatpak-portal.service`): sub-sandboxes (`flatpak-spawn`, used by zypak for Chromium/Electron);+- `/usr/libexec/flatpak-system-helper` (system bus, `flatpak-system-helper.service`, root, polkit):+ system-wide installs;+- `/etc/profile.d/flatpak.sh`, `/etc/X11/Xsession.d/20flatpak` and+ `/usr/lib/systemd/user-environment-generators/60-flatpak`: add the export folders to+ `XDG_DATA_DIRS`. LordOS's launcher reads two fixed folders and ignores `XDG_DATA_DIRS`, so these+ change nothing there.++LordOS's package engine installs Recommends only when asked (`pkg-install … --recommends`,+[PACKAGES.md](PACKAGES.md)), so turning Flathub on would not pull `xdg-desktop-portal` in. That+matters: lord-server already owns `org.freedesktop.portal.Desktop` on the session bus for the+Settings portal (`server/src/ui/portal.c`), and `tests/fwlinux/screen.sh` depends on no screen-cast+portal being installed.++## Problem 1: identity and the firewall++### Facts++- **Checked (flatpak 1.16.6, `common/flatpak-run.c`, `flatpak_run_in_transient_unit`).** Before it+ starts the D-Bus proxy, `flatpak run` connects to `/run/user/<getuid()>/systemd/private` (the path+ is built from the uid, not from `XDG_RUNTIME_DIR`) and calls `StartTransientUnit` for+ `app-flatpak-<escaped id>-<instance id>.scope` with its own pid. If the socket isn't there or the+ call fails, it logs "Failed to run in transient scope" at info level and **goes on**: "nothing+ really depends on it".+- **Checked (LordOS).** The user manager has PID 1 do that move, which only checks the uid+ ([FIREWALL.md](FIREWALL.md), "Escape via `systemd-run --user`"). So a `flatpak run` started inside+ `app-lordos-<id>.scope` would leave it for `user@<uid>.service/app.slice/…`. There+ `lord-netperm` finds no app scope and applies the per-user union: restriction-only, so not a+ hole, but the app loses its own rules, its counters in the Monitor and its device restrictions,+ and its traffic isn't attributed.+- **Checked (flatpak-portal.c).** `flatpak-portal` (D-Bus activated, under `user@`) runs+ sub-sandboxes as its own children with `flatpak run --parent-pid=…`; they land under `user@` the+ same way, whatever LordOS does with the parent.+- **Checked (flatpak-run.c).** bubblewrap is started with `--unshare-user --disable-userns` (when+ unprivileged) and `--unshare-pid`. A process's cgroup doesn't change across namespaces, so+ `lord-netperm`'s programs (`bpf_get_current_ancestor_cgroup_id`) and `sec/appid.c` find a+ Flatpak app by its scope exactly as they find a Linux app, as long as it stays in it.++### Options++**A. Let Flatpak make its scope and recognise `app-flatpak-<id>-*.scope` under `user@` as+`flatpak:<id>`.** No launcher change. *Rejected:* it is an exemption by identity under `user@`,+which `AGENTS.md` forbids. The user (and any unsandboxed app of theirs) controls that manager:+`systemd-run --user --scope --unit=app-flatpak-org.mozilla.firefox-1.scope <cmd>` would give any+process another app's rules and take it out of the union. Two such attempts were already beaten+(`docs/SECURITY-REVIEW-0.8.0.md` #15 and #37).++**B. Start Flatpak apps in a root-owned LordOS scope, in a view without the systemd user socket.**+The launcher's child enters `app-lordos-fp-<id>.scope` through `lord-sessiond`'s placement service+(as every Linux app does today), then builds a view with LordOS's own code+(`sandbox_files_isolate`: user, mount, PID and IPC namespaces) whose runtime folder contains only+the sockets Flatpak is meant to use, never `systemd/`. `flatpak run`'s transient-scope call fails,+and the app, its D-Bus proxy and every process it forks stay in the root-owned scope, where the+user can't move them (every `cgroup.procs` there is root's). *Trade-offs:* every Flatpak launch+needs unprivileged namespaces and the view (the launcher already requires them for restricted+Linux apps); bubblewrap then nests its own user namespace inside LordOS's (allowed by the kernel,+**Unverified** under LordOS's view); a private runtime folder per launch means Flatpak's per-app+`$XDG_RUNTIME_DIR/.flatpak/<id>` state (shared `/tmp` between instances, `flatpak ps`) isn't seen+from outside, unless the launcher binds a per-app folder into the view (open question 4).++**C. Let Flatpak move the app, then have root move it back.** A new request to `lord-sessiond`'s+placement service ("reclaim this pid into that scope"), checked against the pid lord-server+started. *Rejected:* `AGENTS.md` says not to add requests to that service or place arbitrary+pids, and the app runs under `user@` until it is moved back.++**Recommendation: B.** The firewall id is `flatpak:<id>`; `fw_app_canon`, `lord-netperm`'s scope+scan (`netperm.c`), `sec/appid.c`, the PipeWire guard (`sec/pwguard.c`), the Monitor+(`ui/js_monitor.c`) and `sec/restrict.c` learn the `app-lordos-fp-` prefix the way they learned+`app-lordos-lpk-`. The launcher's `valid_id` already refuses desktop ids starting with `lpk-`; it+would refuse `fp-` too, so no `.desktop` can take a Flatpak app's identity.++The view (Design) for a Flatpak app:++| Item | Unrestricted Flatpak app | Device-restricted (no-mic, no-camera, no-usb, no-bluetooth) | no-files |+|---|---|---|---|+| runtime folder | Wayland socket, `pipewire-0`, `pulse/native`, the session `bus` | Wayland, `pipewire-0`, `pulse/native` (no bus, as Linux apps) | same as device-restricted |+| `systemd/`, other agents | never | never | never |+| home | as is (Flatpak exposes only what its arguments allow) | as is | empty tmpfs with only `~/.var/app/<id>` (rw), `~/.local/share/flatpak` (ro) and the opened file |+| `/tmp`, `/var/tmp`, `/dev/shm`, devpts | private | private | private |+| Landlock | scoping only (`sandbox_apply_scope`: abstract sockets, signals) | scoping only | scoping only, **not** the file rules (see below) |+| X display | only if the app declares `x11`/`fallback-x11` and isn't restricted | none | none |++Giving the session bus to an unrestricted app's `flatpak run` is safe only because the app itself+reaches it through Flatpak's filtering proxy (`xdg-dbus-proxy`), never directly: LordOS always adds+`--nosocket=session-bus` (see "Never granted"). A restricted app has no bus, so `flatpak run` starts+no proxy (Checked: `flatpak_run_add_session_dbus_args` returns without one when there is no bus+socket), and the app has no portals, notifications or other D-Bus services, exactly the cost Linux+apps pay today.++**Why scoping-only Landlock.** Landlock's file rules forbid `mount` and `pivot_root` for any domain+that handles file access, and bubblewrap needs both, so `sandbox_apply_files` would make every+Flatpak app fail to start. A domain with only Landlock's scoping (ABI 6) handles no file access,+and Landlock's documentation ties the mount restriction to file-system restrictions, so bubblewrap+should still be able to mount inside it. **Unverified** (the kernel's `security/landlock/fs.c` was+not read for this review): the first thing to test.++## Problem 2: the launcher++### Facts++- **Checked.** `flatpak install` writes a rewritten `.desktop` to+ `~/.local/share/flatpak/exports/share/applications` (user) or+ `/var/lib/flatpak/exports/share/applications` (system). Its `Exec` is `/usr/bin/flatpak run+ --branch=… --arch=… --command=… [--file-forwarding] <id> [@@ %f @@]`.+- **Checked.** LordOS's launcher (`server/src/apps.c`) lists `.desktop` files only from+ `~/.local/share/applications` and `/usr/share/applications`, runs their `Exec` without a shell,+ and refuses files written from JS (`lord.fs` denies those folders). The user's export folder is+ in the home folder: anything running as the user can write a file there with any `Exec`.+- **Checked (flatpak-run.c, `forward_file`).** `--file-forwarding` hands a file to the app through+ the document portal (`org.freedesktop.portal.Documents`, a FUSE file system). Without it,+ `flatpak run` logs "Can't get document portal" and passes the path unchanged, which the app can+ open only if its sandbox already sees it.++### Options++**A. Add the two export folders to the launcher's list and run their `Exec` lines.** Smallest+change. *Rejected:* a third and fourth folder whose `Exec` is run as is, one of them user-writable+and unknown to `lord.fs`'s deny list; the command line would be whatever the file says, so LordOS's+arguments (identity, restrictions, never-granted permissions) couldn't be guaranteed.++**B. A Flatpak launch path that takes only an app id and builds the command line in C.**+`lord.apps.launchFlatpak(id)` and `lord.apps.launchFlatpakWith(id, path)` (names to settle). The+id must:++- pass Flatpak's own name rules (at least three dot-separated elements of `[A-Za-z0-9_-]`, not+ starting with a digit, at most 255 bytes) and LordOS's scope name limit (`cgroup_scope_name_ok`:+ 62 bytes for the id part; see open question 1);+- be an installed app: `~/.local/share/flatpak/app/<id>/current/active/metadata` (user) or+ `/var/lib/flatpak/app/<id>/current/active/metadata` (system, read-only use), opened without+ following links outside that tree.++The argv is fixed in C: `/usr/bin/flatpak` (root-owned, not writable by others, as the Xwayland+rule), `run`, `--arch=<native>`, `--branch=<the active branch read from the installation>`,+LordOS's generated context options (next sections), the id, and with "Open with" one path after+it. The `.desktop` export is read only for the name, icon, `MimeType` and `Categories`, never for+`Exec`. "Open with" follows `launchWith`'s rules (realpath in the home folder or the user's+mounts, only apps with `MimeType`) and, instead of the document portal, adds+`--filesystem=<that real path>` so the sandbox sees exactly that file (**Unverified** for single+files: to test). Desktop actions are not offered in+phase 1 (their `Exec` lines are app arguments LordOS would have to validate).++**C. Run Flatpak apps from the Store only (no launcher, no Dock).** *Rejected:* the Dock, search+and "Open with" are where apps are opened; a second launch path just for the Store would be the+same exception with a worse user experience.++**Recommendation: B.** The Dock pins them as a new typed id (`flatpak:<id>`, `sdk/dockmodel.js`),+and `sdk/wayland.js` maps their windows (Wayland `app_id` is normally the Flatpak id) to the same+entry. The orphaned-grandchild, log, signal and fd hygiene of `launch()` stays as it is.++## Problem 3: permissions++### Facts (Checked, `common/flatpak-context.c`)++An app's `metadata` `[Context]` group declares:++| Key | Values in 1.16 |+|---|---|+| `shared` | `network`, `ipc` |+| `sockets` | `x11`, `wayland`, `fallback-x11`, `pulseaudio` (since 1.8 it also bind-mounts `/dev/snd`), `session-bus`, `system-bus`, `ssh-auth`, `pcsc`, `cups`, `gpg-agent`, `inherit-wayland-socket` |+| `devices` | `dri`, `all`, `kvm`, `shm`, `input`, `usb` |+| `features` | `devel`, `multiarch`, `bluetooth`, `canbus`, `per-app-dev-shm` |+| `filesystems` | `home`, `host`, `host-os`, `host-etc`, `xdg-*` folders, `~/path`, `/path`, each with `:ro`, `:rw` or `:create` |+| `[Session Bus Policy]`, `[System Bus Policy]` | `<name>=see|talk|own` |+| `[Environment]` | variables |++- The same options exist on `flatpak run` (`--share`, `--unshare`, `--socket`, `--nosocket`,+ `--device`, `--nodevice`, `--allow`, `--disallow`, `--filesystem`, `--nofilesystem`,+ `--talk-name`, `--no-talk-name`, `--own-name`, `--system-talk-name`, `--system-no-talk-name`,+ `--env`, `--unset-env`…). `flatpak_run_app` merges the metadata, then the system and user+ override files, then **the command line last**: LordOS's options win over everything, including+ `~/.local/share/flatpak/overrides/<id>`, which any unsandboxed process of the user can write.+- `--nofilesystem=<path>` for a path not granted becomes a tmpfs over it+ (`flatpak_exports_add_path_expose_or_hide`, mode NONE), so a folder can be hidden inside a+ granted `home`. Flatpak itself always hides `~/.local/share/flatpak` and other apps'+ `~/.var/app/*`.+- Every app may call any `org.freedesktop.portal.*` name through its proxy+ (`--call=org.freedesktop.portal.*=*` in `flatpak-run-dbus.c`). Whether `--no-talk-name` overrides+ that wildcard is **Unverified**; LordOS doesn't rely on it.+- The Wayland side: Flatpak creates a `wp_security_context_v1` listener when the compositor+ offers it. LordOS's compositor doesn't (checked: no reference in `server/src/wl`), so Flatpak+ apps connect to the normal Wayland socket like any Linux app.++### What LordOS never grants (Design, fixed in C)++Whatever the app declares, the launcher always adds:++| Option | Why |+|---|---|+| `--nosocket=session-bus` | the unfiltered bus reaches the systemd user manager (`systemd-run --user`) and the session helper |+| `--no-talk-name=org.freedesktop.Flatpak` | `flatpak-spawn --host`: any command, unsandboxed, outside the scope |+| `--no-talk-name=org.freedesktop.systemd1` | units and transient scopes outside the scope |+| no `--own-name` of a name lord-server serves (`org.freedesktop.Notifications`, `org.freedesktop.portal.Desktop`) | impersonating LordOS's services |+| `--nofilesystem` (hide) for `~/.config/lordos`, `~/.local/share/lordos`, `~/.cache/lordos`, `~/.local/share/applications`, `~/.config/autostart`, `~/.config/systemd`, `~/.config/environment.d`, `~/.local/bin` | the folders `fsops_protected()` and the launcher's grant rules keep from every app: rules, permissions, launchers, autostart, units |+| `--filesystem=<file>:ro` for `~/.bashrc`, `~/.profile`, `~/.bash_profile`, `~/.zshrc` (those that exist) | shell startup files run outside any sandbox at the next login |++`org.freedesktop.portal.Flatpak` (sub-sandboxes) can't be refused reliably by an option, so in+phase 1 LordOS masks `flatpak-portal.service` (see "Exceptions to approve", E5): with no owner and+no activation the name can't be called. A user who unmasks it in their own manager only loses+per-app identity for those sub-sandboxes (they fall under the `user@` union), never a restriction.++The table is **Design**: whether each hidden path really disappears inside a sandbox granted+`home` or `host` is part of the test plan.++### LordOS's restrictions on a Flatpak app (Design)++The existing restrictions of Settings → Privacy apply to `flatpak:<id>` with the same enforcement+as for Linux apps, because the app stays in its scope. Where Flatpak has a matching option LordOS+adds it as well, as defence in depth (the kernel path is the boundary, not bubblewrap):++| Restriction | Enforced by (unchanged LordOS code) | Also added to `flatpak run` |+|---|---|---|+| network rules, no-internet, no-LAN, no-network | `lord-netperm` cgroup programs on the scope | `--unshare=network` for no-network |+| no camera | `cgroup/dev` (V4L2) + PipeWire guard | — |+| no USB | `cgroup/dev` | `--nodevice=usb` |+| no Bluetooth | `cgroup/lsm_socket_create` | `--disallow=bluetooth` |+| no microphone | `cgroup/dev` (ALSA capture nodes) + PipeWire guard | — (`--nosocket=pulseaudio` would also take the sound output) |+| no screen capture | no capture protocol, no screen-cast portal, `/dev/fb*` denied | — |+| no notifications | `hw/notifyd.c`: the caller's pid is the app's `xdg-dbus-proxy`, which `flatpak run` starts inside the scope, so its cgroup is the app's | — |+| no access to your files | LordOS's view (home is a tmpfs with only `~/.var/app/<id>`), see Problem 1 | `--nofilesystem=home --nofilesystem=host` |++**No access to your files is the one restriction whose enforcement changes.** For a Linux app it+is the view plus Landlock's file rules; for a Flatpak app Landlock's file rules can't be used+(bubblewrap must mount), so it is the view alone: a mount namespace whose home is an empty tmpfs,+built by LordOS's code, plus Flatpak's own options inside. Paths outside the home (`/media`,+`/run/media`, other users' homes, `/mnt`) are also hidden in the view by tmpfs mounts (Design),+because without Landlock nothing else would deny them. This is weaker than the Linux-app version+in one respect: Landlock would also have denied files reachable through an fd passed in or a bind+the view forgot. Settings → Privacy says so for Flatpak apps.++**The PipeWire guard and pid namespaces (Unverified).** A Flatpak app's native PipeWire clients+are identified by `pipewire.sec.pid` (socket credentials, translated to PipeWire's namespace), so+the guard finds the scope. Its PulseAudio clients go through `pipewire-pulse`, where the guard+trusts `application.process.id` only for a process in its own PID namespace, and a Flatpak app+reports the pid from inside bubblewrap's namespace. The guard would then treat it as unidentified:+restricted while a restricted app runs (fail closed), which could take the microphone from an+unrestricted Flatpak app in that time. The ALSA capture nodes are still denied in the kernel either+way. To measure on the VM (test 9).++### Portals++LordOS runs no `xdg-desktop-portal`; lord-server serves `org.freedesktop.portal.Settings` itself.++**A. Install `xdg-desktop-portal` and write a LordOS backend** (`org.freedesktop.impl.portal.*`:+FileChooser, Screenshot, ScreenCast, Camera…). The frontend identifies Flatpak apps (from+`/.flatpak-info` of the caller), keeps the permission store and runs the document portal.+*Trade-offs:* a large GLib daemon under `user@` (outside any LordOS scope) that decides app+identity and brokers files; it wants the `org.freedesktop.portal.Desktop` name lord-server holds+(the Settings portal would move to a backend); its ScreenCast and Camera frontends hand out+PipeWire streams, which would break the "no Linux app can copy the screen" claim the moment a+backend exists.++**B. Serve the needed frontend interfaces in lord-server, on the name it already owns.**+FileChooser (LordOS's own dialog, `fs.openFile`-style), OpenURI, Notification, Inhibit, next to+Settings. The caller is identified as notifyd does it today: the bus's+`GetConnectionUnixProcessID`, then that pid's cgroup (the proxy's scope), never a file the app can+write. ScreenCast, Screenshot and Camera are not offered. *Trade-offs:* a new D-Bus surface in+lord-server with untrusted callers; FileChooser for a sandboxed app needs a way to expose the+chosen file after start, which is the document portal's FUSE file system (Debian's+`xdg-document-portal` is part of the `xdg-desktop-portal` package) or a LordOS equivalent.++**C. No new portals in phase 1.** Apps reach only the Settings portal (dark mode, accent, fonts).+GTK 4 and Qt fall back to their own in-process file dialogs, which show only what the sandbox sees+(**Unverified** per toolkit).++**Recommendation: C for 0.8.6, B later** with its own review (E8 below is not requested now). The+Store says which apps need portals to be useful (declares no `home`/`host` file access and expects+FileChooser).++### Showing them: the Store and Settings (Design)++- **Before installing**, an app's page lists its declared `[Context]` in plain language (network,+ your files: home / whole computer / specific folders, devices: GPU / all devices / USB / webcam via+ `all`, sound, X11, D-Bus names grouped as "talks to other apps"), and next to each one what LordOS+ changes ("never granted on LordOS", "hidden: LordOS settings and launchers"). The metadata comes+ from `flatpak remote-info --show-metadata` (one of the closed commands below), parsed in C with a+ strict key-file reader into a fixed set of flags; unknown keys are shown as "other".+- Flathub's `verified` flag and licence come from the appstream data (see Problem 4). An app that+ asks for `org.freedesktop.Flatpak`, the unfiltered session bus or `host` says so in red before+ install, and that LordOS removes it (so it may not work).+- **Settings → Privacy** lists Flatpak apps with the same restrictions as Linux apps, labelled+ "Flatpak". A per-app editor for Flatpak's own permissions (turning a declared one off) is a later+ phase: it would add options from a validated table, never free text.+- **Monitor** shows `flatpak:<id>` with the app's appstream name and icon; its processes appear as+ `bwrap` and the app's binaries inside the scope.++## Problem 4: installing++### Facts++- **Checked (live, 2026-10-27).** `https://dl.flathub.org/repo/flathub.flatpakrepo` gives+ `Url=https://dl.flathub.org/repo/` and a `GPGKey` whose primary key is `rsa4096`, fingerprint+ `6E5C 05D9 79C7 6DAF 93C0 8135 4184 DD4D 907A 7CAE`, "Flathub Repo Signing Key+ <[email protected]>", **expiring 2027-06-14** (signing subkey `54A6 CDDD 8919 FB20 4200 D8AC+ 5627 02E9 E3ED 7EE8`, same expiry).+- **Checked (live).** The repository serves `summary` + `summary.sig` (12.7 MB, x86_64 refs only,+ including `appstream/x86_64` and `appstream2/x86_64`) and the indexed `summary.idx` ++ `summary.idx.sig` whose sub-summaries include `x86_64`, `aarch64` and the **subsets** `floss-*`,+ `verified-*` and `verified_floss-*`.+- **Checked (flatpak-dir.c, remote-add).** `flatpak remote-add --subset=<name>` restricts a remote+ to a subset, and the appstream branch then becomes `appstream2/<subset>-<arch>`. A signed summary+ may carry `xa.gpg-keys`, which `flatpak_dir_update_remote_configuration` uses to update the+ remote's keys: Flathub can roll its key forward through a summary signed with the current one.+- **Checked.** OSTree's summary and commits are GPG-signed (detached OpenPGP signatures inside+ GVariant), objects are content-addressed by SHA-256. Flatpak verifies them through libostree and+ GPGME. LordOS's package engine has its own OpenPGP and RSA code (`pkg/pgp.c`, `pkg/crypto.c`) for+ clear-signed `InRelease` files, but no GVariant or OSTree reader.+- **Checked.** `flatpak --user` installs into `~/.local/share/flatpak` with no root and no system+ helper. The system helper (root, polkit) is used only for `--system`; LordOS doesn't install+ polkit.++### Options++**A. lord-server runs `flatpak --user` for a closed list of commands, in its own firewall+component.** Flatpak does the network, TLS, OSTree and signature checks itself (libostree ++GPGME). LordOS controls which commands run, their arguments, their scope and what it reads back.+*Trade-offs:* a third-party program doing network and parsing as the user, not inside+`sandbox_apply_helper` (it must write `~/.local/share/flatpak` and runs bubblewrap for+`apply_extra` and triggers); its trust store (`~/.local/share/flatpak/repo/flathub.trustedkeys.gpg`)+is user-writable, as is everything else in the home folder.++**B. LordOS's own OSTree client in a sandboxed helper** (GVariant parser, detached OpenPGP+signatures in `pgp.c`, object fetch and checkout), Flatpak used only to run. *Trade-offs:* the+strongest control and no third-party network code, but several weeks of work, and installing+still has to produce a layout `flatpak run` accepts. Not for 0.8.6.++**C. System-wide installs through the admin helper.** *Rejected:* the roadmap asks for per-user+installs and no new admin action; it would also need the system helper or root-run `flatpak`.++**Recommendation: A for 0.8.6, B kept as the later way to make the catalog independent of+Flatpak's code.** The closed list (all with `--user --noninteractive`, argv built in C, no shell,+minimal environment, stdin `/dev/null`, output to a log or parsed strictly):++| Command | Arguments from the UI |+|---|---|+| `remote-add --if-not-exists --from flathub /usr/share/lordos/flatpak/flathub.flatpakrepo` | none (the file ships in the `lordos` package, root-owned) |+| `update --appstream flathub` | none |+| `remote-info --show-metadata flathub <ref>` | a ref |+| `install flathub <ref>` | a ref |+| `update [<ref>]` | optionally a ref |+| `uninstall <ref>`, `uninstall --unused` | a ref |+| `list --app --columns=application,branch,version,origin` | none |++A ref is validated in C: `app/<id>/<native arch>/<branch>`, the id as in Problem 2, the branch+`[A-Za-z0-9._-]{1,64}`. Runtimes are never named by the UI; Flatpak resolves them.++Each command is started like a connector: lord-server forks, the child enters a root-owned+`lordos-net-flathub.scope` (the firewall component `lordos:flathub`, added to+`fw_component_scope`'s fixed list) and execs `/usr/bin/flatpak`. In the Monitor its traffic is+"Flathub", with its own rules, and blocking it says that no Flatpak update arrives meanwhile (as+`lordos:store`). Downloads of `extra-data` (proprietary apps that fetch from their vendor during+install) go through the same scope.++**The pinned key.** The `.flatpakrepo` shipped by LordOS holds Flathub's key above. Because the+key expires on 2027-06-14 and Flathub can roll it through `xa.gpg-keys`, LordOS also ships a new+`.flatpakrepo` in a `lordos` update when Flathub publishes one, with a migration that runs+`remote-modify --gpg-import` for users who have the remote (a per-user `MIGRATIONS` entry in+`sdk/settings.js`; never by hand). Whether to accept key updates delivered by the summary or only+LordOS's is open question 6.++**Which subset.** Design: the default is the whole of Flathub, and the Store marks apps that are+neither verified nor free software. Offering `verified_floss` as a setting is open question 7.++### The catalog (Design)++After `update --appstream flathub`, the signature-checked appstream data sits in+`~/.local/share/flatpak/appstream/flathub/<arch>/active/` (`appstream.xml`, icons in+`icons/64x64` and `icons/128x128`; exact file names **Unverified**). lord-server doesn't parse it+(a 10+ MB XML file from the network): a sandboxed helper does, with `sandbox_apply_helper`, the+file given as an fd, returning a compact index in a sealed memfd (id, name and summary in the+user's language, categories, licence, `flathub::verification::verified`, content rating, icon+file name, sizes), which lord-server validates again before the Store reads it. Which helper+(a new mode of an existing one, or a small new binary) is open question 5; the rule is the same as+for every decoder. The website's API is never used.++### Updates (Design)++- Store → Updates lists Flatpak updates beside Debian ones (`flatpak --user remote-ls --updates`+ would be one more closed command; alternatively compare the installed commit with the appstream+ release, open question 8) and applies them with `update`.+- Runtimes left over are removed with `uninstall --unused` after an update, with the space freed+ shown.+- The hourly check that already exists for blocklists (`sdk/netstatus.jsx`) can drive a daily+ `update --appstream`; no new timer or daemon.+- An app running during an update keeps its old deployment until restarted (Flatpak's behaviour);+ the Store says "restart to finish".++## Dependency policy++`AGENTS.md` and [ARCHITECTURE.md](ARCHITECTURE.md) forbid "bubblewrap, flatpak, firejail or+libseccomp for isolation", and `.lpk` isolation must stay LordOS's own code. The argument for+allowing Flatpak as an **app source**:++1. LordOS doesn't link it: no libflatpak, libostree or bubblewrap code in any LordOS binary.+ lord-server only executes `/usr/bin/flatpak` with fixed argv (E1, E3).+2. It isn't installed by default; it arrives as a Debian package the user chooses in the Store,+ like the Commercial apps, and the page says what it adds (about the size: **Unverified**,+ measured in test 1; Flathub runtimes add hundreds of MB each).+3. LordOS's boundaries for a Flatpak app are LordOS's: the root-owned scope, `lord-netperm`'s+ programs, the PipeWire guard, notifyd and the launcher's view. If bubblewrap failed open, the app+ would still be held by every LordOS restriction the owner set, exactly like an unsandboxed Linux+ app. Flatpak's sandbox adds to that; LordOS's guarantees don't depend on it.+4. `.lpk` apps, sysapps and helpers keep `sec/sandbox.c` and nothing changes for them.++What it costs that the policy was protecting: a large amount of third-party C (Flatpak, OSTree,+GPGME/GnuPG, xdg-dbus-proxy, bubblewrap) runs as the user when Flathub is on, and Flatpak's network+code runs outside LordOS's helper sandbox (Problem 4). The wording to approve is E4.++The root parts of the package are not used: LordOS masks `flatpak-system-helper.service` (E5), so+installing Flathub adds no root service and no polkit actions are reachable (polkitd isn't installed;+the mask makes that explicit).++## Exceptions to approve++Each needs the maintainer's approval before code, in the same way as the existing launcher and+network exceptions:++- **E1. The Flatpak launch path** (Problem 2, option B). `lord.apps.launchFlatpak(id)` /+ `launchFlatpakWith(id, path)`: only a validated id of an installed Flatpak app (user or system+ installation), only `/usr/bin/flatpak` (root-owned, not writable by others), argv built in C+ from a fixed set (`run`, `--arch`, `--branch` read from the installation, LordOS's restriction and+ never-granted options from fixed tables, the id, and for `With` one real path in the home folder+ or the user's mounts with its `--filesystem` grant). Never an `Exec` line from an export, never+ caller arguments, no shell. The child enters its scope and builds the view (E2) before exec;+ failing either, it doesn't launch.+- **E2. The identity `flatpak:<id>` and the scope name `app-lordos-fp-<id>.scope`**, created by the+ existing placement request (no new request type), and a launcher view variant that keeps the+ session bus socket (for unrestricted Flatpak apps only) and never contains `systemd/`. Desktop+ ids starting with `fp-` are refused.+- **E3. The closed list of `flatpak --user` management commands with network** (Problem 4,+ option A) in `lordos-net-flathub.scope` (`lordos:flathub`): the table above and nothing else; refs+ validated in C; no URL, remote name, key, file or option from the UI. Flatpak's own TLS and+ signature checks are not relaxed by any option (no `--no-gpg-verify`, no `--from` other than the+ shipped file).+- **E4. Dependency policy wording.** "Flatpak (and with it bubblewrap, OSTree and+ xdg-dbus-proxy) may be installed from the Store as an app source and is run only through E1 and+ E3; it is never linked, never installed by default and never used for LordOS's own isolation."+- **E5. Masking Flatpak's services**: the `lordos` package ships `/etc/systemd/system/+ flatpak-system-helper.service` and `/etc/systemd/user/flatpak-portal.service` as links to+ `/dev/null` (harmless while Flatpak isn't installed). This is a packaging change with a+ migration (`packaging/migrations/`), not an admin action.+- **E6. `lord.fs` deny list**: `~/.local/share/flatpak` (installations, the trusted key ring,+ override files and exports) is added to `fsops_protected()`, since the system reads it to launch+ and install.+- **E7. A sandboxed parser for Flathub's appstream data** (`sandbox_apply_helper`, file as an fd,+ sealed memfd back, validated again in lord-server), whichever binary hosts it.++Not requested now: **E8**, lord-server serving more `org.freedesktop.portal.*` interfaces (portal+option B), which gets its own review in a later phase.++## Device restrictions, the session bus and `no-files` (Design, summary)++- A device-restricted Flatpak app (no-mic, no-camera, no-usb, no-bluetooth) gets the view without a+ session bus, like a Linux app: `flatpak run` starts no D-Bus proxy, so the app has no portals,+ no notifications, no tray, no MPRIS and no a11y bus. Some apps will refuse to start (as Xfce's+ Ristretto does for Linux apps). Settings → Privacy says it, as it does today.+- `no-files` uses the view's empty home with `~/.var/app/<id>` (rw) and `~/.local/share/flatpak`+ (ro, needed by `flatpak run`), plus `--nofilesystem=home --nofilesystem=host`. Not Landlock's+ file rules (see Problem 1).+- A restriction set while the app runs applies at once for everything the kernel enforces, and at+ the next launch for the view (files, bus), as for Linux apps.+- Without Landlock ABI 6 a restricted Flatpak app is not started (`apps.restrictKernel`), as for+ Linux apps. Without unprivileged user namespaces no Flatpak app can start at all (bubblewrap+ needs them), and the Store says so before installing Flatpak.++## Phased plan++**Phase 1, 0.8.6 (if E1–E7 are approved):**++1. Store → "Flathub" switch: installs `flatpak` (no Recommends), runs `remote-add` from the shipped+ file. Masks per E5. x86-64 only.+2. Catalog: `update --appstream`, the sandboxed parser, a Flathub section in Discover and search,+ app pages with declared permissions and LordOS's changes.+3. Install, uninstall, update for user installations; Flathub in Store → Installed and Updates.+4. The launch path (E1) with the scope and view (E2), the never-granted table, LordOS's restrictions+ mapped as above; Dock, search, launcher grid and "Open with".+5. Firewall, Monitor, Settings → Privacy for `flatpak:<id>` and `lordos:flathub`.+6. The test plan below, with a list of apps actually tried and how they behaved: only those are+ named on the website and in the paper.++**Phase 2 (0.8.7 or later):**++- LordOS's portal frontends (E8): FileChooser with a document store, OpenURI, Notification,+ Inhibit; identity by cgroup.+- Sub-sandboxes (`org.freedesktop.portal.Flatpak` served by LordOS so `flatpak-spawn` children+ enter the same scope), which Chromium/Electron apps need.+- A session-bus filter for device-restricted apps (shared with Linux apps, already the "next step"+ in FIREWALL.md).+- Per-app Flatpak permission editor in Settings.+- `wp_security_context_v1` in the compositor, so Wayland clients from Flatpak are known by+ their sandbox engine and app id.+- aarch64 / Raspberry Pi 5 (16 KB pages: some runtimes or apps may not run; **Unverified**).+- Option B of Problem 4 (LordOS's own signed summary and appstream reader).++## Test plan (VM, x86-64 Debian 13 with LordOS)++Each step records the commands, the output and a screenshot (`screendump`) before anything is+claimed; packages installed for it go into `VM-SETUP.md`.++1. Install `flatpak` through the Store (no Recommends): which packages, how much disk; check+ `xdg-desktop-portal` was not installed and `screen.sh`'s portal check still passes; the two masked+ units show as masked.+2. `remote-add` from the shipped file: the remote's key fingerprint equals the pinned one;+ `update --appstream` runs in `lordos-net-flathub.scope` (its row in Monitor → Network); blocking+ `lordos:flathub` makes it fail with a firewall denial.+3. Bubblewrap under LordOS's view: `flatpak run` of a small app (e.g. a GTK 4 app from Flathub)+ inside the view with scoping-only Landlock starts; the same with `sandbox_apply_files` fails (to+ confirm the reasoning in Problem 1).+4. Identity: after launch, `/proc/<pid>/cgroup` of the app, its `xdg-dbus-proxy` and its children+ is `…/app-lordos-fp-<id>.scope`; `flatpak run --verbose` logs the failed transient scope; nothing+ appears under `user@<uid>.service/app.slice/app-flatpak-*`.+5. Firewall: "no internet" on `flatpak:<id>` blocks the app's connections (`denied out tcp …`),+ per-domain rules apply, the Monitor shows its bytes; an escape attempt from inside the app+ (`systemd-run --user`, `flatpak-spawn --host`, `gdbus call` to `org.freedesktop.systemd1`) fails.+6. Never-granted: an app declaring `home` can't read `~/.config/lordos/firewall.json`, can't write+ `~/.local/share/applications` or `~/.config/autostart`, and sees `~/.bashrc` read-only; an app+ declaring `host` likewise. A user override file granting `session-bus` has no effect.+7. no-files: the app sees only `~/.var/app/<id>`; `/media/$USER` and other homes aren't visible;+ "Open with" a file in Documents opens exactly that file.+8. Devices: v4l2loopback camera, a USB device and Bluetooth sockets denied for a restricted app,+ as `tests/fwlinux/devices.sh` and `bluetooth.sh` do for Linux apps.+9. Sound: playback works for an unrestricted app; with no-mic, `parecord` inside the app gets no+ capture and ALSA capture is denied; while a restricted Flatpak runs, check whether an+ unrestricted Flatpak app's microphone is affected (the PipeWire guard question).+10. Notifications: a Flatpak app's notification shows; with no-notifications it is dropped+ (notifyd resolves the proxy's pid to the app's scope).+11. Device-restricted app: starts without a bus; record which apps refuse.+12. Updates: an app with a pending update shows in Store → Updates, updates, and `uninstall --unused`+ frees the old runtime.+13. Apps to try and record (a mix of toolkits and permission profiles): a GTK 4/libadwaita app, a+ Qt/KDE app, an X11-only app (Xwayland), Firefox (its own sandbox inside Flatpak), one Electron app+ (expected to fail or degrade without the Flatpak portal), an app declaring `host`, an app with+ `extra-data`.++## Open questions++1. **Long ids.** The scope name allows 62 bytes for the id part; Flatpak ids may be 255. Refuse+ longer ids in phase 1 (and count how many Flathub apps that excludes from the appstream data), or+ name the scope by a hash and keep a root-readable map?+2. **Sub-sandboxes.** Masking `flatpak-portal` likely breaks most Chromium/Electron apps (zypak).+ Accept that in phase 1 and mark them in the Store, or ship phase 2's own Spawn implementation+ first?+3. **`~/.ssh`, `~/.gnupg` and the `ssh-auth`/`gpg-agent` sockets.** Hide them from Flatpak apps that+ declare `home` by default (as the launcher's grant rules do for Linux apps with no-files), or+ honour the declaration and show it in the Store?+4. **Per-app runtime state.** Bind a persistent per-app `$XDG_RUNTIME_DIR/.flatpak/<id>` into the+ view (shared `/tmp` between an app's instances, `flatpak ps`), or keep it private per launch?+5. **Which binary parses appstream** (E7): a mode of `lord-doc` (which already decodes untrusted+ files), or a small new helper?+6. **Key roll-over.** Accept Flathub's key updates delivered in its signed summary (`xa.gpg-keys`,+ Flatpak's default behaviour), or pin strictly to the key LordOS ships and update it only in+ LordOS releases? The current key expires on 2027-06-14.+7. **Subsets.** Whole Flathub by default, or `verified_floss` by default with the rest behind a+ setting?+8. **Update detection.** One more closed command (`remote-ls --updates`) or LordOS's own comparison+ of installed commits against the appstream data?+9. **Disk use on low-end machines.** Runtimes are large; should the Store warn below a free-space+ threshold, and should Flathub be offered at all on the Raspberry Pi in phase 1?+10. **Flatpak's own seccomp filter** (Flatpak installs one in every sandbox; whether Debian's+ build links libseccomp for it is **Unverified**): it is Flatpak's, inside the app, and LordOS+ never uses it; confirm the wording of E4 covers it.++## References++- Flatpak 1.16.6 source: `common/flatpak-run.c` (`flatpak_run_in_transient_unit`,+ `flatpak_run_add_environment_args`, `forward_file`), `common/flatpak-run-dbus.c`,+ `common/flatpak-context.c`, `common/flatpak-exports.c`, `common/flatpak-dir.c`,+ `portal/flatpak-portal.c`, `app/flatpak-builtins-run.c`, `app/flatpak-builtins-remote-add.c`+ (github.com/flatpak/flatpak, tag 1.16.6).+- Debian: sources.debian.org (flatpak 1.16.6-1~deb13u2, bubblewrap 0.12.0-1~deb13u1),+ `debian/control` of flatpak, `debian/README.Debian` of bubblewrap, packages.debian.org file list+ of `flatpak` (trixie, amd64).+- Flathub: `https://dl.flathub.org/repo/flathub.flatpakrepo`, `summary`, `summary.idx`+ (fetched 2026-10-27).+- LordOS: [FIREWALL.md](FIREWALL.md) ("Linux apps", "Escape via `systemd-run --user`", "LordOS+ components in their own scopes", "Blocklists"), [PRIVACY.md](PRIVACY.md) ("What is isolated+ today", "Root-owned app scopes"), [WAYLAND.md](WAYLAND.md) ("The launcher"),+ [PACKAGES.md](PACKAGES.md), [ARCHITECTURE.md](ARCHITECTURE.md) (dependencies),+ `server/src/apps.c`, `server/src/sec/sandbox.h`, `server/src/sec/cgroup.h`,+ `server/src/remote/cgsup.c`, `server/src/sec/netconn.c`, `server/src/fetch/`,+ `server/src/ui/portal.c`.diff --git a/docs/PAPER-VALIDATION.md b/docs/PAPER-VALIDATION.mdindex d2ceae9..9d689e6 100644--- a/docs/PAPER-VALIDATION.md+++ b/docs/PAPER-VALIDATION.md@@ -141,7 +141,7 @@ State in the 0.8.5 edition (`web/content/paper/paper.en.md`, checked 2026-10-26)| Gap | Covers | Plan ||---|---|---|| A denied connection, tried on the user's machine | §6.6 effective | An app with network access and a temporary rule (Checks) |-| Repeatable performance numbers | §7 | LordBench (0.8.6): idle memory and CPU, boot, frame times, video, app start |+| Repeatable performance numbers | §7 | LordBench (0.8.6, in development: CPU, memory, GPU offscreen, storage, sustained load and the boot time per version are built, `BENCHMARK.md` "Built so far"; idle memory and CPU, frame times under load, video and app start are not) || Rendering, 3D and video on every GPU | §3.2, §7.2–7.3 | The visual test bench below || Every key, the mouse, touchpads, gamepads, and the Wayland protocols | §3.3–§3.4 | The visual test bench below || Real hardware | §10.2 | Reports from System Information (0.8.7) |diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 182e50c..80db094 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -664,7 +664,8 @@ no migration (`UPDATES.md`). What it delivered, each item described in its own d`/media/<user>/`), the password in the keyring, the mount's traffic as its own firewall app.- [ ] **Flatpak and Flathub (0.8.6, approved by the maintainer on 2026-10-27; needs a design- review before code)** — a Flathub section in the Store. Today LordOS neither uses nor integrates+ review before code)** — a Flathub section in the Store. The design review is written (`FLATPAK.md`,+ 2026-10-27) and waits for approval. Today LordOS neither uses nor integratesFlatpak, and its rules keep isolation as LordOS's own code (no bubblewrap/flatpak for `.lpk`). Whathas to be solved so Flatpak apps follow LordOS's security model:- **Identity and the firewall:** `flatpak run` moves the app into its own transient@@ -699,6 +700,10 @@ no migration (`UPDATES.md`). What it delivered, each item described in its own duse; stops on the hardware's trip points and throttling; every result records its conditions;three verdicts (performance against several reference machines, compatibility, stability), nosingle score; results versioned.+ *In development (2026-10-27):* the `lord-bench` helper, CPU, memory, GPU, storage and sustained workloads,+ the thermal, throttle and battery guards, the boot history and System Information → Performance are built+ (`BENCHMARK.md`, "Built so far"); desktop impact, the compositor and video workloads and the Pi 5 and x86 PC+ references are left.- [ ] **Community hardware reports (0.8.7)** — `BENCHMARK.md`. Share on GitHub with the`hardware-report` template (the user submits it, LordOS sends nothing), schema validation andlabels in a workflow, and a tested-hardware catalogue on lordos.org that the Compatibility paneldiff --git a/docs/VM-SETUP.md b/docs/VM-SETUP.mdindex bfc11d7..d3584d6 100644--- a/docs/VM-SETUP.md+++ b/docs/VM-SETUP.md@@ -1685,3 +1685,11 @@ sudo apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-bc bison flex libssl-dev libelf-dev libdw-dev dwarves cpio kmod rsync dpkg-dev debhelper git \qemu-user-static binfmt-support fdisk dosfstools e2fsprogs xz-utils curl gpg util-linux```++## Step — 0.8.6 in development: LordBench on VM 116 (2026-10-27)++See `BENCHMARK.md` ("Built so far"). Built in `~/LordOS-086` (`make -C server`, plus `build/lordbench-cli` to run+it from a terminal) and run from there as `lord`; nothing was installed over `/usr/local/lib/lordos` and no+package was added. The build uses `xz` (xz-utils, already installed: `dpkg-deb` depends on it) to compress the+xz workload's fixed text (`build/gen/lb_corpus.h`). The app was checked in an isolated headless session of that+tree (own `HOME`, `XDG_RUNTIME_DIR` and bus, driven over its `remote.sock`), removed afterwards.diff --git a/docs/sysinfo-performance.png b/docs/sysinfo-performance.pngnew file mode 100644index 0000000..ed4a34dBinary files /dev/null and b/docs/sysinfo-performance.png differdiff --git a/server/mk/lordbench.mk b/server/mk/lordbench.mknew file mode 100644index 0000000..48c6f29--- /dev/null+++ b/server/mk/lordbench.mk@@ -0,0 +1,42 @@+# LordBench (0.8.6, src/bench, docs/BENCHMARK.md "0.8.6 — LordBench"): lord-bench, the sandboxed helper+# that runs the workloads (CPU, memory, GPU offscreen on a render node fd, storage on a scratch fd,+# sustained load), and lord-server's side (lbrun.c: conditions, the quiet wait, thermal and throttle+# guards, the result file; lord.sysinfo.bench in ui/js_hw.c). The helper links libc, QuickJS (one of+# its workloads) and, with GPU=1, Mesa (GBM, EGL, GLESv2); nothing else.+LB_SRV_SRC := src/bench/lbrun.c src/bench/lbcond.c src/bench/lbproto.c src/bench/bench.c+LB_SRV_OBJ := $(LB_SRV_SRC:src/%.c=build/obj/%.o)+$(LB_SRV_OBJ): $(wildcard src/bench/*.h) build/gen/lord_version.h+build/lord-server: $(LB_SRV_OBJ)+build/obj/ui/js_hw.o: src/bench/lbrun.h++# the xz workload's input: a fixed text (src/bench/lbcorpus.c), compressed at build time+build/lbcorpus: src/bench/lbcorpus.c+ @mkdir -p build+ $(CC) $(CFLAGS) $(WARN) -std=c11 -o $@ $<+build/gen/lb_corpus.h: build/lbcorpus+ @mkdir -p build/gen+ ./build/lbcorpus text | xz -9 -T1 --check=crc64 -c | ./build/lbcorpus header > [email protected] && mv [email protected] $@++LB_SRC := src/bench/lbmain.c src/bench/lbwork.c src/bench/lbproto.c src/bench/bench.c src/pkg/crypto.c src/pkg/xz.c \+ src/sec/sandbox.c src/sec/cgroup.c+LB_GL_SRC := $(if $(filter 1,$(GPU)),src/bench/lbgpu.c src/bench/glscene.c)+LB_GL_FLAGS := $(if $(filter 1,$(GPU)),-DLORD_GPU $(shell pkg-config --cflags gbm egl glesv2))+LB_GL_LIBS := $(if $(filter 1,$(GPU)),$(shell pkg-config --libs gbm egl glesv2))+all: build/lord-bench+build/lord-bench: $(LB_SRC) $(LB_GL_SRC) build/obj/ui/stb.o $(QJS_OBJ) build/gen/lb_corpus.h $(wildcard src/bench/*.h) src/sec/sandbox.h src/sec/cgroup.h+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LB_GL_FLAGS) $(WARN) -std=c11 -o $@ $(LB_SRC) $(LB_GL_SRC) build/obj/ui/stb.o $(QJS_OBJ) $(LB_GL_LIBS) -lm -lpthread++# the workloads (short), the record checks, the thermal guard on fake sysfs trees and the boot history+test: build/lordbench-test+build/lordbench-test: tests/lordbench_test.c src/bench/lbwork.c src/bench/lbproto.c src/bench/lbcond.c src/bench/lbrun.c src/bench/bench.c \+ src/pkg/crypto.c src/pkg/xz.c src/hw/jbuf.c src/sec/json.c build/obj/ui/stb.o $(QJS_OBJ) build/gen/lb_corpus.h \+ build/gen/lord_version.h $(wildcard src/bench/*.h)+ @mkdir -p build+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/lordbench_test.c src/bench/lbwork.c src/bench/lbproto.c src/bench/lbcond.c \+ src/bench/lbrun.c src/bench/bench.c src/pkg/crypto.c src/pkg/xz.c src/hw/jbuf.c src/sec/json.c build/obj/ui/stb.o $(QJS_OBJ) -lm -lpthread+ ./$@ || { rm -f $@; exit 1; }+# from a terminal, without a session: build/lordbench-cli quick|full [sustained_s] (needs build/lord-bench)+build/lordbench-cli: tests/lordbench_cli.c src/bench/lbrun.c src/bench/lbcond.c src/bench/lbproto.c src/bench/bench.c src/hw/jbuf.c src/sec/json.c \+ build/gen/lord_version.h $(wildcard src/bench/*.h) build/lord-bench+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/lordbench_cli.c src/bench/lbrun.c src/bench/lbcond.c src/bench/lbproto.c \+ src/bench/bench.c src/hw/jbuf.c src/sec/json.c -lm -lpthreaddiff --git a/server/src/bench/lbcond.c b/server/src/bench/lbcond.cnew file mode 100644index 0000000..cbf03dd--- /dev/null+++ b/server/src/bench/lbcond.c@@ -0,0 +1,275 @@+/* lbcond.c — see lbcond.h. */+#include "lbcond.h"++#include <dirent.h>+#include <limits.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/stat.h>+#include <sys/statfs.h>+#include <sys/sysmacros.h>+#include <unistd.h>++/* a small sysfs/procfs file, one line, trailing newline cut; -1 if missing */+static int rd(const char *root, const char *path, char *out, size_t n) {+ char p[PATH_MAX];+ snprintf(p, sizeof p, "%s%s", root, path);+ FILE *f = fopen(p, "re");+ if (!f) return -1;+ if (!fgets(out, (int)n, f)) out[0] = 0;+ fclose(f);+ out[strcspn(out, "\n")] = 0;+ return 0;+}+static long rdl(const char *root, const char *path, long dflt) {+ char b[64];+ if (rd(root, path, b, sizeof b) || !b[0]) return dflt;+ char *e;+ long v = strtol(b, &e, 10);+ return e == b ? dflt : v;+}++static void thermal(const char *root, LbCond *c) {+ char d[PATH_MAX];+ snprintf(d, sizeof d, "%s/sys/class/thermal", root);+ DIR *dir = opendir(d);+ if (!dir) return;+ struct dirent *e;+ while ((e = readdir(dir))) {+ if (strncmp(e->d_name, "thermal_zone", 12) || strlen(e->d_name) > 20) continue;+ char p[96], type[24] = "";+ snprintf(p, sizeof p, "/sys/class/thermal/%s/type", e->d_name);+ rd(root, p, type, sizeof type);+ snprintf(p, sizeof p, "/sys/class/thermal/%s/temp", e->d_name);+ long t = rdl(root, p, LONG_MIN);+ if (t == LONG_MIN || t < -50000 || t > 150000) continue;+ double tc = t / 1000.0;+ if (tc > c->temp_c) { c->temp_c = tc; snprintf(c->zone, sizeof c->zone, "%s", type); }+ for (int i = 0; i < 16; i++) {+ char tt[24] = "";+ snprintf(p, sizeof p, "/sys/class/thermal/%s/trip_point_%d_type", e->d_name, i);+ if (rd(root, p, tt, sizeof tt)) break;+ snprintf(p, sizeof p, "/sys/class/thermal/%s/trip_point_%d_temp", e->d_name, i);+ long v = rdl(root, p, 0);+ if (v < 30000 || v > 130000) continue; /* no trip, or a placeholder */+ double vc = v / 1000.0;+ if (!strcmp(tt, "passive") && (!c->passive_c || vc < c->passive_c)) c->passive_c = vc;+ if (!strcmp(tt, "critical") && (!c->critical_c || vc < c->critical_c)) c->critical_c = vc;+ }+ }+ closedir(dir);+}++/* without thermal zones (many desktops), the CPU's hwmon sensors: coretemp, k10temp, zenpower */+static void hwmon(const char *root, LbCond *c) {+ char d[PATH_MAX];+ snprintf(d, sizeof d, "%s/sys/class/hwmon", root);+ DIR *dir = opendir(d);+ if (!dir) return;+ struct dirent *e;+ while ((e = readdir(dir))) {+ if (strncmp(e->d_name, "hwmon", 5) || strlen(e->d_name) > 10) continue;+ char p[96], name[24] = "";+ snprintf(p, sizeof p, "/sys/class/hwmon/%s/name", e->d_name);+ if (rd(root, p, name, sizeof name)) continue;+ if (!strcmp(name, "rpi_volt")) { /* the Pi's under-voltage alarm */+ snprintf(p, sizeof p, "/sys/class/hwmon/%s/in0_lcrit_alarm", e->d_name);+ if (rdl(root, p, 0) == 1) { if (c->rpi_throttled < 0) c->rpi_throttled = 0; c->rpi_throttled |= LB_RPI_UV; }+ continue;+ }+ if (strcmp(name, "coretemp") && strcmp(name, "k10temp") && strcmp(name, "zenpower")) continue;+ for (int i = 1; i < 64; i++) {+ snprintf(p, sizeof p, "/sys/class/hwmon/%s/temp%d_input", e->d_name, i);+ long t = rdl(root, p, LONG_MIN);+ if (t == LONG_MIN) { if (i > 2) break; continue; }+ if (t < -50000 || t > 150000) continue;+ if (t / 1000.0 > c->temp_c) { c->temp_c = t / 1000.0; snprintf(c->zone, sizeof c->zone, "%s", name); }+ snprintf(p, sizeof p, "/sys/class/hwmon/%s/temp%d_crit", e->d_name, i);+ long cr = rdl(root, p, 0);+ if (cr >= 30000 && cr <= 130000 && (!c->critical_c || cr / 1000.0 < c->critical_c)) c->critical_c = cr / 1000.0;+ snprintf(p, sizeof p, "/sys/class/hwmon/%s/temp%d_max", e->d_name, i);+ long mx = rdl(root, p, 0);+ if (mx >= 30000 && mx <= 130000 && (!c->passive_c || mx / 1000.0 < c->passive_c)) c->passive_c = mx / 1000.0;+ }+ }+ closedir(dir);+}++static void cpus(const char *root, LbCond *c) {+ char d[PATH_MAX];+ snprintf(d, sizeof d, "%s/sys/devices/system/cpu", root);+ DIR *dir = opendir(d);+ if (!dir) return;+ struct dirent *e;+ double sum = 0;+ int n = 0;+ while ((e = readdir(dir))) {+ if (strncmp(e->d_name, "cpu", 3) || !e->d_name[3] || strlen(e->d_name) > 12 || strspn(e->d_name + 3, "0123456789") != strlen(e->d_name + 3)) continue;+ char p[PATH_MAX];+ snprintf(p, sizeof p, "/sys/devices/system/cpu/%s/cpufreq/scaling_cur_freq", e->d_name);+ long f = rdl(root, p, 0);+ if (f > 0) { sum += f / 1000.0; n++; }+ snprintf(p, sizeof p, "/sys/devices/system/cpu/%s/cpufreq/cpuinfo_max_freq", e->d_name);+ long m = rdl(root, p, 0);+ if (m / 1000.0 > c->freq_max_mhz) c->freq_max_mhz = m / 1000.0;+ static const char *const cnt[] = { "core_throttle_count", "package_throttle_count" };+ for (int i = 0; i < 2; i++) {+ snprintf(p, sizeof p, "/sys/devices/system/cpu/%s/thermal_throttle/%s", e->d_name, cnt[i]);+ long v = rdl(root, p, -1);+ if (v >= 0) { c->throttle_events += (unsigned long)v; c->throttle_known = 1; }+ }+ }+ closedir(dir);+ if (n) c->freq_mhz = sum / n;+ rd(root, "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", c->governor, sizeof c->governor);+}++/* the Pi firmware's get_throttled, wherever the firmware node sits (soc:firmware, axi:firmware…) */+static void rpi(const char *root, LbCond *c) {+ char d[PATH_MAX];+ snprintf(d, sizeof d, "%s/sys/devices/platform", root);+ DIR *dir = opendir(d);+ if (!dir) return;+ struct dirent *e;+ while ((e = readdir(dir))) {+ if (e->d_name[0] == '.' || strlen(e->d_name) > 64) continue;+ char p[256], b[32];+ const char *sub[] = { "", "/soc:firmware", "/axi:firmware" };+ for (int i = 0; i < 3; i++) {+ snprintf(p, sizeof p, "/sys/devices/platform/%s%s/get_throttled", e->d_name, sub[i]);+ if (!rd(root, p, b, sizeof b) && b[0]) {+ char *end;+ unsigned long v = strtoul(b, &end, 16);+ if (end != b) { c->rpi_throttled = (c->rpi_throttled > 0 ? c->rpi_throttled : 0) | (int)(v & 0xf000f); closedir(dir); return; }+ }+ }+ }+ closedir(dir);+}++static void power(const char *root, LbCond *c) {+ char d[PATH_MAX];+ snprintf(d, sizeof d, "%s/sys/class/power_supply", root);+ DIR *dir = opendir(d);+ if (!dir) return;+ struct dirent *e;+ int mains = -1;+ while ((e = readdir(dir))) {+ if (e->d_name[0] == '.' || strlen(e->d_name) > 48) continue;+ char p[128], type[24] = "", st[24] = "";+ snprintf(p, sizeof p, "/sys/class/power_supply/%s/type", e->d_name);+ if (rd(root, p, type, sizeof type)) continue;+ if (!strcmp(type, "Battery")) {+ snprintf(p, sizeof p, "/sys/class/power_supply/%s/scope", e->d_name);+ char scope[16] = "";+ if (!rd(root, p, scope, sizeof scope) && !strcmp(scope, "Device")) continue; /* a mouse's battery */+ snprintf(p, sizeof p, "/sys/class/power_supply/%s/capacity", e->d_name);+ c->battery_pct = (int)rdl(root, p, -1);+ snprintf(p, sizeof p, "/sys/class/power_supply/%s/status", e->d_name);+ rd(root, p, st, sizeof st);+ if (!strcmp(st, "Discharging")) c->on_battery = 1;+ else if (c->on_battery < 0) c->on_battery = 0;+ } else if (!strcmp(type, "Mains") || !strcmp(type, "USB")) {+ snprintf(p, sizeof p, "/sys/class/power_supply/%s/online", e->d_name);+ if (rdl(root, p, 0) == 1) mains = 1;+ else if (mains < 0) mains = 0;+ }+ }+ closedir(dir);+ if (mains == 1 && c->on_battery == 1 && c->battery_pct >= 0) c->on_battery = 0; /* plugged in, reported late */+ if (c->on_battery < 0 && mains >= 0) c->on_battery = !mains;+}++void lb_cond_read(const char *root, LbCond *c) {+ memset(c, 0, sizeof *c);+ c->temp_c = -273;+ c->rpi_throttled = -1;+ c->on_battery = -1;+ c->battery_pct = -1;+ thermal(root, c);+ hwmon(root, c);+ cpus(root, c);+ rpi(root, c);+ power(root, c);+ rd(root, "/sys/firmware/acpi/platform_profile", c->platform_profile, sizeof c->platform_profile);+ for (char *s = c->governor; *s; s++) if (!((*s >= 'a' && *s <= 'z') || *s == '-' || *s == '_')) *s = '_';+ for (char *s = c->platform_profile; *s; s++) if (!((*s >= 'a' && *s <= 'z') || *s == '-' || *s == '_')) *s = '_';+ for (char *s = c->zone; *s; s++) if (!((*s >= 'a' && *s <= 'z') || (*s >= 'A' && *s <= 'Z') || (*s >= '0' && *s <= '9') || *s == '-' || *s == '_')) *s = '_';+}++int lb_cpu_ticks(const char *root, unsigned long long *busy, unsigned long long *total) {+ char line[256];+ if (rd(root, "/proc/stat", line, sizeof line) || strncmp(line, "cpu ", 4)) return -1;+ unsigned long long v[10] = { 0 };+ int n = sscanf(line + 4, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]);+ if (n < 4) return -1;+ unsigned long long t = 0;+ for (int i = 0; i < n && i < 8; i++) t += v[i]; /* guest time is already in user */+ *total = t;+ *busy = t - v[3] - (n > 4 ? v[4] : 0); /* minus idle and iowait */+ return 0;+}++const char *lb_storage_kind(const char *root, const char *path) {+ struct statfs fs;+ struct stat st;+ if (statfs(path, &fs) || stat(path, &st)) return "unknown";+ if (fs.f_type == 0x01021994 /* tmpfs */ || fs.f_type == 0x794c7630 /* overlayfs */) return "ram";+ if (!major(st.st_dev)) return "unknown";+ char p[PATH_MAX], real[PATH_MAX];+ snprintf(p, sizeof p, "%s/sys/dev/block/%u:%u", root, major(st.st_dev), minor(st.st_dev));+ if (!realpath(p, real)) return "unknown";+ /* device-mapper (LUKS, LVM): the first device below it */+ char slaves[PATH_MAX + 8];+ snprintf(slaves, sizeof slaves, "%s/slaves", real);+ DIR *sd = opendir(slaves);+ if (sd) {+ struct dirent *e;+ while ((e = readdir(sd))) if (e->d_name[0] != '.') {+ char q[PATH_MAX + 300];+ snprintf(q, sizeof q, "%s/%s", slaves, e->d_name);+ char r2[PATH_MAX];+ if (realpath(q, r2)) snprintf(real, sizeof real, "%s", r2);+ break;+ }+ closedir(sd);+ }+ /* a partition: its disk is the parent folder */+ char part[PATH_MAX + 12];+ snprintf(part, sizeof part, "%s/partition", real);+ if (!access(part, F_OK)) { char *sl = strrchr(real, '/'); if (sl) *sl = 0; }+ const char *name = strrchr(real, '/');+ name = name ? name + 1 : real;+ if (strstr(real, "/usb")) return "usb";+ if (!strncmp(name, "nvme", 4)) return "nvme";+ if (!strncmp(name, "mmcblk", 6)) return "sd";+ if (!strncmp(name, "vd", 2) || !strncmp(name, "xvd", 3)) return "virtual";+ if (!strncmp(name, "sd", 2)) {+ char vendor[64] = "", q[PATH_MAX + 32];+ snprintf(q, sizeof q, "%s/device/vendor", real);+ FILE *f = fopen(q, "re");+ if (f) { if (!fgets(vendor, sizeof vendor, f)) vendor[0] = 0; fclose(f); }+ if (strstr(vendor, "QEMU") || strstr(vendor, "VMware") || strstr(vendor, "VBOX") || strstr(vendor, "Msft")) return "virtual";+ snprintf(q, sizeof q, "%s/queue/rotational", real);+ f = fopen(q, "re");+ int rot = -1;+ if (f) { if (fscanf(f, "%d", &rot) != 1) rot = -1; fclose(f); }+ return rot == 1 ? "hdd" : rot == 0 ? "ssd" : "unknown";+ }+ return "unknown";+}++const char *lb_cond_stop(const LbCond *start, const LbCond *now, int peak) {+ if (now->temp_c > -270) {+ if (now->passive_c > 0 && now->temp_c >= now->passive_c - 2) return "thermal";+ if (now->passive_c <= 0 && now->critical_c > 0 && now->temp_c >= now->critical_c - 10) return "thermal";+ }+ if (peak) {+ if (start->throttle_known && now->throttle_events > start->throttle_events) return "throttled";+ if (now->rpi_throttled > 0 && (now->rpi_throttled & (LB_RPI_THROTTLED | LB_RPI_CAPPED | LB_RPI_SOFTTEMP))) return "throttled";+ }+ return NULL;+}++int lb_cond_battery_low(const LbCond *c) { return c->on_battery == 1 && c->battery_pct >= 0 && c->battery_pct < 30; }diff --git a/server/src/bench/lbcond.h b/server/src/bench/lbcond.hnew file mode 100644index 0000000..6165f65--- /dev/null+++ b/server/src/bench/lbcond.h@@ -0,0 +1,45 @@+/* lbcond.h — what LordBench records about the machine around a run, and its thermal and power guards+ * (docs/BENCHMARK.md, "Thermal and power safety", "Recorded conditions"). World-readable sysfs and+ * procfs only, read by lord-server (never by lord-bench). Every reader takes a root folder ("" for the+ * real one) so tests can feed fake trees. */+#ifndef LORD_BENCH_LBCOND_H+#define LORD_BENCH_LBCOND_H++#include <stdint.h>++typedef struct {+ double temp_c; /* the hottest thermal zone or CPU hwmon sensor, °C; < -270 unknown */+ double passive_c, critical_c; /* the lowest passive and critical trip points, °C; 0 unknown */+ char zone[24]; /* the hottest zone's type ("x86_pkg_temp", "cpu-thermal", …) */+ unsigned long throttle_events; /* x86 core + package thermal throttle counters, summed */+ int throttle_known; /* 1 if those counters exist */+ int rpi_throttled; /* the Pi firmware's get_throttled bits (-1: no such file) */+ double freq_mhz, freq_max_mhz; /* the average current and the highest maximum cpufreq, 0 unknown */+ char governor[24];+ char platform_profile[24]; /* /sys/firmware/acpi/platform_profile, "" without one */+ int on_battery; /* 1 battery, 0 mains, -1 unknown (no power_supply: a desktop or VM) */+ int battery_pct; /* -1 without a battery */+} LbCond;++void lb_cond_read(const char *root, LbCond *c);++/* the Pi firmware's flags: 0 under-voltage now, 1 frequency capped now, 2 throttled now, 3 soft+ * temperature limit now; bits 16-19 the same since boot */+enum { LB_RPI_UV = 1, LB_RPI_CAPPED = 2, LB_RPI_THROTTLED = 4, LB_RPI_SOFTTEMP = 8 };++/* CPU busy share between two reads of /proc/stat: lb_cpu_ticks fills busy and total */+int lb_cpu_ticks(const char *root, unsigned long long *busy, unsigned long long *total);++/* the kind of device holding the folder `path` is on: "nvme", "sd" (an SD card or eMMC through+ * mmcblk), "ssd", "hdd", "usb", "virtual", "ram" (tmpfs, overlay of the live session) or "unknown" */+const char *lb_storage_kind(const char *root, const char *path);++/* why a run must stop now, or NULL: "thermal" when the temperature is within 2 °C of the passive trip+ * point (or within 10 °C of the critical one when there's no passive), "throttled" when the throttle+ * counters grew or the Pi says it throttles since `start` (only checked when peak = 1) */+const char *lb_cond_stop(const LbCond *start, const LbCond *now, int peak);++/* refused before starting: on battery below 30 % */+int lb_cond_battery_low(const LbCond *c);++#endifdiff --git a/server/src/bench/lbcorpus.c b/server/src/bench/lbcorpus.cnew file mode 100644index 0000000..fbb6712--- /dev/null+++ b/server/src/bench/lbcorpus.c@@ -0,0 +1,59 @@+/* lbcorpus.c — a build tool for LordBench's xz workload (lbwork.c, lb_xz): `lbcorpus text` writes a+ * fixed text of LB_CORPUS_SIZE bytes (words drawn from a fixed list with a fixed seed, so every build+ * gets the same one), and `lbcorpus header` turns its xz-compressed form on standard input into+ * build/gen/lb_corpus.h. Runs at build time only; nothing of it ships. */+#include <stdint.h>+#include <stdio.h>+#include <string.h>++#define LB_CORPUS_SIZE (2u << 20)++static const char *const words[] = {+ "the", "of", "and", "to", "in", "a", "is", "that", "for", "it", "as", "with", "was", "on", "be", "by",+ "this", "are", "from", "at", "or", "an", "which", "not", "but", "all", "can", "has", "were", "one",+ "system", "window", "package", "network", "display", "kernel", "memory", "process", "screen", "file",+ "folder", "session", "desktop", "update", "signature", "repository", "firewall", "permission", "device",+ "frame", "pixel", "layer", "texture", "shader", "buffer", "socket", "thread", "driver", "battery",+ "temperature", "keyboard", "pointer", "camera", "microphone", "printer", "scanner", "language", "font",+ "glyph", "paragraph", "terminal", "command", "archive", "document", "picture", "video", "audio", "stream",+ "measured", "tested", "released", "checked", "signed", "verified", "installed", "started", "stopped",+ "quickly", "slowly", "always", "never", "only", "every", "each", "before", "after", "while", "until",+ "LordOS", "Debian", "Wayland", "compositor", "sandbox", "helper", "manifest", "release", "version",+ "0.8.6", "2026", "1920", "1080", "60", "120", "4096", "65536", "x86-64", "arm64", "/usr/lib", "~/.config",+};++static uint64_t xs(uint64_t *s) { uint64_t x = *s; x ^= x << 13; x ^= x >> 7; x ^= x << 17; return *s = x; }++int main(int argc, char **argv) {+ if (argc == 2 && !strcmp(argv[1], "text")) {+ uint64_t seed = 0x4c6f72644265ull;+ size_t n = 0, line = 0;+ int cap = 1;+ while (n < LB_CORPUS_SIZE) {+ const char *w = words[xs(&seed) % (sizeof words / sizeof *words)];+ char buf[64];+ int k = snprintf(buf, sizeof buf, "%s", w);+ if (cap && buf[0] >= 'a' && buf[0] <= 'z') buf[0] = (char)(buf[0] - 32);+ cap = 0;+ uint64_t r = xs(&seed) % 23;+ if (r == 0) { buf[k++] = '.'; cap = 1; }+ else if (r == 1) buf[k++] = ',';+ char sep = line + (size_t)k > 76 ? '\n' : ' ';+ buf[k++] = sep;+ line = buf[k - 1] == '\n' ? 0 : line + (size_t)k;+ for (int i = 0; i < k && n < LB_CORPUS_SIZE; i++, n++) putchar(buf[i]);+ }+ return 0;+ }+ if (argc == 2 && !strcmp(argv[1], "header")) {+ printf("/* generated by src/bench/lbcorpus.c: LordBench's xz workload input */\n");+ printf("#define LB_CORPUS_SIZE %uu\nstatic const unsigned char lb_corpus_xz[] = {", LB_CORPUS_SIZE);+ int c;+ size_t n = 0;+ while ((c = getchar()) != EOF) printf("%s%d,", n++ % 24 ? "" : "\n", c);+ printf("\n};\n");+ return n ? 0 : 1;+ }+ fprintf(stderr, "usage: lbcorpus text | header < corpus.xz\n");+ return 2;+}diff --git a/server/src/bench/lbgpu.c b/server/src/bench/lbgpu.cnew file mode 100644index 0000000..c7a0d08--- /dev/null+++ b/server/src/bench/lbgpu.c@@ -0,0 +1,175 @@+/* lbgpu.c — LordBench's GPU workloads (docs/BENCHMARK.md, "Workloads", GPU): OpenGL ES 2 offscreen on+ * the render node lord-server opened and passed in (GBM + EGL, a surfaceless context and a framebuffer+ * object of 1920×1080), nothing on screen. Every frame ends with glFinish, so the times are the GPU's.+ * Runs inside lord-bench after its sandbox: Mesa's driver loads from /usr/lib (read-only) and talks to+ * the device only through that fd (DRM ioctls). */+#include "lbgpu.h"+#include "bench.h"+#include "glscene.h"++#include <EGL/egl.h>+#include <EGL/eglext.h>+#include <GLES2/gl2.h>+#include <gbm.h>+#include <stdint.h>+#include <stdlib.h>+#include <string.h>++#define W 1920+#define H 1080++static struct gbm_device *gbm;+static EGLDisplay dpy = EGL_NO_DISPLAY;+static EGLContext ctx = EGL_NO_CONTEXT;+static GLuint fbo, color, depth, quad_prog, layer_tex[8];+static GLint q_pos, q_tex, q_alpha;++static GLuint shader(GLenum type, const char *src) {+ GLuint s = glCreateShader(type);+ glShaderSource(s, 1, &src, NULL);+ glCompileShader(s);+ GLint ok = 0;+ glGetShaderiv(s, GL_COMPILE_STATUS, &ok);+ if (!ok) { glDeleteShader(s); return 0; }+ return s;+}++int lb_gpu_open(int render_fd, BenchGlInfo *info) {+ gbm = gbm_create_device(render_fd);+ if (!gbm) return -1;+ PFNEGLGETPLATFORMDISPLAYEXTPROC get_display = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");+ dpy = get_display ? get_display(EGL_PLATFORM_GBM_KHR, gbm, NULL) : eglGetDisplay((EGLNativeDisplayType)gbm);+ if (dpy == EGL_NO_DISPLAY || !eglInitialize(dpy, NULL, NULL)) return -1;+ const char *ext = eglQueryString(dpy, EGL_EXTENSIONS);+ if (!ext || !strstr(ext, "EGL_KHR_surfaceless_context")) return -1;+ if (!eglBindAPI(EGL_OPENGL_ES_API)) return -1;+ static const EGLint cfg_attr[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE };+ EGLConfig cfg;+ EGLint n = 0;+ if (!eglChooseConfig(dpy, cfg_attr, &cfg, 1, &n) || n < 1) return -1;+ static const EGLint ctx_attr[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };+ ctx = eglCreateContext(dpy, cfg, EGL_NO_CONTEXT, ctx_attr);+ if (ctx == EGL_NO_CONTEXT || !eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) return -1;+ if (bench_scene_init(info)) return -1;+ /* the offscreen target: colour texture + depth */+ glGenFramebuffers(1, &fbo);+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);+ glGenTextures(1, &color);+ glBindTexture(GL_TEXTURE_2D, color);+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, W, H, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color, 0);+ glGenRenderbuffers(1, &depth);+ glBindRenderbuffer(GL_RENDERBUFFER, depth);+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, W, H);+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) return -1;+ /* a textured full-screen quad with an alpha, for fill rate and layers */+ static const char *vs = "attribute vec2 pos; varying vec2 uv; void main(){ uv = pos * 0.5 + 0.5; gl_Position = vec4(pos, 0.0, 1.0); }";+ static const char *fs = "precision mediump float; varying vec2 uv; uniform sampler2D tex; uniform float alpha;"+ "void main(){ vec4 c = texture2D(tex, uv); gl_FragColor = vec4(c.rgb, c.a * alpha); }";+ GLuint v = shader(GL_VERTEX_SHADER, vs), f = shader(GL_FRAGMENT_SHADER, fs);+ if (!v || !f) return -1;+ quad_prog = glCreateProgram();+ glAttachShader(quad_prog, v);+ glAttachShader(quad_prog, f);+ glLinkProgram(quad_prog);+ glDeleteShader(v);+ glDeleteShader(f);+ q_pos = glGetAttribLocation(quad_prog, "pos");+ q_tex = glGetUniformLocation(quad_prog, "tex");+ q_alpha = glGetUniformLocation(quad_prog, "alpha");+ /* eight screen-size layers with different content */+ uint32_t *px = malloc((size_t)W * H * 4);+ if (!px) return -1;+ glGenTextures(8, layer_tex);+ for (int l = 0; l < 8; l++) {+ for (int y = 0; y < H; y++)+ for (int x = 0; x < W; x++) px[y * W + x] = 0xc0000000u | (uint32_t)((x * (l + 1)) & 255) << 16 | (uint32_t)((y + l * 31) & 255) << 8 | (uint32_t)(l * 32);+ glBindTexture(GL_TEXTURE_2D, layer_tex[l]);+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, W, H, 0, GL_RGBA, GL_UNSIGNED_BYTE, px);+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);+ }+ free(px);+ glFinish();+ return glGetError() == GL_NO_ERROR ? 0 : -1;+}++static void quad(GLuint tex, float alpha) {+ static const float P[] = { -1, -1, 1, -1, -1, 1, 1, 1 };+ glUseProgram(quad_prog);+ glActiveTexture(GL_TEXTURE0);+ glBindTexture(GL_TEXTURE_2D, tex);+ glUniform1i(q_tex, 0);+ glUniform1f(q_alpha, alpha);+ glVertexAttribPointer((GLuint)q_pos, 2, GL_FLOAT, GL_FALSE, 0, P);+ glEnableVertexAttribArray((GLuint)q_pos);+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);+}++double lb_gpu_scene(double secs) {+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);+ glEnable(GL_DEPTH_TEST);+ double t0 = bench_now_ms(), end = t0 + secs * 1000;+ long frames = 0;+ do { bench_scene_draw(W, H, (double)frames * 16.667); frames++; } while (bench_now_ms() < end);+ glDisable(GL_DEPTH_TEST);+ return frames * 1000.0 / (bench_now_ms() - t0);+}++/* frames of `layers` blended full-screen quads: frames per second */+static double blend_frames(int layers, double secs) {+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);+ glViewport(0, 0, W, H);+ glDisable(GL_DEPTH_TEST);+ glEnable(GL_BLEND);+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);+ double t0 = bench_now_ms(), end = t0 + secs * 1000;+ long frames = 0;+ do {+ glClear(GL_COLOR_BUFFER_BIT);+ for (int l = 0; l < layers; l++) quad(layer_tex[l % 8], 0.9f);+ glFinish();+ frames++;+ } while (bench_now_ms() < end);+ glDisable(GL_BLEND);+ return frames * 1000.0 / (bench_now_ms() - t0);+}++double lb_gpu_fill(double secs) { return blend_frames(16, secs) * 16 * W * H / 1e6; }+double lb_gpu_layers(double secs) { return blend_frames(8, secs); }++double lb_gpu_upload(double secs) {+ uint32_t *px = malloc((size_t)W * H * 4);+ if (!px) return -1;+ for (size_t i = 0; i < (size_t)W * H; i++) px[i] = (uint32_t)(i * 2654435761u);+ GLuint t;+ glGenTextures(1, &t);+ glBindTexture(GL_TEXTURE_2D, t);+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, W, H, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);+ double t0 = bench_now_ms(), end = t0 + secs * 1000;+ long n = 0;+ do {+ px[n % ((size_t)W * H)] ^= 1;+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, W, H, GL_RGBA, GL_UNSIGNED_BYTE, px);+ glFinish();+ n++;+ } while (bench_now_ms() < end);+ double ms = bench_now_ms() - t0;+ glDeleteTextures(1, &t);+ free(px);+ return n * (double)W * H * 4 / 1e6 / (ms / 1000);+}++void lb_gpu_close(void) {+ if (dpy != EGL_NO_DISPLAY) {+ eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);+ if (ctx != EGL_NO_CONTEXT) eglDestroyContext(dpy, ctx);+ eglTerminate(dpy);+ }+ if (gbm) gbm_device_destroy(gbm);+ dpy = EGL_NO_DISPLAY;+ ctx = EGL_NO_CONTEXT;+ gbm = NULL;+}diff --git a/server/src/bench/lbgpu.h b/server/src/bench/lbgpu.hnew file mode 100644index 0000000..ab7fca1--- /dev/null+++ b/server/src/bench/lbgpu.h@@ -0,0 +1,14 @@+/* lbgpu.h — LordBench's GPU workloads, offscreen on a render node fd (lbgpu.c). */+#ifndef LORD_BENCH_LBGPU_H+#define LORD_BENCH_LBGPU_H++#include "glscene.h"++int lb_gpu_open(int render_fd, BenchGlInfo *info); /* 0, or -1: no usable GLES 2 context */+double lb_gpu_scene(double secs); /* the 3D scene at 1920×1080: frames/s */+double lb_gpu_fill(double secs); /* blended full-screen quads: Mpixel/s */+double lb_gpu_upload(double secs); /* 1920×1080 RGBA texture uploads: MB/s */+double lb_gpu_layers(double secs); /* 8 blended screen-size layers: frames/s */+void lb_gpu_close(void);++#endifdiff --git a/server/src/bench/lbmain.c b/server/src/bench/lbmain.cnew file mode 100644index 0000000..002b7c3--- /dev/null+++ b/server/src/bench/lbmain.c@@ -0,0 +1,185 @@+/* lbmain.c — lord-bench, LordBench's helper (docs/BENCHMARK.md, "0.8.6 — LordBench").+ *+ * lord-server (lbrun.c) launches it from a fixed path next to its own binary, with no arguments, the+ * channel on fd 3 and a minimal environment. The first message (LbGo) says what to run and brings at+ * most two fds lord-server opened: the GPU's render node and a scratch file for the storage test. Then,+ * before any work, it locks itself in with sandbox_apply_helper (sec/sandbox.c, the same as+ * lord-doc's and lord-media's): no network, no exec, no new files, read-only system libraries for Mesa,+ * DRM ioctls only on the fd it was given. It answers only with fixed-size LbMsg records (lbproto.h);+ * lord-server checks each one, watches temperatures and throttling, and kills it to stop. */+#include "lbproto.h"+#include "lbwork.h"+#ifdef LORD_GPU+#include "lbgpu.h"+#endif+#include "../sec/sandbox.h"++#include <errno.h>+#include <signal.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/prctl.h>+#include <sys/resource.h>+#include <sys/socket.h>+#include <sys/syscall.h>+#include <unistd.h>++#define SOCK 3++static void send_msg(uint32_t kind, int id, double value, double aux) {+ LbMsg m = { LB_MAGIC, kind, (uint32_t)id, 0, value, aux };+ if (send(SOCK, &m, sizeof m, MSG_NOSIGNAL) != (ssize_t)sizeof m) _exit(1); /* lord-server is gone */+}++/* runs a measurement `reps` times and reports the median with its spread */+static void measure(int id, int reps, double (*fn)(void *), void *ctx) {+ send_msg(LB_MSG_STEP, id, 0, 0);+ double v[5];+ int n = 0;+ for (int i = 0; i < reps && i < 5; i++) {+ double r = fn(ctx);+ if (r <= 0) { send_msg(LB_MSG_SKIP, id, 0, LB_SKIP_FAILED); return; }+ v[n++] = r;+ }+ double spread, med = lb_median(v, n, &spread);+ send_msg(LB_MSG_RESULT, id, med, spread);+}++typedef struct { int threads; double secs; size_t mb; long hops; } Ctx;+static double w_sha(void *c) { Ctx *x = c; return lb_sha256(x->threads, x->secs); }+static double w_mat(void *c) { Ctx *x = c; return lb_matmul(x->threads, x->secs); }+static double w_xz(void *c) { Ctx *x = c; return lb_xz(x->threads, x->secs); }+static double w_js(void *c) { Ctx *x = c; return lb_js(x->threads, x->secs); }+static double w_copy(void *c) { Ctx *x = c; return lb_mem_copy(x->threads, x->mb, x->secs); }+static double w_triad(void *c) { Ctx *x = c; return lb_mem_triad(x->threads, x->mb, x->secs); }+static double w_lat(void *c) { Ctx *x = c; return lb_mem_latency(x->mb, x->hops); }+#ifdef LORD_GPU+static double w_scene(void *c) { return lb_gpu_scene(((Ctx *)c)->secs); }+static double w_fill(void *c) { return lb_gpu_fill(((Ctx *)c)->secs); }+static double w_upload(void *c) { return lb_gpu_upload(((Ctx *)c)->secs); }+static double w_layers(void *c) { return lb_gpu_layers(((Ctx *)c)->secs); }+#endif++typedef struct { double first, last; int n; } Sus;+static void on_sample(double gflops, double t_s, void *ctx) {+ Sus *s = ctx;+ if (!s->n++) s->first = gflops;+ s->last = gflops;+ send_msg(LB_MSG_SAMPLE, 0, gflops, t_s);+}++static void skip_all(int from, int to, int why) {+ for (int id = from; id <= to; id++) send_msg(LB_MSG_SKIP, id, 0, why);+}++int main(int argc, char **argv) {+ (void)argv;+ if (argc != 1) { fprintf(stderr, "lord-bench: launched by lord-server (no arguments)\n"); return 2; }+ signal(SIGPIPE, SIG_IGN);+ prctl(PR_SET_PDEATHSIG, SIGKILL);+ if (getppid() == 1) return 1;+ prctl(PR_SET_NAME, "lord-bench");+#ifdef SYS_close_range+ syscall(SYS_close_range, SOCK + 1, ~0U, 0);+#endif+ struct rlimit core = { 0, 0 };+ setrlimit(RLIMIT_CORE, &core);+ prctl(PR_SET_DUMPABLE, 0, 0, 0, 0);++ /* the job and its fds */+ LbGo go;+ int fds[2] = { -1, -1 };+ char cbuf[CMSG_SPACE(2 * sizeof(int))];+ struct iovec iov = { &go, sizeof go };+ struct msghdr mh = { .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cbuf, .msg_controllen = sizeof cbuf };+ ssize_t r = recvmsg(SOCK, &mh, MSG_CMSG_CLOEXEC);+ if (r != (ssize_t)sizeof go || go.magic != LB_MAGIC || (go.mode != LB_MODE_QUICK && go.mode != LB_MODE_FULL)) return 1;+ int nfd = 0;+ for (struct cmsghdr *c = CMSG_FIRSTHDR(&mh); c; c = CMSG_NXTHDR(&mh, c))+ if (c->cmsg_level == SOL_SOCKET && c->cmsg_type == SCM_RIGHTS) {+ nfd = (int)((c->cmsg_len - CMSG_LEN(0)) / sizeof(int));+ if (nfd > 2) return 1;+ memcpy(fds, CMSG_DATA(c), (size_t)nfd * sizeof(int));+ }+ int k = 0, gpu_fd = go.flags & LB_GO_GPU ? (k < nfd ? fds[k++] : -1) : -1;+ int disk_fd = go.flags & LB_GO_STORAGE ? (k < nfd ? fds[k++] : -1) : -1;+ long cpus = sysconf(_SC_NPROCESSORS_ONLN);+ int threads = (int)go.threads;+ if (threads < 1 || threads > cpus || threads > 256) threads = cpus > 0 && cpus <= 256 ? (int)cpus : 1;+ int full = go.mode == LB_MODE_FULL;++ if (go.flags & LB_GO_LOW) { /* desktop impact: below everything the user runs */+ setpriority(PRIO_PROCESS, 0, 19);+ syscall(SYS_ioprio_set, 1, 0, (3 << 13)); /* IOPRIO_CLASS_IDLE */+ }+ setenv("MESA_SHADER_CACHE_DISABLE", "true", 1); /* no cache folder: nothing to write */+ static const char *const ro[] = { "/usr/lib", "/usr/lib64", "/lib", "/lib64", "/usr/share", "/etc/ld.so.cache",+ "/sys/dev/char", "/sys/devices", NULL };+ static const int extra[] = { SYS_getcpu, SYS_kcmp, SYS_membarrier, SYS_sched_getparam, SYS_sched_getscheduler,+#ifdef SYS_futex_waitv+ SYS_futex_waitv,+#endif+ -1 };+ SandboxHelperCfg cfg = { .name = "lordos-bench", .ro_paths = ro, .extra_syscalls = extra,+ .allow_ioctl_classes = gpu_fd >= 0 ? SANDBOX_IOCTL_DRM | SANDBOX_IOCTL_DMABUF : 0,+ .mem_max_mb = 2048 };+ int mask = sandbox_apply_helper(&cfg);++ Ctx one = { 1, full ? 1.5 : 0.5, 0, 0 }, all = { threads, full ? 1.5 : 0.5, 0, 0 };+ int reps = 3;+ measure(LB_CPU_SHA1, reps, w_sha, &one);+ measure(LB_CPU_SHAN, reps, w_sha, &all);+ measure(LB_CPU_MAT1, reps, w_mat, &one);+ measure(LB_CPU_MATN, reps, w_mat, &all);+ measure(LB_CPU_XZ1, reps, w_xz, &one);+ measure(LB_CPU_XZN, reps, w_xz, &all);+ measure(LB_CPU_JS1, reps, w_js, &one);+ measure(LB_CPU_JSN, reps, w_js, &all);+ Ctx mem = { threads, full ? 1.5 : 0.5, full ? 128 : 32, 0 };+ measure(LB_MEM_COPY, reps, w_copy, &mem);+ measure(LB_MEM_TRIAD, reps, w_triad, &mem);+ Ctx lat = { 1, 0, 64, full ? 10000000 : 2000000 };+ measure(LB_MEM_LAT, reps, w_lat, &lat);++#ifdef LORD_GPU+ if (gpu_fd >= 0) {+ BenchGlInfo gi;+ if (lb_gpu_open(gpu_fd, &gi) == 0) {+ send_msg(LB_MSG_GPUINFO, 0, !strcmp(gi.kind, "HARDWARE GPU") ? 0 : !strcmp(gi.kind, "VIRTUAL GPU (HOST)") ? 1 : 2, 0);+ Ctx g = { 1, full ? 1.5 : 0.5, 0, 0 };+ measure(LB_GPU_SCENE, reps, w_scene, &g);+ measure(LB_GPU_FILL, reps, w_fill, &g);+ measure(LB_GPU_UPLOAD, reps, w_upload, &g);+ measure(LB_GPU_LAYERS, reps, w_layers, &g);+ lb_gpu_close();+ } else skip_all(LB_GPU_SCENE, LB_GPU_LAYERS, LB_SKIP_FAILED);+ } else skip_all(LB_GPU_SCENE, LB_GPU_LAYERS, LB_SKIP_NODEV);+#else+ skip_all(LB_GPU_SCENE, LB_GPU_LAYERS, LB_SKIP_NODEV);+#endif++ if (disk_fd >= 0 && go.storage_mb >= 8) {+ send_msg(LB_MSG_STEP, LB_DISK_SEQW, 0, 0);+ double w, rd, iops;+ if (lb_disk(disk_fd, go.storage_mb, 3, &w, &rd, &iops) == 0) {+ send_msg(LB_MSG_RESULT, LB_DISK_SEQW, w, 0);+ send_msg(LB_MSG_RESULT, LB_DISK_SEQR, rd, 0);+ send_msg(LB_MSG_RESULT, LB_DISK_RAND, iops, 0);+ } else skip_all(LB_DISK_SEQW, LB_DISK_RAND, LB_SKIP_FAILED);+ close(disk_fd);+ } else skip_all(LB_DISK_SEQW, LB_DISK_RAND, full ? LB_SKIP_NODEV : LB_SKIP_MODE);++ if (full && go.sustained_s >= 20 && go.sustained_s <= 1800) {+ send_msg(LB_MSG_STEP, LB_SUS_START, 0, 0);+ Sus s = { 0, 0, 0 };+ lb_sustained(threads, go.sustained_s, 10, on_sample, &s);+ if (s.n >= 2 && s.first > 0 && s.last > 0) {+ send_msg(LB_MSG_RESULT, LB_SUS_START, s.first, 0);+ send_msg(LB_MSG_RESULT, LB_SUS_END, s.last, 0);+ } else skip_all(LB_SUS_START, LB_SUS_END, LB_SKIP_FAILED);+ } else skip_all(LB_SUS_START, LB_SUS_END, LB_SKIP_MODE);++ send_msg(LB_MSG_DONE, 0, 0, mask < 0 ? 0 : mask);+ return 0;+}diff --git a/server/src/bench/lbproto.c b/server/src/bench/lbproto.cnew file mode 100644index 0000000..0370d96--- /dev/null+++ b/server/src/bench/lbproto.c@@ -0,0 +1,36 @@+/* lbproto.c — see lbproto.h. */+#include "lbproto.h"++#include <math.h>+#include <stddef.h>++static const struct { const char *name, *unit; } meas[LB_COUNT] = {+ [LB_CPU_SHA1] = { "cpu.sha256.1", "MB/s" }, [LB_CPU_SHAN] = { "cpu.sha256.n", "MB/s" },+ [LB_CPU_MAT1] = { "cpu.matmul.1", "GFLOP/s" }, [LB_CPU_MATN] = { "cpu.matmul.n", "GFLOP/s" },+ [LB_CPU_XZ1] = { "cpu.xz.1", "MB/s" }, [LB_CPU_XZN] = { "cpu.xz.n", "MB/s" },+ [LB_CPU_JS1] = { "cpu.js.1", "runs/s" }, [LB_CPU_JSN] = { "cpu.js.n", "runs/s" },+ [LB_MEM_COPY] = { "mem.copy", "GB/s" }, [LB_MEM_TRIAD] = { "mem.triad", "GB/s" },+ [LB_MEM_LAT] = { "mem.latency", "ns" },+ [LB_GPU_SCENE] = { "gpu.scene", "fps" }, [LB_GPU_FILL] = { "gpu.fill", "Mpx/s" },+ [LB_GPU_UPLOAD] = { "gpu.upload", "MB/s" }, [LB_GPU_LAYERS] = { "gpu.layers", "fps" },+ [LB_DISK_SEQW] = { "disk.seqwrite", "MB/s" }, [LB_DISK_SEQR] = { "disk.seqread", "MB/s" },+ [LB_DISK_RAND] = { "disk.random4k", "IOPS" },+ [LB_SUS_START] = { "sustained.start", "GFLOP/s" }, [LB_SUS_END] = { "sustained.end", "GFLOP/s" },+};++const char *lb_name(int id) { return id >= 0 && id < LB_COUNT ? meas[id].name : NULL; }+const char *lb_unit(int id) { return id >= 0 && id < LB_COUNT ? meas[id].unit : NULL; }+int lb_lower_better(int id) { return id == LB_MEM_LAT; }++int lb_msg_valid(const LbMsg *m) {+ if (m->magic != LB_MAGIC || !isfinite(m->value) || !isfinite(m->aux)) return 0;+ switch (m->kind) {+ case LB_MSG_STEP: return m->id < LB_COUNT;+ case LB_MSG_RESULT: return m->id < LB_COUNT && m->value > 0 && m->value < 1e12 && m->aux >= 0 && m->aux < 1e12;+ case LB_MSG_SKIP: return m->id < LB_COUNT && m->aux >= LB_SKIP_NODEV && m->aux <= LB_SKIP_MEMORY;+ case LB_MSG_SAMPLE: return m->value >= 0 && m->value < 1e9 && m->aux >= 0 && m->aux < 86400;+ case LB_MSG_DONE: return m->aux >= 0 && m->aux < 65536;+ case LB_MSG_GPUINFO: return m->value == 0 || m->value == 1 || m->value == 2;+ }+ return 0;+}diff --git a/server/src/bench/lbproto.h b/server/src/bench/lbproto.hnew file mode 100644index 0000000..df0637b--- /dev/null+++ b/server/src/bench/lbproto.h@@ -0,0 +1,78 @@+/* lbproto.h — the channel between lord-server (lbrun.c) and lord-bench (lbmain.c), LordBench's+ * sandboxed helper (docs/BENCHMARK.md, "0.8.6 — LordBench").+ *+ * A SOCK_SEQPACKET pair on fd 3. lord-server sends one LbGo (with up to two fds: the GPU's render node+ * and a storage scratch file, both opened by lord-server); lord-bench answers only with fixed-size+ * LbMsg records: no text, no paths. lord-server checks every field (lb_msg_valid) and builds the JSON+ * itself. To stop a run, lord-server kills the helper. */+#ifndef LORD_BENCH_LBPROTO_H+#define LORD_BENCH_LBPROTO_H++#include <stdint.h>++#define LB_MAGIC 0x4c424e31u /* "LBN1" */+#define LB_VERSION 1 /* LordBench's version: results compare only with the same one */++/* what to run */+enum { LB_MODE_QUICK = 1, LB_MODE_FULL = 2 };+/* LbGo.flags */+enum {+ LB_GO_GPU = 1, /* an fd with the render node follows */+ LB_GO_STORAGE = 2, /* an fd with the scratch file follows (after the GPU's) */+ LB_GO_LOW = 4, /* desktop impact: lowest priority */+};++typedef struct {+ uint32_t magic, mode, flags, threads;+ uint32_t storage_mb; /* the scratch file's size limit */+ uint32_t sustained_s; /* the sustained test's length (Full only), 0 = none */+} LbGo;++/* the measurements; their names and units are lb_name()/lb_unit() */+enum {+ LB_CPU_SHA1 = 0, /* SHA-256, one core, MB/s */+ LB_CPU_SHAN, /* SHA-256, all cores, MB/s */+ LB_CPU_MAT1, /* matrix multiply, one core, GFLOP/s */+ LB_CPU_MATN, /* matrix multiply, all cores, GFLOP/s */+ LB_CPU_XZ1, /* xz decompression (the package engine's decoder), one core, MB/s */+ LB_CPU_XZN, /* the same on all cores, MB/s */+ LB_CPU_JS1, /* QuickJS running a fixed script, one core, runs/s */+ LB_CPU_JSN, /* the same on all cores, runs/s */+ LB_MEM_COPY, /* memory bandwidth, copy, GB/s */+ LB_MEM_TRIAD, /* memory bandwidth, triad, GB/s */+ LB_MEM_LAT, /* memory latency, a pointer chase over 64 MB, ns */+ LB_GPU_SCENE, /* the 3D scene offscreen at 1920×1080, frames/s */+ LB_GPU_FILL, /* fill rate, Mpixel/s */+ LB_GPU_UPLOAD, /* texture upload, MB/s */+ LB_GPU_LAYERS, /* composing 8 screen-size layers, frames/s */+ LB_DISK_SEQW, /* storage, sequential write, MB/s */+ LB_DISK_SEQR, /* storage, sequential read, MB/s */+ LB_DISK_RAND, /* storage, random 4 KiB reads, IOPS */+ LB_SUS_START, /* sustained: all-core matrix multiply, first 10 s, GFLOP/s */+ LB_SUS_END, /* sustained: last 10 s, GFLOP/s */+ LB_COUNT+};++/* LbMsg.kind */+enum {+ LB_MSG_STEP = 1, /* id: the measurement starting now */+ LB_MSG_RESULT, /* id, value (and aux: the spread, max − min over the repeats) */+ LB_MSG_SKIP, /* id, why (aux, an LB_SKIP_*) */+ LB_MSG_SAMPLE, /* sustained: value = GFLOP/s of the last interval, aux = seconds since start */+ LB_MSG_DONE, /* the run ended; aux = the sandbox mask */+ LB_MSG_GPUINFO, /* value = 0 hardware, 1 virtual, 2 software (bench_gl_kind) */+};+enum { LB_SKIP_NODEV = 1, LB_SKIP_FAILED, LB_SKIP_MODE, LB_SKIP_MEMORY };++typedef struct {+ uint32_t magic, kind, id, pad;+ double value, aux;+} LbMsg;++const char *lb_name(int id); /* "cpu.sha256.1", …; NULL out of range */+const char *lb_unit(int id); /* "MB/s", "GFLOP/s", "runs/s", "GB/s", "ns", "fps", "Mpx/s", "IOPS" */+int lb_lower_better(int id); /* 1 for latency */+/* 1 if a record from the helper is acceptable: magic, kind, id in range, finite values in range */+int lb_msg_valid(const LbMsg *m);++#endifdiff --git a/server/src/bench/lbrun.c b/server/src/bench/lbrun.cnew file mode 100644index 0000000..767ce99--- /dev/null+++ b/server/src/bench/lbrun.c@@ -0,0 +1,512 @@+/* lbrun.c — see lbrun.h. */+#include "lbrun.h"+#include "lbcond.h"+#include "lbproto.h"+#include "bench.h"+#include "../hw/jbuf.h"+#include "lord_version.h"++#include <errno.h>+#include <fcntl.h>+#include <limits.h>+#include <poll.h>+#include <pthread.h>+#include <signal.h>+#include <spawn.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/socket.h>+#include <sys/stat.h>+#include <sys/statvfs.h>+#include <sys/utsname.h>+#include <sys/wait.h>+#include <time.h>+#include <unistd.h>++enum { ST_IDLE, ST_WAITING, ST_RUNNING, ST_DONE, ST_STOPPED, ST_FAILED, ST_CANCELLED };+static const char *const st_name[] = { "idle", "waiting", "running", "done", "stopped", "failed", "cancelled" };++#define QUIET_SECS 10 /* CPU below QUIET_PCT for this long before starting */+#define QUIET_PCT 15.0+#define QUIET_MAX_S 30 /* after this, the run starts anyway and is marked busy */+#define MAX_SAMPLES 200++static pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;+static int state = ST_IDLE, step = -1, done_count;+static volatile int cancel_req;+static pid_t child = -1;+static char *result_json;++typedef struct {+ int full, sustained_s;+ char *extra;+} Job;++/* ---- the helper's fixed path, next to lord-server, as for lord-doc and lord-media ---- */++static int helper_path(char *out, size_t n) {+ char self[PATH_MAX];+ ssize_t k = readlink("/proc/self/exe", self, sizeof self - 1);+ if (k <= 0) return -1;+ self[k] = 0;+ char *slash = strrchr(self, '/');+ if (!slash) return -1;+ *slash = 0;+ if ((size_t)snprintf(out, n, "%s/lord-bench", self) >= n) return -1;+ struct stat st;+ if (stat(out, &st) || !S_ISREG(st.st_mode) || !(st.st_mode & S_IXUSR)) return -1;+ if ((st.st_uid != 0 && st.st_uid != getuid()) || (st.st_mode & (S_IWGRP | S_IWOTH))) return -1;+ return 0;+}++/* ---- what lord-server opens for it ---- */++static int open_render_node(void) {+ for (int i = 128; i < 136; i++) {+ char p[32];+ snprintf(p, sizeof p, "/dev/dri/renderD%d", i);+ int fd = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY);+ if (fd >= 0) return fd;+ }+ return -1;+}++/* the storage scratch file: an unnamed file (O_TMPFILE) in the user's cache folder, so nothing is left+ * behind if anything dies; its size is at most 1 GB and a quarter of the free space */+static int open_scratch(char *dir, size_t dn, unsigned *mb) {+ const char *xc = getenv("XDG_CACHE_HOME"), *home = getenv("HOME");+ if (xc && xc[0] == '/') snprintf(dir, dn, "%s", xc);+ else if (home && home[0] == '/') snprintf(dir, dn, "%s/.cache", home);+ else return -1;+ mkdir(dir, 0700);+ int fd = open(dir, O_TMPFILE | O_RDWR | O_CLOEXEC, 0600);+ if (fd < 0) return -1;+ struct statvfs vf;+ unsigned long long freemb = fstatvfs(fd, &vf) ? 0 : (unsigned long long)vf.f_bavail * vf.f_frsize / (1 << 20);+ unsigned long long m = freemb / 4;+ if (m > 1024) m = 1024;+ if (m < 64) { close(fd); return -1; }+ *mb = (unsigned)m;+ return fd;+}++/* ---- the result ---- */++typedef struct {+ double value[LB_COUNT], spread[LB_COUNT];+ int have[LB_COUNT], skip[LB_COUNT];+ int gpu_kind, sandbox;+ double sample_t[MAX_SAMPLES], sample_v[MAX_SAMPLES], sample_temp[MAX_SAMPLES];+ int nsamples;+ double throttle_at, throttle_temp;+} Res;++static void cond_json(HBuf *b, const LbCond *c) {+ hb_printf(b, "{");+ if (c->temp_c > -270) hb_printf(b, "\"tempC\":%.1f,", c->temp_c);+ if (c->zone[0]) { hb_printf(b, "\"zone\":"); hb_str(b, c->zone); hb_printf(b, ","); }+ if (c->passive_c > 0) hb_printf(b, "\"passiveC\":%.1f,", c->passive_c);+ if (c->critical_c > 0) hb_printf(b, "\"criticalC\":%.1f,", c->critical_c);+ if (c->throttle_known) hb_printf(b, "\"throttleEvents\":%lu,", c->throttle_events);+ if (c->rpi_throttled >= 0) hb_printf(b, "\"rpiThrottled\":%d,", c->rpi_throttled);+ if (c->freq_mhz > 0) hb_printf(b, "\"freqMHz\":%.0f,", c->freq_mhz);+ if (c->freq_max_mhz > 0) hb_printf(b, "\"freqMaxMHz\":%.0f,", c->freq_max_mhz);+ if (c->governor[0]) { hb_printf(b, "\"governor\":"); hb_str(b, c->governor); hb_printf(b, ","); }+ if (c->platform_profile[0]) { hb_printf(b, "\"platformProfile\":"); hb_str(b, c->platform_profile); hb_printf(b, ","); }+ hb_printf(b, "\"power\":\"%s\"", c->on_battery < 0 ? "unknown" : c->on_battery ? "battery" : "mains");+ if (c->battery_pct >= 0) hb_printf(b, ",\"batteryPct\":%d", c->battery_pct);+ hb_printf(b, "}");+}++static char *build_result(const Job *j, int st, const char *why, const Res *r, const LbCond *c0, const LbCond *c1,+ double busy_pct, double waited, int quiet, int threads, const char *storage, unsigned storage_mb,+ double secs) {+ HBuf b = { 0 };+ struct utsname u;+ if (uname(&u)) u.release[0] = u.machine[0] = 0;+ hb_printf(&b, "{\"lordbench\":%d,\"mode\":\"%s\",\"at\":%lld,\"seconds\":%.0f,\"status\":\"%s\",\"stopReason\":",+ LB_VERSION, j->full ? "full" : "quick", (long long)time(NULL), secs, st_name[st]);+ hb_str(&b, why ? why : "");+ hb_printf(&b, ",\"lordos\":\"%s%s%s\",\"kernel\":", LORD_VERSION, LORD_CHANNEL[0] ? "-" : "", LORD_CHANNEL);+ hb_str(&b, u.release);+ hb_printf(&b, ",\"arch\":");+ hb_str(&b, u.machine);+ hb_printf(&b, ",\"live\":%s,\"threads\":%d,\"cpus\":%ld", access("/run/live", F_OK) ? "false" : "true", threads, sysconf(_SC_NPROCESSORS_ONLN));+ hb_printf(&b, ",\"quiet\":{\"quiet\":%s,\"busyPct\":%.1f,\"waitedS\":%.0f}", quiet ? "true" : "false", busy_pct, waited);+ hb_printf(&b, ",\"before\":");+ cond_json(&b, c0);+ hb_printf(&b, ",\"after\":");+ cond_json(&b, c1);+ hb_printf(&b, ",\"storage\":{\"kind\":\"%s\",\"mb\":%u}", storage, storage_mb);+ hb_printf(&b, ",\"gpuKind\":\"%s\"", r->gpu_kind == 0 ? "hardware" : r->gpu_kind == 1 ? "virtual" : r->gpu_kind == 2 ? "software" : "");+ hb_printf(&b, ",\"sandbox\":%d", r->sandbox);+ if (j->extra) hb_printf(&b, ",\"session\":%s", j->extra);+ hb_printf(&b, ",\"results\":{");+ int first = 1;+ for (int i = 0; i < LB_COUNT; i++) if (r->have[i]) {+ hb_printf(&b, "%s\"%s\":{\"value\":%.6g,\"spread\":%.4g,\"unit\":\"%s\"%s}", first ? "" : ",", lb_name(i), r->value[i], r->spread[i],+ lb_unit(i), lb_lower_better(i) ? ",\"lowerBetter\":true" : "");+ first = 0;+ }+ hb_printf(&b, "},\"skipped\":{");+ first = 1;+ static const char *const why_skip[] = { "", "nodev", "failed", "mode", "memory" };+ for (int i = 0; i < LB_COUNT; i++) if (!r->have[i] && r->skip[i]) {+ hb_printf(&b, "%s\"%s\":\"%s\"", first ? "" : ",", lb_name(i), why_skip[r->skip[i]]);+ first = 0;+ }+ hb_printf(&b, "}");+ if (r->nsamples) {+ hb_printf(&b, ",\"sustained\":{\"samples\":[");+ for (int i = 0; i < r->nsamples; i++)+ if (r->sample_temp[i] > -270) hb_printf(&b, "%s[%.1f,%.3g,%.1f]", i ? "," : "", r->sample_t[i], r->sample_v[i], r->sample_temp[i]);+ else hb_printf(&b, "%s[%.1f,%.3g,null]", i ? "," : "", r->sample_t[i], r->sample_v[i]);+ hb_printf(&b, "]");+ if (r->throttle_at >= 0) hb_printf(&b, ",\"throttleAtS\":%.0f,\"throttleTempC\":%.1f", r->throttle_at, r->throttle_temp);+ hb_printf(&b, "}");+ }+ hb_printf(&b, "}");+ return hb_take(&b);+}++/* ~/.local/state/lordos/lordbench.json, the previous one kept as lordbench-prev.json */+static const char *saving;+static void write_saving(FILE *f) { fputs(saving, f); fputc('\n', f); }+static int state_dir(char *out, size_t n) {+ const char *st = getenv("XDG_STATE_HOME"), *home = getenv("HOME");+ if (st && st[0] == '/') snprintf(out, n, "%s/lordos", st);+ else if (home && home[0] == '/') snprintf(out, n, "%s/.local/state/lordos", home);+ else return -1;+ return 0;+}+static void save_result(const char *json) {+ char dir[PATH_MAX], a[PATH_MAX + 32], b[PATH_MAX + 32];+ if (!state_dir(dir, sizeof dir)) {+ snprintf(a, sizeof a, "%s/lordbench.json", dir);+ snprintf(b, sizeof b, "%s/lordbench-prev.json", dir);+ rename(a, b);+ }+ saving = json;+ bench_save("lordbench", write_saving);+}++char *lbrun_saved(int which) {+ char dir[PATH_MAX], p[PATH_MAX + 32];+ if (state_dir(dir, sizeof dir)) return NULL;+ snprintf(p, sizeof p, "%s/%s.json", dir, which ? "lordbench-prev" : "lordbench");+ int fd = open(p, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);+ struct stat st;+ if (fd < 0) return NULL;+ if (fstat(fd, &st) || !S_ISREG(st.st_mode) || st.st_size <= 0 || st.st_size > 256 * 1024) { close(fd); return NULL; }+ char *s = malloc((size_t)st.st_size + 1);+ ssize_t n = s ? read(fd, s, (size_t)st.st_size) : -1;+ close(fd);+ if (n <= 0) { free(s); return NULL; }+ s[n] = 0;+ return s; /* the caller parses it as JSON (JS_ParseJSON) */+}++/* ---- the run ---- */++static void set_state(int s) { pthread_mutex_lock(&mu); state = s; pthread_mutex_unlock(&mu); }++static double cpu_busy(unsigned long long b0, unsigned long long t0, unsigned long long b1, unsigned long long t1) {+ return t1 > t0 ? 100.0 * (double)(b1 - b0) / (double)(t1 - t0) : 0;+}++static void *run(void *arg) {+ Job *j = arg;+ Res *r = calloc(1, sizeof *r);+ LbCond c0, c1, cn;+ char why_buf[16] = "";+ const char *why = NULL;+ int st = ST_FAILED, threads = (int)sysconf(_SC_NPROCESSORS_ONLN), sock = -1, gpu = -1, disk = -1, quiet = 0;+ unsigned storage_mb = 0;+ char scratch_dir[PATH_MAX] = "";+ const char *storage = "none";+ double busy_pct = 0, waited = 0, t_start = bench_now_ms();+ if (!r) goto finish;+ for (int i = 0; i < LB_COUNT; i++) r->skip[i] = 0;+ r->gpu_kind = -1;+ r->throttle_at = -1;+ lb_cond_read("", &c0);+ c1 = c0;+ if (lb_cond_battery_low(&c0)) { why = "battery"; goto finish; }++ /* a quiet system first: QUIET_SECS seconds in a row below QUIET_PCT, at most QUIET_MAX_S */+ unsigned long long b0, t0, b1, t1, wb, wt;+ if (lb_cpu_ticks("", &b0, &t0)) { b0 = t0 = 0; }+ wb = b0; wt = t0;+ int calm = 0;+ double w0 = bench_now_ms();+ while (!cancel_req && (bench_now_ms() - w0) < QUIET_MAX_S * 1000) {+ struct timespec ts = { 1, 0 };+ nanosleep(&ts, NULL);+ if (lb_cpu_ticks("", &b1, &t1)) break;+ double p = cpu_busy(b0, t0, b1, t1);+ b0 = b1; t0 = t1;+ calm = p < QUIET_PCT ? calm + 1 : 0;+ if (calm >= QUIET_SECS) { quiet = 1; break; }+ }+ waited = (bench_now_ms() - w0) / 1000;+ if (!lb_cpu_ticks("", &b1, &t1)) busy_pct = cpu_busy(wb, wt, b1, t1);+ if (cancel_req) { st = ST_CANCELLED; goto finish; }++ /* the helper, with what lord-server opened for it */+ char path[PATH_MAX];+ if (helper_path(path, sizeof path)) { why = "helper"; goto finish; }+ gpu = open_render_node();+ if (j->full) {+ disk = open_scratch(scratch_dir, sizeof scratch_dir, &storage_mb);+ storage = disk >= 0 ? lb_storage_kind("", scratch_dir) : "none";+ }+ int sv[2];+ if (socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv)) goto finish;+ posix_spawn_file_actions_t fa;+ posix_spawn_file_actions_init(&fa);+ posix_spawn_file_actions_adddup2(&fa, sv[1], 3);+ posix_spawnattr_t at;+ posix_spawnattr_init(&at);+ sigset_t none, all;+ sigemptyset(&none);+ sigfillset(&all);+ posix_spawnattr_setsigmask(&at, &none);+ posix_spawnattr_setsigdefault(&at, &all);+ posix_spawnattr_setflags(&at, POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF);+ char sessiond[32] = "LORDOS_SESSIOND=1";+ char *envp[] = { "LANG=C.UTF-8", getenv("LORDOS_SESSIOND") ? sessiond : NULL, NULL };+ char *argv[] = { "lord-bench", NULL };+ pid_t pid;+ int e = posix_spawn(&pid, path, &fa, &at, argv, envp);+ posix_spawn_file_actions_destroy(&fa);+ posix_spawnattr_destroy(&at);+ close(sv[1]);+ if (e) { close(sv[0]); why = "helper"; goto finish; }+ sock = sv[0];+ pthread_mutex_lock(&mu);+ child = pid;+ state = ST_RUNNING;+ pthread_mutex_unlock(&mu);++ LbGo go = { LB_MAGIC, j->full ? LB_MODE_FULL : LB_MODE_QUICK, (gpu >= 0 ? LB_GO_GPU : 0) | (disk >= 0 ? LB_GO_STORAGE : 0),+ (uint32_t)threads, storage_mb, j->full ? (uint32_t)j->sustained_s : 0 };+ int fds[2], nfd = 0;+ if (gpu >= 0) fds[nfd++] = gpu;+ if (disk >= 0) fds[nfd++] = disk;+ char cbuf[CMSG_SPACE(2 * sizeof(int))];+ memset(cbuf, 0, sizeof cbuf);+ struct iovec iov = { &go, sizeof go };+ struct msghdr mh = { .msg_iov = &iov, .msg_iovlen = 1 };+ if (nfd) {+ mh.msg_control = cbuf;+ mh.msg_controllen = CMSG_SPACE((size_t)nfd * sizeof(int));+ struct cmsghdr *cm = CMSG_FIRSTHDR(&mh);+ cm->cmsg_level = SOL_SOCKET;+ cm->cmsg_type = SCM_RIGHTS;+ cm->cmsg_len = CMSG_LEN((size_t)nfd * sizeof(int));+ memcpy(CMSG_DATA(cm), fds, (size_t)nfd * sizeof(int));+ }+ if (sendmsg(sock, &mh, MSG_NOSIGNAL) != (ssize_t)sizeof go) { why = "helper"; goto stop; }+ if (gpu >= 0) { close(gpu); gpu = -1; }+ if (disk >= 0) { close(disk); disk = -1; }++ /* the records, and the guards every second */+ double deadline = bench_now_ms() + (j->full ? (600.0 + j->sustained_s) : 180.0) * 1000, next_guard = 0;+ int sustained_phase = 0, finished = 0;+ while (!finished) {+ if (cancel_req) { st = ST_CANCELLED; goto stop; }+ if (bench_now_ms() > deadline) { why = "timeout"; goto stop; }+ if (bench_now_ms() >= next_guard) {+ next_guard = bench_now_ms() + 1000;+ lb_cond_read("", &cn);+ const char *s = lb_cond_stop(&c0, &cn, !sustained_phase);+ if (s) {+ if (sustained_phase && !strcmp(s, "throttled")) { /* recorded, not stopped */ }+ else { snprintf(why_buf, sizeof why_buf, "%s", s); why = why_buf; st = ST_STOPPED; goto stop; }+ }+ if (sustained_phase && r->throttle_at < 0 &&+ ((c0.throttle_known && cn.throttle_events > c0.throttle_events) || (cn.rpi_throttled > 0 && (cn.rpi_throttled & (LB_RPI_THROTTLED | LB_RPI_CAPPED | LB_RPI_SOFTTEMP))))) {+ r->throttle_at = r->nsamples ? r->sample_t[r->nsamples - 1] : 0;+ r->throttle_temp = cn.temp_c;+ }+ }+ struct pollfd pf = { sock, POLLIN, 0 };+ int pr = poll(&pf, 1, 250);+ if (pr < 0 && errno != EINTR) { why = "helper"; goto stop; }+ if (pr <= 0) continue;+ LbMsg m;+ ssize_t n = recv(sock, &m, sizeof m, MSG_DONTWAIT);+ if (n == 0 || (n < 0 && errno != EAGAIN)) { why = "helper"; goto stop; }+ if (n < 0) continue;+ if (n != (ssize_t)sizeof m || !lb_msg_valid(&m)) { why = "protocol"; goto stop; }+ if (m.kind == LB_MSG_SAMPLE) lb_cond_read("", &cn);+ pthread_mutex_lock(&mu);+ switch (m.kind) {+ case LB_MSG_STEP:+ step = (int)m.id;+ if (m.id == LB_SUS_START) sustained_phase = 1;+ break;+ case LB_MSG_RESULT:+ r->have[m.id] = 1; r->value[m.id] = m.value; r->spread[m.id] = m.aux;+ done_count++;+ break;+ case LB_MSG_SKIP:+ r->skip[m.id] = (int)m.aux;+ done_count++;+ break;+ case LB_MSG_SAMPLE:+ if (r->nsamples < MAX_SAMPLES) {+ r->sample_t[r->nsamples] = m.aux;+ r->sample_v[r->nsamples] = m.value;+ r->sample_temp[r->nsamples] = cn.temp_c;+ r->nsamples++;+ }+ break;+ case LB_MSG_GPUINFO: r->gpu_kind = (int)m.value; break;+ case LB_MSG_DONE: r->sandbox = (int)m.aux; finished = 1; st = ST_DONE; break;+ }+ pthread_mutex_unlock(&mu);+ }+stop:+ if (st != ST_DONE && st != ST_CANCELLED && st != ST_STOPPED) st = ST_FAILED;+ kill(pid, SIGKILL);+ waitpid(pid, NULL, 0);+ pthread_mutex_lock(&mu);+ child = -1;+ pthread_mutex_unlock(&mu);+finish:+ if (sock >= 0) close(sock);+ if (gpu >= 0) close(gpu);+ if (disk >= 0) close(disk);+ lb_cond_read("", &c1);+ if (r) {+ if (!why && st == ST_FAILED) why = "helper";+ if (st == ST_FAILED && why && !strcmp(why, "battery")) st = ST_STOPPED;+ char *json = build_result(j, st, why, r, &c0, &c1, busy_pct, waited, quiet, threads, storage, storage_mb,+ (bench_now_ms() - t_start) / 1000);+ int any = 0;+ for (int i = 0; i < LB_COUNT; i++) any |= r->have[i];+ if (json && any && (st == ST_DONE || st == ST_STOPPED)) save_result(json); /* a refused run keeps the last result */+ pthread_mutex_lock(&mu);+ free(result_json);+ result_json = json;+ state = st;+ pthread_mutex_unlock(&mu);+ free(r);+ } else set_state(ST_FAILED);+ free(j->extra);+ free(j);+ return NULL;+}++int lbrun_start(const char *mode, int sustained_s, const char *extra) {+ int full = mode && !strcmp(mode, "full");+ if (!mode || (!full && strcmp(mode, "quick"))) return -1;+ if (sustained_s && (sustained_s < 20 || sustained_s > 1800)) return -1;+ char path[PATH_MAX];+ if (helper_path(path, sizeof path)) return -1;+ pthread_mutex_lock(&mu);+ if (state == ST_WAITING || state == ST_RUNNING) { pthread_mutex_unlock(&mu); return -1; }+ state = ST_WAITING;+ step = -1;+ done_count = 0;+ cancel_req = 0;+ free(result_json);+ result_json = NULL;+ pthread_mutex_unlock(&mu);+ Job *j = calloc(1, sizeof *j);+ if (!j) { set_state(ST_IDLE); return -1; }+ j->full = full;+ j->sustained_s = full ? sustained_s : 0;+ j->extra = extra ? strdup(extra) : NULL;+ pthread_t th;+ pthread_attr_t a;+ pthread_attr_init(&a);+ pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);+ int e = pthread_create(&th, &a, run, j);+ pthread_attr_destroy(&a);+ if (e) { free(j->extra); free(j); set_state(ST_IDLE); return -1; }+ return 0;+}++void lbrun_cancel(void) {+ pthread_mutex_lock(&mu);+ if (state == ST_WAITING || state == ST_RUNNING) cancel_req = 1;+ pthread_mutex_unlock(&mu);+}++char *lbrun_poll(void) {+ HBuf b = { 0 };+ pthread_mutex_lock(&mu);+ hb_printf(&b, "{\"state\":\"%s\",\"step\":", st_name[state]);+ hb_str(&b, step >= 0 ? lb_name(step) : "");+ hb_printf(&b, ",\"progress\":%.3f", done_count / (double)LB_COUNT);+ if (result_json && state != ST_WAITING && state != ST_RUNNING) hb_printf(&b, ",\"result\":%s", result_json);+ hb_printf(&b, "}");+ pthread_mutex_unlock(&mu);+ return hb_take(&b);+}++/* ---- boot history (lord-sessiond's boot-times.jsonl) ---- */++static int cmp_d(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return (x > y) - (x < y); }++char *lbrun_boot_history(const char *path) {+ int fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);+ struct stat st;+ if (fd < 0) return NULL;+ if (fstat(fd, &st) || !S_ISREG(st.st_mode) || st.st_size > 256 * 1024 || (st.st_uid != 0 && st.st_uid != getuid()) || (st.st_mode & 022)) { close(fd); return NULL; }+ char *txt = malloc((size_t)st.st_size + 1);+ ssize_t n = txt ? read(fd, txt, (size_t)st.st_size) : -1;+ close(fd);+ if (n < 0) { free(txt); return NULL; }+ txt[n] = 0;+ /* versions in order of appearance; for each, the boots' seconds; the first boot of each version kept apart */+ enum { MAXV = 32, MAXB = 200 };+ static struct { char v[40]; double s[MAXB]; int n; double first; } vs[MAXV];+ int nv = 0;+ char last[40] = "";+ for (char *line = txt; line && *line; ) {+ char *eol = strchr(line, '\n');+ if (eol) *eol = 0;+ char *ver = strstr(line, "\"version\":\""), *sec = strstr(line, "\"seconds\":");+ if (ver && sec) {+ ver += 11;+ size_t k = strspn(ver, "0123456789.-+~abcdefghijklmnopqrstuvwxyz");+ double s = atof(sec + 10);+ if (k && k < sizeof last && ver[k] == '"' && s > 0 && s < 3600) {+ char v[40];+ memcpy(v, ver, k);+ v[k] = 0;+ int i;+ for (i = 0; i < nv && strcmp(vs[i].v, v); i++) {}+ if (i == nv && nv < MAXV) { snprintf(vs[nv].v, sizeof vs[nv].v, "%s", v); vs[nv].n = 0; vs[nv].first = -1; nv++; }+ if (i < nv) {+ if (strcmp(last, v)) { if (vs[i].first < 0) vs[i].first = s; else if (vs[i].n < MAXB) vs[i].s[vs[i].n++] = s; }+ else if (vs[i].n < MAXB) vs[i].s[vs[i].n++] = s;+ }+ snprintf(last, sizeof last, "%s", v);+ }+ }+ line = eol ? eol + 1 : NULL;+ }+ free(txt);+ HBuf b = { 0 };+ hb_printf(&b, "[");+ for (int i = 0; i < nv; i++) {+ hb_printf(&b, "%s{\"version\":", i ? "," : "");+ hb_str(&b, vs[i].v);+ hb_printf(&b, ",\"boots\":%d", vs[i].n);+ if (vs[i].n) {+ qsort(vs[i].s, (size_t)vs[i].n, sizeof(double), cmp_d);+ int m = vs[i].n;+ double med = m % 2 ? vs[i].s[m / 2] : (vs[i].s[m / 2 - 1] + vs[i].s[m / 2]) / 2;+ hb_printf(&b, ",\"median\":%.2f,\"min\":%.2f,\"max\":%.2f", med, vs[i].s[0], vs[i].s[m - 1]);+ }+ if (vs[i].first >= 0) hb_printf(&b, ",\"first\":%.2f", vs[i].first);+ hb_printf(&b, "}");+ }+ hb_printf(&b, "]");+ return hb_take(&b);+}diff --git a/server/src/bench/lbrun.h b/server/src/bench/lbrun.hnew file mode 100644index 0000000..98c64b1--- /dev/null+++ b/server/src/bench/lbrun.h@@ -0,0 +1,24 @@+/* lbrun.h — LordBench in lord-server (docs/BENCHMARK.md, "0.8.6 — LordBench"): one run at a time, on+ * its own thread. It records the conditions, waits for a quiet system, launches lord-bench (lbmain.c)+ * with the render node and, for Full, a scratch file it opened itself, checks every record that comes+ * back, watches temperatures and throttling, and saves the result as+ * ~/.local/state/lordos/lordbench.json (the previous one becomes lordbench-prev.json). Exposed to JS+ * as lord.sysinfo.bench (ui/js_hw.c). */+#ifndef LORD_BENCH_LBRUN_H+#define LORD_BENCH_LBRUN_H++/* mode: "quick" or "full"; sustained_s: Full's sustained test (0 = none, 20–1800); extra: JSON the+ * caller adds as "session" (displays, composition), produced by lord-server itself. 0 started,+ * -1 refused (another run, a bad argument, no helper). */+int lbrun_start(const char *mode, int sustained_s, const char *extra);+void lbrun_cancel(void);+/* the state as JSON (malloc'd): {"state":"idle|waiting|running|done|stopped|failed|cancelled",+ * "step":"<measurement>","progress":0..1,"result":{…} once finished} */+char *lbrun_poll(void);+/* the saved results (malloc'd JSON text, NULL if none): which = 0 the last, 1 the previous */+char *lbrun_saved(int which);+/* every recorded boot's time to the first frame, grouped by LordOS version (malloc'd JSON array):+ * [{"version","boots","median","min","max","first"}], the first boot after an update kept apart */+char *lbrun_boot_history(const char *path);++#endifdiff --git a/server/src/bench/lbwork.c b/server/src/bench/lbwork.cnew file mode 100644index 0000000..76b8737--- /dev/null+++ b/server/src/bench/lbwork.c@@ -0,0 +1,380 @@+/* lbwork.c — see lbwork.h. */+#include "lbwork.h"+#include "bench.h"+#include "../pkg/crypto.h"+#include "../pkg/xz.h"+#include "lb_corpus.h"++#include <fcntl.h>+#include <pthread.h>+#include <quickjs.h>+#include <sched.h>+#include <stdatomic.h>+#include <stdint.h>+#include <stdlib.h>+#include <string.h>+#include <time.h>+#include <unistd.h>++#define LB_MAX_THREADS 256++/* ---- running on n threads at once ---- */++typedef struct {+ void (*fn)(void *, int);+ void *arg;+ int t;+ atomic_int *gate; /* 0 wait, 1 go, -1 give up */+} Job;++static void *job_main(void *p) {+ Job *j = p;+ int g;+ while (!(g = atomic_load(j->gate))) sched_yield();+ if (g > 0) j->fn(j->arg, j->t);+ return NULL;+}++double lb_parallel(int n, void (*fn)(void *arg, int t), void *arg) {+ if (n < 1) n = 1;+ if (n > LB_MAX_THREADS) n = LB_MAX_THREADS;+ static pthread_t th[LB_MAX_THREADS];+ static Job jobs[LB_MAX_THREADS];+ atomic_int gate = 0;+ int started = 1;+ for (int i = 1; i < n; i++, started++) {+ jobs[i] = (Job){ fn, arg, i, &gate };+ if (pthread_create(&th[i], NULL, job_main, &jobs[i])) break;+ }+ atomic_store(&gate, started == n ? 1 : -1);+ double t0 = bench_now_ms();+ if (started == n) fn(arg, 0);+ for (int i = 1; i < started; i++) pthread_join(th[i], NULL);+ return started == n ? bench_now_ms() - t0 : -1;+}++/* a timed loop shared by the CPU workloads: every thread repeats one unit of work until secs have+ * passed and counts the units it finished */+typedef struct {+ double secs;+ void (*unit)(void *state);+ void *(*setup)(void);+ void (*teardown)(void *state);+ double units[LB_MAX_THREADS];+ double ms[LB_MAX_THREADS];+ atomic_int failed;+} Timed;++static void timed_thread(void *arg, int t) {+ Timed *tm = arg;+ void *st = tm->setup ? tm->setup() : NULL;+ if (tm->setup && !st) { atomic_store(&tm->failed, 1); return; }+ double t0 = bench_now_ms(), end = t0 + tm->secs * 1000, now = t0;+ double u = 0;+ do { tm->unit(st); u++; now = bench_now_ms(); } while (now < end);+ tm->units[t] = u;+ tm->ms[t] = now - t0;+ if (tm->teardown) tm->teardown(st);+}++/* units per second, summed over the threads; -1 if a thread failed */+static double timed_run(int threads, double secs, void *(*setup)(void), void (*unit)(void *), void (*teardown)(void *)) {+ static Timed tm;+ memset(&tm, 0, sizeof tm);+ tm.secs = secs;+ tm.setup = setup;+ tm.unit = unit;+ tm.teardown = teardown;+ if (threads > LB_MAX_THREADS) threads = LB_MAX_THREADS;+ if (lb_parallel(threads, timed_thread, &tm) < 0 || atomic_load(&tm.failed)) return -1;+ double rate = 0;+ for (int i = 0; i < threads; i++) if (tm.ms[i] > 0) rate += tm.units[i] * 1000.0 / tm.ms[i];+ return rate;+}++/* ---- SHA-256 (pkg/crypto.c, with the CPU's SHA instructions when it has them) ---- */++#define SHA_BLOCK (1 << 20)+static void *sha_setup(void) {+ uint8_t *b = malloc(SHA_BLOCK);+ if (b) for (size_t i = 0; i < SHA_BLOCK; i++) b[i] = (uint8_t)(i * 2654435761u >> 13);+ return b;+}+static void sha_unit(void *st) {+ static _Thread_local uint8_t out[32];+ sha256(st, SHA_BLOCK, out);+ ((uint8_t *)st)[0] ^= out[0]; /* depend on the result */+}++double lb_sha256(int threads, double secs) {+ sha256_select(1);+ double r = timed_run(threads, secs, sha_setup, sha_unit, free);+ return r < 0 ? r : r * SHA_BLOCK / 1e6;+}++/* ---- matrix multiply ---- */++#define MAT_N 256+typedef struct { double a[MAT_N * MAT_N], b[MAT_N * MAT_N], c[MAT_N * MAT_N]; } Mat;+static void *mat_setup(void) {+ Mat *m = aligned_alloc(64, sizeof(Mat));+ if (!m) return NULL;+ for (int i = 0; i < MAT_N * MAT_N; i++) { m->a[i] = (i % 17) * 0.25; m->b[i] = (i % 13) * 0.5; }+ return m;+}+static void mat_unit(void *st) {+ Mat *m = st;+ memset(m->c, 0, sizeof m->c);+ for (int i = 0; i < MAT_N; i++)+ for (int k = 0; k < MAT_N; k++) {+ double aik = m->a[i * MAT_N + k];+ const double *restrict b = &m->b[k * MAT_N];+ double *restrict c = &m->c[i * MAT_N];+ for (int j = 0; j < MAT_N; j++) c[j] += aik * b[j];+ }+ m->a[0] = m->c[MAT_N * MAT_N - 1] * 1e-12; /* depend on the result */+}+#define MAT_FLOP (2.0 * MAT_N * MAT_N * MAT_N)++double lb_matmul(int threads, double secs) {+ double r = timed_run(threads, secs, mat_setup, mat_unit, free);+ return r < 0 ? r : r * MAT_FLOP / 1e9;+}++/* ---- xz (the package engine's decoder) ---- */++static void *xz_setup(void) { return (void *)1; }+static _Thread_local size_t xz_out;+static _Thread_local int xz_bad;+static void xz_unit(void *st) {+ (void)st;+ uint8_t *out = NULL;+ size_t n = 0;+ if (xz_decode(lb_corpus_xz, sizeof lb_corpus_xz, &out, &n, LB_CORPUS_SIZE + 1) || n != LB_CORPUS_SIZE) xz_bad = 1;+ free(out);+ xz_out = n;+}+static void xz_none(void *st) { (void)st; }++double lb_xz(int threads, double secs) {+ double r = timed_run(threads, secs, xz_setup, xz_unit, xz_none);+ return r < 0 ? r : r * LB_CORPUS_SIZE / 1e6;+}++/* ---- QuickJS ---- */++static const char js_script[] =+ "function work(){"+ " var s=[]; for(var i=0;i<2000;i++) s.push('item-'+i+'-'+(i*7919%1000));"+ " var o={list:s.map(function(x,i){return {id:i,name:x,tags:[x.length,i%7]};})};"+ " var j=JSON.stringify(o); var p=JSON.parse(j);"+ " p.list.sort(function(a,b){return a.name<b.name?-1:a.name>b.name?1:0;});"+ " var re=/item-(\\d+)-(\\d+)/, n=0;"+ " for(var k=0;k<p.list.length;k++){var m=re.exec(p.list[k].name); if(m) n+= +m[2];}"+ " var mp=new Map(); for(var k=0;k<p.list.length;k++) mp.set(p.list[k].name,k);"+ " return n + j.length + mp.size;"+ "}";++typedef struct { JSRuntime *rt; JSContext *c; JSValue fn; } JsState;+static void *js_setup(void) {+ JsState *s = calloc(1, sizeof *s);+ if (!s) return NULL;+ s->rt = JS_NewRuntime();+ if (!s->rt) { free(s); return NULL; }+ JS_SetMemoryLimit(s->rt, 64 << 20);+ s->c = JS_NewContext(s->rt);+ if (!s->c) { JS_FreeRuntime(s->rt); free(s); return NULL; }+ JSValue r = JS_Eval(s->c, js_script, sizeof js_script - 1, "<lordbench>", JS_EVAL_TYPE_GLOBAL);+ JS_FreeValue(s->c, r);+ JSValue g = JS_GetGlobalObject(s->c);+ s->fn = JS_GetPropertyStr(s->c, g, "work");+ JS_FreeValue(s->c, g);+ if (!JS_IsFunction(s->c, s->fn)) { JS_FreeValue(s->c, s->fn); JS_FreeContext(s->c); JS_FreeRuntime(s->rt); free(s); return NULL; }+ return s;+}+static void js_unit(void *st) {+ JsState *s = st;+ JSValue r = JS_Call(s->c, s->fn, JS_UNDEFINED, 0, NULL);+ JS_FreeValue(s->c, r);+}+static void js_teardown(void *st) {+ JsState *s = st;+ JS_FreeValue(s->c, s->fn);+ JS_FreeContext(s->c);+ JS_FreeRuntime(s->rt);+ free(s);+}++double lb_js(int threads, double secs) { return timed_run(threads, secs, js_setup, js_unit, js_teardown); }++/* ---- memory bandwidth ---- */++typedef struct {+ double *a, *b, *c;+ size_t n; /* doubles per array */+ int threads, triad;+ double secs;+ double bytes[LB_MAX_THREADS];+} Bw;++static void bw_thread(void *arg, int t) {+ Bw *w = arg;+ size_t per = w->n / (size_t)w->threads, lo = per * (size_t)t, hi = t == w->threads - 1 ? w->n : lo + per;+ double *a = w->a, *b = w->b, *c = w->c, s = 3.0;+ for (size_t i = lo; i < hi; i++) { a[i] = 1.0; b[i] = 2.0; c[i] = 0.0; } /* first touch on this thread */+ double end = bench_now_ms() + w->secs * 1000, bytes = 0;+ do {+ if (w->triad) { for (size_t i = lo; i < hi; i++) a[i] = b[i] + s * c[i]; bytes += 3.0 * (double)(hi - lo) * sizeof(double); }+ else { for (size_t i = lo; i < hi; i++) c[i] = a[i]; bytes += 2.0 * (double)(hi - lo) * sizeof(double); }+ } while (bench_now_ms() < end);+ w->bytes[t] = bytes;+}++static double bandwidth(int threads, size_t mb, double secs, int triad) {+ static Bw w;+ memset(&w, 0, sizeof w);+ if (threads > LB_MAX_THREADS) threads = LB_MAX_THREADS;+ w.n = mb * (1 << 20) / sizeof(double);+ w.a = aligned_alloc(64, w.n * sizeof(double));+ w.b = aligned_alloc(64, w.n * sizeof(double));+ w.c = aligned_alloc(64, w.n * sizeof(double));+ double r = -1;+ if (w.a && w.b && w.c) {+ w.threads = threads;+ w.triad = triad;+ w.secs = secs;+ double ms = lb_parallel(threads, bw_thread, &w);+ double bytes = 0;+ for (int i = 0; i < threads; i++) bytes += w.bytes[i];+ /* the first pass touched the pages: it's part of ms, a little pessimistic on purpose */+ if (ms > 0) r = bytes / 1e9 / (ms / 1000);+ }+ free(w.a);+ free(w.b);+ free(w.c);+ return r;+}++double lb_mem_copy(int threads, size_t mb, double secs) { return bandwidth(threads, mb, secs, 0); }+double lb_mem_triad(int threads, size_t mb, double secs) { return bandwidth(threads, mb, secs, 1); }++static uint64_t xs(uint64_t *s) { uint64_t x = *s; x ^= x << 13; x ^= x >> 7; x ^= x << 17; return *s = x; }++double lb_mem_latency(size_t mb, long hops) {+ size_t n = mb * (1 << 20) / 64; /* one node per cache line */+ if (n < 2) return -1;+ size_t *buf = aligned_alloc(64, n * 64);+ size_t *perm = malloc(n * sizeof *perm);+ if (!buf || !perm) { free(buf); free(perm); return -1; }+ for (size_t i = 0; i < n; i++) perm[i] = i;+ uint64_t seed = 0x9e3779b97f4a7c15ull;+ for (size_t i = n - 1; i > 0; i--) { /* Sattolo: one cycle through every node */+ size_t j = (size_t)(xs(&seed) % i);+ size_t t = perm[i]; perm[i] = perm[j]; perm[j] = t;+ }+ for (size_t i = 0; i < n; i++) buf[perm[i] * 8] = perm[(i + 1) % n] * 8;+ free(perm);+ volatile size_t sink;+ size_t p = 0;+ for (long i = 0; i < hops / 10; i++) p = buf[p]; /* warm the TLB a little */+ double t0 = bench_now_ms();+ for (long i = 0; i < hops; i++) p = buf[p];+ double ms = bench_now_ms() - t0;+ sink = p;+ (void)sink;+ free(buf);+ return ms * 1e6 / (double)hops;+}++/* ---- storage ---- */++int lb_disk(int fd, size_t mb, double secs, double *seq_w, double *seq_r, double *rand_iops) {+ *seq_w = *seq_r = *rand_iops = -1;+ const size_t blk = 1 << 20;+ uint8_t *b = aligned_alloc(4096, blk);+ if (!b || mb < 8) { free(b); return -1; }+ uint64_t seed = 0x1234567ull;+ for (size_t i = 0; i < blk / 8; i++) ((uint64_t *)b)[i] = xs(&seed); /* doesn't compress */+ int rc = -1;+ if (ftruncate(fd, 0)) goto out;+ double t0 = bench_now_ms();+ for (size_t i = 0; i < mb; i++) {+ b[0] = (uint8_t)i;+ if (pwrite(fd, b, blk, (off_t)(i * blk)) != (ssize_t)blk) goto out;+ }+ if (fdatasync(fd)) goto out;+ double ms = bench_now_ms() - t0;+ *seq_w = mb / (ms / 1000);+ posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); /* read from the device, not the page cache */+ t0 = bench_now_ms();+ for (size_t i = 0; i < mb; i++) if (pread(fd, b, blk, (off_t)(i * blk)) != (ssize_t)blk) goto out;+ ms = bench_now_ms() - t0;+ *seq_r = mb / (ms / 1000);+ posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);+ size_t pages = mb * (blk / 4096);+ double end = bench_now_ms() + secs * 1000, n = 0;+ t0 = bench_now_ms();+ do {+ size_t pg = (size_t)(xs(&seed) % pages);+ if (pread(fd, b, 4096, (off_t)(pg * 4096)) != 4096) goto out;+ n++;+ } while (bench_now_ms() < end);+ ms = bench_now_ms() - t0;+ *rand_iops = n / (ms / 1000);+ rc = 0;+out:+ if (ftruncate(fd, 0)) rc = -1; /* give the space back */+ free(b);+ return rc;+}++/* ---- sustained load ---- */++typedef struct { atomic_int stop; atomic_long done; } Sus;+static void sus_thread(void *arg, int t) {+ (void)t;+ Sus *s = arg;+ Mat *m = mat_setup();+ if (!m) return;+ while (!atomic_load_explicit(&s->stop, memory_order_relaxed)) { mat_unit(m); atomic_fetch_add_explicit(&s->done, 1, memory_order_relaxed); }+ free(m);+}+typedef struct { Sus *s; int n; } SusArgs;+static void *sus_workers(void *p) {+ SusArgs *a = p;+ lb_parallel(a->n, sus_thread, a->s);+ return NULL;+}++void lb_sustained(int threads, double secs, double interval_s, void (*sample)(double, double, void *), void *ctx) {+ static Sus s;+ atomic_store(&s.stop, 0);+ atomic_store(&s.done, 0);+ SusArgs a = { &s, threads };+ pthread_t w;+ if (pthread_create(&w, NULL, sus_workers, &a)) return;+ double t0 = bench_now_ms(), last_t = t0;+ long last = 0;+ while ((bench_now_ms() - t0) < secs * 1000) {+ struct timespec ts = { (time_t)interval_s, (long)((interval_s - (time_t)interval_s) * 1e9) };+ nanosleep(&ts, NULL);+ double now = bench_now_ms();+ long d = atomic_load(&s.done);+ sample((double)(d - last) * MAT_FLOP / 1e9 / ((now - last_t) / 1000), (now - t0) / 1000, ctx);+ last = d;+ last_t = now;+ }+ atomic_store(&s.stop, 1);+ pthread_join(w, NULL);+}++/* ---- statistics ---- */++static int cmp_d(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return (x > y) - (x < y); }++double lb_median(double *v, int n, double *spread) {+ if (n <= 0) { if (spread) *spread = 0; return -1; }+ qsort(v, (size_t)n, sizeof *v, cmp_d);+ if (spread) *spread = v[n - 1] - v[0];+ return n % 2 ? v[n / 2] : (v[n / 2 - 1] + v[n / 2]) / 2;+}diff --git a/server/src/bench/lbwork.h b/server/src/bench/lbwork.hnew file mode 100644index 0000000..88bc6c9--- /dev/null+++ b/server/src/bench/lbwork.h@@ -0,0 +1,38 @@+/* lbwork.h — LordBench's CPU, memory and storage workloads (docs/BENCHMARK.md, "Workloads"). Pure+ * computation on memory the caller gives or allocates, plus one fd for storage: no paths, no network.+ * Used by lord-bench (lbmain.c) and tested in tests/lordbench_test.c. Each returns a rate (higher is+ * better) or, for latency, nanoseconds; a value < 0 means it could not run (out of memory, an I/O error). */+#ifndef LORD_BENCH_LBWORK_H+#define LORD_BENCH_LBWORK_H++#include <stddef.h>++/* runs fn(arg, thread_index) on n threads at once (n ≥ 1; thread 0 is the caller) and returns the+ * wall time in ms from the moment all of them were released; -1 if a thread couldn't start */+double lb_parallel(int n, void (*fn)(void *arg, int t), void *arg);++double lb_sha256(int threads, double secs); /* MB/s hashed, summed over the threads */+double lb_matmul(int threads, double secs); /* GFLOP/s, a 256×256 double matrix product per thread */+/* the package engine's own xz decoder (pkg/xz.c) on a fixed compressed text (build/gen/lb_corpus.h):+ * MB/s of output, summed over the threads */+double lb_xz(int threads, double secs);+/* QuickJS running a fixed script (strings, JSON, sorting, objects, a regular expression), one runtime+ * per thread: runs per second, summed */+double lb_js(int threads, double secs);++/* memory bandwidth over arrays of mb MB each, split across the threads: GB/s */+double lb_mem_copy(int threads, size_t mb, double secs);+double lb_mem_triad(int threads, size_t mb, double secs);+double lb_mem_latency(size_t mb, long hops); /* ns per dependent load, one thread */++/* storage on fd (a scratch file lord-server opened, read and write), mb MB at most:+ * sequential write and read in MB/s, then random 4 KiB reads for secs, in IOPS */+int lb_disk(int fd, size_t mb, double secs, double *seq_w, double *seq_r, double *rand_iops);++/* sustained all-core load: calls sample(gflops, t_s, ctx) every interval_s for secs seconds */+void lb_sustained(int threads, double secs, double interval_s, void (*sample)(double gflops, double t_s, void *ctx), void *ctx);++/* the median of v[0..n) (sorted in place) and its spread max − min */+double lb_median(double *v, int n, double *spread);++#endifdiff --git a/server/src/ui/js_hw.c b/server/src/ui/js_hw.cindex ca3ae24..eec9328 100644--- a/server/src/ui/js_hw.c+++ b/server/src/ui/js_hw.c@@ -32,6 +32,11 @@* the system package `sysprobe`, app/probe.c), or null* lord.sysinfo.markdown() the same report as Markdown, as lordos-sysreport prints it,* with a "This session" section (System Information's Report tab)+ * lord.sysinfo.bench.start(mode, sustainedS) / poll() / cancel() / saved(which) / boots()+ * LordBench (bench/lbrun.c, the lord-bench helper): mode+ * 'quick' | 'full'; poll() → {state, step, progress, result};+ * saved(0|1) the last or previous result; boots() the boot+ * times per LordOS version (lord-sessiond's history)* lord.fan.status() / setProfile(p) / setCurve(pts) / force(v) / caseConfig() (js_fan.c, lord-fand)* lord.browserFrame.apply(on, which) Settings → Appearance → "Browsers: tabs in the title bar":* one preference in the user's Chromium/Firefox profiles@@ -52,6 +57,7 @@#include "../gpu/gpu.h"#include "../sysreport/sysreport.h"#include "../sysreport/facts.h"+#include "../bench/lbrun.h"#include "../sec/broker.h"#include "lord_version.h" /* build/gen: the version for the report */#include "../hw/mimeapps.h"@@ -466,6 +472,91 @@ static JSValue f_sysinfo_probe(JSContext *c, JSValueConst t, int argc, JSValueCoreturn j ? JS_ParseJSON(c, j, strlen(j), "<probe>") : JS_NULL;}+/* ---- lord.sysinfo.bench (LordBench) ---- */++/* what a result records about this session: how the screen is composed and each active display's+ * connector, mode, refresh, scale and rotation (no names, vendors or identities) */+static char *bench_session_json(JSContext *c) {+ GpuInfo g;+ gpu_info(&g);+ JSValue o = JS_NewObject(c);+ JS_SetPropertyStr(c, o, "composition", JS_NewString(c, lord_composition()));+ JS_SetPropertyStr(c, o, "gpuInit", JS_NewString(c, g.why ? g.why : ""));+ JS_SetPropertyStr(c, o, "renderer", JS_NewString(c, g.renderer ? g.renderer : ""));+ JSValue outs = JS_NewArray(c);+ JSValue d = json_or_null(c, display_list_json());+ JSValue list = JS_IsObject(d) ? JS_GetPropertyStr(c, d, "outputs") : JS_UNDEFINED;+ uint32_t k = 0;+ for (uint32_t i = 0; JS_IsArray(c, list) && i < 16; i++) {+ JSValue e = JS_GetPropertyUint32(c, list, i);+ if (!JS_IsObject(e)) { JS_FreeValue(c, e); break; }+ JSValue act = JS_GetPropertyStr(c, e, "active");+ if (JS_ToBool(c, act) > 0) {+ JSValue x = JS_NewObject(c);+ static const char *const keep[] = { "connector", "builtin", "mode", "scale", "rotation" };+ for (int f = 0; f < 5; f++) JS_SetPropertyStr(c, x, keep[f], JS_GetPropertyStr(c, e, keep[f]));+ JS_SetPropertyUint32(c, outs, k++, x);+ }+ JS_FreeValue(c, act);+ JS_FreeValue(c, e);+ }+ JS_FreeValue(c, list);+ JS_FreeValue(c, d);+ JS_SetPropertyStr(c, o, "displays", outs);+ JSValue str = JS_JSONStringify(c, o, JS_UNDEFINED, JS_UNDEFINED);+ JS_FreeValue(c, o);+ const char *s = JS_ToCString(c, str);+ char *r = s ? strdup(s) : NULL;+ if (s) JS_FreeCString(c, s);+ JS_FreeValue(c, str);+ return r;+}++static JSValue f_bench_start(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t;+ const char *mode = argc > 0 ? JS_ToCString(c, argv[0]) : NULL;+ if (!mode) return JS_FALSE;+ int sus = argc > 1 ? arg_int(c, argv[1], 0) : 0;+ char *extra = bench_session_json(c);+ int r = lbrun_start(mode, sus, extra);+ free(extra);+ JS_FreeCString(c, mode);+ return JS_NewBool(c, r == 0);+}++static JSValue f_bench_poll(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t; (void)argc; (void)argv;+ return json_or_null(c, lbrun_poll());+}++static JSValue f_bench_cancel(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)c; (void)t; (void)argc; (void)argv;+ lbrun_cancel();+ return JS_UNDEFINED;+}++static JSValue f_bench_saved(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t;+ int which = argc > 0 ? arg_int(c, argv[0], 0) : 0;+ if (which != 0 && which != 1) return JS_NULL;+ JSValue v = json_or_null(c, lbrun_saved(which));+ if (JS_IsException(v)) { JS_FreeValue(c, JS_GetException(c)); return JS_NULL; }+ return v;+}++static JSValue f_bench_boots(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t; (void)argc; (void)argv;+ return json_or_null(c, lbrun_boot_history("/var/lib/lordos/boot-times.jsonl"));+}++static const JSCFunctionListEntry bench_funcs[] = {+ JS_CFUNC_DEF("start", 2, f_bench_start),+ JS_CFUNC_DEF("poll", 0, f_bench_poll),+ JS_CFUNC_DEF("cancel", 0, f_bench_cancel),+ JS_CFUNC_DEF("saved", 1, f_bench_saved),+ JS_CFUNC_DEF("boots", 0, f_bench_boots),+};+static const JSCFunctionListEntry sysinfo_funcs[] = {JS_CFUNC_DEF("report", 0, f_sysinfo_report),JS_CFUNC_DEF("probe", 0, f_sysinfo_probe),@@ -547,6 +638,11 @@ void js_hw_register(JSContext *c, JSValue lord) {add(c, lord, "notifyd", nd_funcs, sizeof nd_funcs / sizeof nd_funcs[0]);add(c, lord, "hwinfo", hwinfo_funcs, sizeof hwinfo_funcs / sizeof hwinfo_funcs[0]);add(c, lord, "sysinfo", sysinfo_funcs, sizeof sysinfo_funcs / sizeof sysinfo_funcs[0]);+ JSValue si = JS_GetPropertyStr(c, lord, "sysinfo");+ JSValue bo = JS_NewObject(c);+ JS_SetPropertyFunctionList(c, bo, bench_funcs, sizeof bench_funcs / sizeof bench_funcs[0]);+ JS_SetPropertyStr(c, si, "bench", bo);+ JS_FreeValue(c, si);add(c, lord, "browserFrame", brf_funcs, sizeof brf_funcs / sizeof brf_funcs[0]);js_fan_register(c, lord); /* lord.fan: Settings → Cooling and Monitor (js_fan.c) */}diff --git a/server/tests/lordbench_cli.c b/server/tests/lordbench_cli.cnew file mode 100644index 0000000..e0ea3af--- /dev/null+++ b/server/tests/lordbench_cli.c@@ -0,0 +1,25 @@+/* lordbench_cli.c — runs LordBench from a terminal through lord-server's own code (bench/lbrun.c), with+ * build/lord-bench next to it: `build/lordbench-cli quick|full [sustained_s]`. For checking the helper+ * and its sandbox on a machine without a session; prints the result JSON. */+#include "../src/bench/lbrun.h"++#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <time.h>++int main(int argc, char **argv) {+ if (argc < 2) { fprintf(stderr, "usage: lordbench-cli quick|full [sustained_s]\n"); return 2; }+ if (lbrun_start(argv[1], argc > 2 ? atoi(argv[2]) : 0, "{\"cli\":true}")) { fprintf(stderr, "refused\n"); return 1; }+ char last[64] = "";+ for (;;) {+ struct timespec ts = { 0, 250 * 1000 * 1000 };+ nanosleep(&ts, NULL);+ char *p = lbrun_poll();+ if (!p) return 1;+ char *s = strstr(p, "\"step\":\"");+ if (s && strncmp(s, last, sizeof last - 1)) { snprintf(last, sizeof last, "%.63s", s); fprintf(stderr, "%.60s\n", s + 8); }+ if (!strstr(p, "\"state\":\"waiting\"") && !strstr(p, "\"state\":\"running\"")) { puts(p); free(p); return 0; }+ free(p);+ }+}diff --git a/server/tests/lordbench_test.c b/server/tests/lordbench_test.cnew file mode 100644index 0000000..360895e--- /dev/null+++ b/server/tests/lordbench_test.c@@ -0,0 +1,196 @@+/* lordbench_test.c — LordBench without the helper process (docs/BENCHMARK.md, "0.8.6 — LordBench"): the+ * records lord-server accepts from lord-bench, short runs of every CPU, memory and storage workload, the+ * conditions read from fake sysfs trees (temperatures and trip points, throttle counters, the Pi's+ * flags, batteries) with the thermal and battery guards, and the boot history per version. */+#include "../src/bench/lbproto.h"+#include "../src/bench/lbwork.h"+#include "../src/bench/lbcond.h"+#include "../src/bench/lbrun.h"++#include <fcntl.h>+#include <math.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/stat.h>+#include <unistd.h>++static int fails, oks;+#define CHECK(c, ...) do { if (c) oks++; else { fails++; printf("FAIL %s:%d: ", __FILE__, __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)++static char root[256];+static void put(const char *rel, const char *text) {+ char p[512];+ snprintf(p, sizeof p, "%s%s", root, rel);+ for (char *s = p + strlen(root) + 1; (s = strchr(s, '/')); s++) { *s = 0; mkdir(p, 0755); *s = '/'; }+ FILE *f = fopen(p, "w");+ if (!f) { printf("can't write %s\n", p); exit(1); }+ fputs(text, f);+ fclose(f);+}++static LbMsg msg(uint32_t kind, uint32_t id, double v, double aux) { LbMsg m = { LB_MAGIC, kind, id, 0, v, aux }; return m; }++int main(void) {+ /* ---- records ---- */+ LbMsg m = msg(LB_MSG_RESULT, LB_CPU_SHA1, 1200, 15);+ CHECK(lb_msg_valid(&m), "a good result");+ m.magic = 1;+ CHECK(!lb_msg_valid(&m), "bad magic");+ m = msg(LB_MSG_RESULT, LB_COUNT, 1, 0);+ CHECK(!lb_msg_valid(&m), "id out of range");+ m = msg(LB_MSG_RESULT, LB_CPU_SHA1, NAN, 0);+ CHECK(!lb_msg_valid(&m), "NaN");+ m = msg(LB_MSG_RESULT, LB_CPU_SHA1, -5, 0);+ CHECK(!lb_msg_valid(&m), "a negative rate");+ m = msg(LB_MSG_RESULT, LB_CPU_SHA1, INFINITY, 0);+ CHECK(!lb_msg_valid(&m), "infinity");+ m = msg(LB_MSG_SKIP, LB_GPU_SCENE, 0, LB_SKIP_NODEV);+ CHECK(lb_msg_valid(&m), "a skip");+ m = msg(LB_MSG_SKIP, LB_GPU_SCENE, 0, 99);+ CHECK(!lb_msg_valid(&m), "an unknown skip reason");+ m = msg(77, 0, 0, 0);+ CHECK(!lb_msg_valid(&m), "an unknown kind");+ m = msg(LB_MSG_GPUINFO, 0, 3, 0);+ CHECK(!lb_msg_valid(&m), "an unknown GPU kind");+ for (int i = 0; i < LB_COUNT; i++) {+ CHECK(lb_name(i) && lb_unit(i), "names for %d", i);+ for (int k = 0; k < i; k++) CHECK(strcmp(lb_name(i), lb_name(k)), "unique %s", lb_name(i));+ }+ CHECK(!lb_name(LB_COUNT) && !lb_name(-1), "names out of range");++ /* ---- workloads, short ---- */+ double v;+ CHECK((v = lb_sha256(1, 0.1)) > 1, "sha256 %f", v);+ CHECK((v = lb_sha256(2, 0.1)) > 1, "sha256 x2 %f", v);+ CHECK((v = lb_matmul(1, 0.1)) > 0.01, "matmul %f", v);+ CHECK((v = lb_xz(1, 0.1)) > 1, "xz %f", v);+ CHECK((v = lb_js(1, 0.2)) > 0.5, "js %f", v);+ CHECK((v = lb_js(2, 0.2)) > 0.5, "js x2 %f", v);+ CHECK((v = lb_mem_copy(2, 8, 0.1)) > 0.05, "copy %f", v);+ CHECK((v = lb_mem_triad(2, 8, 0.1)) > 0.05, "triad %f", v);+ CHECK((v = lb_mem_latency(8, 200000)) > 0.1 && v < 10000, "latency %f", v);+ char tmpl[] = "/tmp/lordbench-disk-XXXXXX";+ int fd = mkstemp(tmpl);+ unlink(tmpl);+ double w, r, iops;+ CHECK(fd >= 0 && lb_disk(fd, 16, 0.2, &w, &r, &iops) == 0 && w > 0 && r > 0 && iops > 0, "disk %f %f %f", w, r, iops);+ struct stat st;+ CHECK(fd >= 0 && !fstat(fd, &st) && st.st_size == 0, "the scratch file is emptied");+ if (fd >= 0) close(fd);+ double a[] = { 5, 1, 3 }, sp;+ CHECK(lb_median(a, 3, &sp) == 3 && sp == 4, "median");+ double b2[] = { 4, 2 };+ CHECK(lb_median(b2, 2, &sp) == 3, "median of two");++ /* ---- conditions on a fake tree ---- */+ snprintf(root, sizeof root, "/tmp/lordbench-root-XXXXXX");+ if (!mkdtemp(root)) return 1;+ put("/sys/class/thermal/thermal_zone0/type", "x86_pkg_temp\n");+ put("/sys/class/thermal/thermal_zone0/temp", "61000\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_type", "passive\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_temp", "95000\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_1_type", "critical\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_1_temp", "105000\n");+ put("/sys/class/thermal/thermal_zone1/type", "acpitz\n");+ put("/sys/class/thermal/thermal_zone1/temp", "40000\n");+ put("/sys/class/thermal/thermal_zone1/trip_point_0_type", "critical\n");+ put("/sys/class/thermal/thermal_zone1/trip_point_0_temp", "0\n"); /* a placeholder: ignored */+ put("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "2400000\n");+ put("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "4200000\n");+ put("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "powersave\n");+ put("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", "3\n");+ put("/sys/devices/system/cpu/cpu0/thermal_throttle/package_throttle_count", "1\n");+ put("/sys/class/power_supply/BAT0/type", "Battery\n");+ put("/sys/class/power_supply/BAT0/status", "Discharging\n");+ put("/sys/class/power_supply/BAT0/capacity", "25\n");+ put("/sys/class/power_supply/AC/type", "Mains\n");+ put("/sys/class/power_supply/AC/online", "0\n");+ put("/sys/class/power_supply/hidpp_battery_0/type", "Battery\n");+ put("/sys/class/power_supply/hidpp_battery_0/scope", "Device\n");+ put("/sys/class/power_supply/hidpp_battery_0/capacity", "90\n");+ put("/proc/stat", "cpu 100 0 50 800 50 0 0 0 0 0\ncpu0 1 2 3\n");+ LbCond c0, c1;+ lb_cond_read(root, &c0);+ CHECK(c0.temp_c == 61 && !strcmp(c0.zone, "x86_pkg_temp"), "hottest zone %f %s", c0.temp_c, c0.zone);+ CHECK(c0.passive_c == 95 && c0.critical_c == 105, "trips %f %f", c0.passive_c, c0.critical_c);+ CHECK(c0.throttle_known && c0.throttle_events == 4, "throttle counters %lu", c0.throttle_events);+ CHECK(c0.freq_mhz == 2400 && c0.freq_max_mhz == 4200 && !strcmp(c0.governor, "powersave"), "cpufreq");+ CHECK(c0.on_battery == 1 && c0.battery_pct == 25, "battery %d %d (a mouse's battery ignored)", c0.on_battery, c0.battery_pct);+ CHECK(lb_cond_battery_low(&c0), "below 30 %% on battery: refused");+ CHECK(c0.rpi_throttled == -1, "no Pi firmware");+ CHECK(!lb_cond_stop(&c0, &c0, 1), "nothing to stop at 61 °C");+ put("/sys/class/thermal/thermal_zone0/temp", "93500\n");+ lb_cond_read(root, &c1);+ CHECK(lb_cond_stop(&c0, &c1, 0) && !strcmp(lb_cond_stop(&c0, &c1, 0), "thermal"), "within 2 °C of passive: thermal");+ put("/sys/class/thermal/thermal_zone0/temp", "70000\n");+ put("/sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count", "5\n");+ lb_cond_read(root, &c1);+ CHECK(lb_cond_stop(&c0, &c1, 1) && !strcmp(lb_cond_stop(&c0, &c1, 1), "throttled"), "throttle counters grew in a peak test");+ CHECK(!lb_cond_stop(&c0, &c1, 0), "…recorded but not stopped in the sustained test");+ put("/sys/class/power_supply/AC/online", "1\n");+ put("/sys/class/power_supply/BAT0/status", "Charging\n");+ lb_cond_read(root, &c1);+ CHECK(c1.on_battery == 0 && !lb_cond_battery_low(&c1), "on mains");+ unsigned long long busy, total;+ CHECK(!lb_cpu_ticks(root, &busy, &total) && total == 1000 && busy == 150, "/proc/stat %llu/%llu", busy, total);++ /* a Raspberry Pi 5: no passive trip, the firmware's flags, hwmon's under-voltage alarm */+ snprintf(root, sizeof root, "/tmp/lordbench-pi-XXXXXX");+ if (!mkdtemp(root)) return 1;+ put("/sys/class/thermal/thermal_zone0/type", "cpu-thermal\n");+ put("/sys/class/thermal/thermal_zone0/temp", "55000\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_type", "critical\n");+ put("/sys/class/thermal/thermal_zone0/trip_point_0_temp", "110000\n");+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "0\n");+ lb_cond_read(root, &c0);+ CHECK(c0.rpi_throttled == 0 && c0.passive_c == 0 && c0.critical_c == 110, "Pi: flags %d trips %f %f", c0.rpi_throttled, c0.passive_c, c0.critical_c);+ CHECK(c0.on_battery == -1 && c0.battery_pct == -1, "Pi: no power_supply");+ put("/sys/class/thermal/thermal_zone0/temp", "101000\n");+ lb_cond_read(root, &c1);+ CHECK(lb_cond_stop(&c0, &c1, 0) && !strcmp(lb_cond_stop(&c0, &c1, 0), "thermal"), "Pi: within 10 °C of critical");+ put("/sys/class/thermal/thermal_zone0/temp", "80000\n");+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "50005\n");+ lb_cond_read(root, &c1);+ CHECK(c1.rpi_throttled == 0x50005, "Pi flags %#x", c1.rpi_throttled);+ CHECK(lb_cond_stop(&c0, &c1, 1) && !strcmp(lb_cond_stop(&c0, &c1, 1), "throttled"), "Pi: throttled now");+ put("/sys/devices/platform/soc/soc:firmware/get_throttled", "50000\n"); /* only "since boot" bits */+ put("/sys/class/hwmon/hwmon0/name", "rpi_volt\n");+ put("/sys/class/hwmon/hwmon0/in0_lcrit_alarm", "1\n");+ lb_cond_read(root, &c1);+ CHECK(!lb_cond_stop(&c0, &c1, 1) && (c1.rpi_throttled & LB_RPI_UV), "Pi: past events and under-voltage recorded, not a stop (%#x)", c1.rpi_throttled);++ /* ---- boot history ---- */+ char bt[] = "/tmp/lordbench-boots-XXXXXX";+ fd = mkstemp(bt);+ const char *lines =+ "{\"bootId\":\"a\",\"at\":1,\"seconds\":30.000,\"shown\":\"desktop\",\"version\":\"0.8.4-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"b\",\"at\":2,\"seconds\":20.000,\"shown\":\"desktop\",\"version\":\"0.8.4-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"c\",\"at\":3,\"seconds\":22.000,\"shown\":\"desktop\",\"version\":\"0.8.4-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"d\",\"at\":4,\"seconds\":40.000,\"shown\":\"greeter\",\"version\":\"0.8.5-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"e\",\"at\":5,\"seconds\":18.000,\"shown\":\"greeter\",\"version\":\"0.8.5-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"f\",\"at\":6,\"seconds\":21.000,\"shown\":\"greeter\",\"version\":\"0.8.5-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"g\",\"at\":7,\"seconds\":19.000,\"shown\":\"greeter\",\"version\":\"0.8.5-beta\",\"build\":\"x\",\"kernel\":\"k\"}\n"+ "{\"bootId\":\"h\",\"at\":8,\"seconds\":\"x\",\"version\":\"0.8.5\\\"evil\"}\n";+ CHECK(fd >= 0 && write(fd, lines, strlen(lines)) == (ssize_t)strlen(lines), "boot file");+ fchmod(fd, 0644);+ close(fd);+ char *h = lbrun_boot_history(bt);+ CHECK(h && strstr(h, "{\"version\":\"0.8.4-beta\",\"boots\":2,\"median\":21.00,\"min\":20.00,\"max\":22.00,\"first\":30.00}"), "0.8.4: %s", h ? h : "null");+ CHECK(h && strstr(h, "{\"version\":\"0.8.5-beta\",\"boots\":3,\"median\":19.00,\"min\":18.00,\"max\":21.00,\"first\":40.00}"), "0.8.5: %s", h ? h : "null");+ CHECK(h && !strstr(h, "evil"), "a bad line is skipped");+ free(h);+ chmod(bt, 0666);+ CHECK(!(h = lbrun_boot_history(bt)), "a file others can write is refused");+ free(h);+ unlink(bt);++ /* ---- the run's state without a helper ---- */+ char *p = lbrun_poll();+ CHECK(p && strstr(p, "\"state\":\"idle\""), "idle: %s", p ? p : "null");+ free(p);+ CHECK(lbrun_start("turbo", 0, NULL) == -1 && lbrun_start("full", 5, NULL) == -1, "bad arguments refused");++ printf("lordbench-test: %d ok, %d failed\n", oks, fails);+ return fails != 0;+}diff --git a/server/tests/run_suites.sh b/server/tests/run_suites.shindex 8ab105b..7248429 100644--- a/server/tests/run_suites.sh+++ b/server/tests/run_suites.sh@@ -174,6 +174,9 @@ EOF# (0.8.5) System Information's model (apps/sysinfo/model.js): GPU layers, CPU reasons, Compatibilityif have node; then run "sysinfo-model-test (apps/sysinfo/model.js)" node tests/sysinfo_model_test.mjselse skip "sysinfo-model-test" "node"; fi+ # (0.8.6) LordBench's model (apps/sysinfo/perf.js): references, verdicts, comparisons+ if have node; then run "sysinfo-perf-test (apps/sysinfo/perf.js)" node tests/sysinfo_perf_test.mjs+ else skip "sysinfo-perf-test" "node"; fi# (0.8.5) Settings → Displays' arrangement (sdk/displaylayout.js): numbers, magnetic snap, valid dropsif have node; then run "display-layout-test (sdk/displaylayout.js)" node tests/display_layout_test.mjselse skip "display-layout-test" "node"; fidiff --git a/server/tests/sysinfo_perf_test.mjs b/server/tests/sysinfo_perf_test.mjsnew file mode 100644index 0000000..b72a624--- /dev/null+++ b/server/tests/sysinfo_perf_test.mjs@@ -0,0 +1,70 @@+// sysinfo_perf_test.mjs — LordBench's model (apps/sysinfo/perf.js, 0.8.6): ratios against the reference+// machines, category means, the stability and compatibility verdicts, comparisons with the previous+// result and the conditions that differ. Run by tests/run_suites.sh (needs node).+import { CATEGORIES, REFERENCES, ratio, categoryRatios, comparableReferences, stability, compatibilityVerdict, conditionDiffs, changes, sustainedSeries, refreshBudget, fileName } from '../../apps/sysinfo/perf.js';++let n = 0, bad = 0;+const eq = (what, got, want) => {+ n++;+ const g = JSON.stringify(got), w = JSON.stringify(want);+ if (g !== w) { bad++; console.log(`✗ ${what}\n got ${g}\n want ${w}`); }+};+const near = (what, got, want) => eq(what, got != null && Math.abs(got - want) < 1e-9, true);++const res = (over = {}) => ({+ lordbench: 1, mode: 'full', status: 'done', stopReason: '', threads: 4, live: false, gpuKind: 'hardware', lordos: '0.8.6', kernel: 'k',+ quiet: { quiet: true, busyPct: 2 }, before: { power: 'mains', governor: 'schedutil' }, after: { power: 'mains' }, storage: { kind: 'nvme' },+ session: { composition: 'gpu', displays: [{ mode: { w: 1920, h: 1080, refresh: 60000 } }, { mode: { w: 2560, h: 1440, refresh: 144000 } }] },+ results: { 'cpu.sha256.1': { value: 200 }, 'cpu.matmul.1': { value: 8 }, 'mem.latency': { value: 45, lowerBetter: true },+ 'sustained.start': { value: 50 }, 'sustained.end': { value: 49 } },+ skipped: {}, ...over,+});+const ref = { lordbench: 1, results: { 'cpu.sha256.1': { value: 100 }, 'cpu.matmul.1': { value: 2 }, 'mem.latency': { value: 90 } } };++// every measurement lord-bench reports is in exactly one category+const ids = CATEGORIES.flatMap((c) => c.ids);+eq('20 measurements, no repeats', [ids.length, new Set(ids).size], [20, 20]);+eq('references have every measurement', REFERENCES.every((r) => ids.every((id) => r.results[id] && r.results[id].value > 0)), true);++near('×2 SHA', ratio(res(), ref, 'cpu.sha256.1'), 2);+near('latency: lower is better', ratio(res(), ref, 'mem.latency'), 2);+eq('missing on one side', ratio(res(), ref, 'gpu.scene'), null);+const cr = categoryRatios(res(), ref);+near('CPU: geometric mean of ×2 and ×4', cr.cpu, Math.sqrt(8));+eq('no GPU numbers: null', cr.gpu, null);+eq('only the same LordBench version', comparableReferences({ lordbench: 99 }).length, 0);++// stability+eq('clean run passes', stability(res()), { state: 'pass', notes: [] });+eq('failed', stability(res({ status: 'failed', stopReason: 'helper' })).state, 'fail');+eq('thermal stop', stability(res({ status: 'stopped', stopReason: 'thermal' })).notes[0].id, 'stoppedThermal');+eq('throttle counters grew', stability(res({ before: { throttleEvents: 2 }, after: { throttleEvents: 5 } })).notes, [{ id: 'throttleSeen', vars: { count: 3 } }]);+eq('Pi throttling and under-voltage', stability(res({ after: { rpiThrottled: 0x50005 } })).notes.map((x) => x.id), ['piThrottled', 'underVoltage']);+eq('Pi: only past events', stability(res({ after: { rpiThrottled: 0x50000 } })).state, 'pass');+eq('sustained dropped 20 %', stability(res({ results: { 'sustained.start': { value: 50 }, 'sustained.end': { value: 40 } } })).notes, [{ id: 'sustainedDrop', vars: { pct: 20 } }]);+eq('not quiet', stability(res({ quiet: { quiet: false, busyPct: 37.4 } })).notes, [{ id: 'notQuiet', vars: { pct: 37 } }]);+eq('a measurement failed', stability(res({ skipped: { 'gpu.scene': 'failed', 'disk.seqread': 'mode' } })).notes, [{ id: 'measureFailed', vars: { count: 1 } }]);++eq('compatibility: limits warn', compatibilityVerdict([{ state: 'works' }, { state: 'limits' }, { state: 'absent' }]),+ { state: 'warn', count: { works: 1, limits: 1, no: 0, absent: 1, unchecked: 0 } });+eq('compatibility: nothing', compatibilityVerdict([]).state, 'unknown');++// comparisons+eq('same conditions', conditionDiffs(res(), res()), []);+eq('battery and governor differ', conditionDiffs(res({ before: { power: 'battery', governor: 'powersave' } }), res()),+ [{ id: 'power', now: 'battery', before: 'mains' }, { id: 'governor', now: 'powersave', before: 'schedutil' }]);+const ch = changes(res({ results: { 'cpu.sha256.1': { value: 220 }, 'mem.latency': { value: 50, lowerBetter: true } } }), res());+near('+10 %', ch['cpu.sha256.1'], 0.1);+near('latency got worse', ch['mem.latency'], 45 / 50 - 1);+eq('another mode: no comparison', changes(res({ mode: 'quick' }), res()), null);+eq('another LordBench: no comparison', changes(res({ lordbench: 2 }), res()), null);++eq('samples, bad ones dropped', sustainedSeries({ sustained: { samples: [[10, 19.8, null], [20, -1, 50], 'x', [30, 19.7, 61.5]] } }), [[10, 19.8, null], [30, 19.7, 61.5]]);+near('the slowest display sets the budget', refreshBudget(res()), 1000 / 60);+eq('no displays', refreshBudget(res({ session: {} })), null);+const at = Date.UTC(2026, 9, 27, 12) / 1000;+eq('file name', fileName(at, () => false), 'lordbench-2026-10-27.json');+eq('file name taken', fileName(at, (x) => x === 'lordbench-2026-10-27.json'), 'lordbench-2026-10-27-2.json');++console.log(`sysinfo-perf-test: ${n - bad} ok, ${bad} failed`);+process.exit(bad ? 1 : 0);diff --git a/tools/iso/mkdeb.sh b/tools/iso/mkdeb.shindex 97a647e..616a40e 100755--- a/tools/iso/mkdeb.sh+++ b/tools/iso/mkdeb.sh@@ -96,6 +96,9 @@ ln -s lordos-sysreport "$PKG/usr/bin/lordos-fetch"# lord-maild: IMAP/SMTP/CalDAV/CardDAV with TLS for Mail (docs/MAIL.md); lord-server only launches the one in its own folder[ -x server/build/lord-maild ] && install -m 755 server/build/lord-maild "$L/bin/lord-maild"[ -x "$L/bin/lord-maild" ] && { "$STRIP" --strip-unneeded "$L/bin/lord-maild" 2>/dev/null || true; }+# lord-bench (0.8.6): LordBench's sandboxed workloads (docs/BENCHMARK.md); lord-server only launches the one in its own folder+[ -x server/build/lord-bench ] && install -m 755 server/build/lord-bench "$L/bin/lord-bench"+[ -x "$L/bin/lord-bench" ] && { "$STRIP" --strip-unneeded "$L/bin/lord-bench" 2>/dev/null || true; }# lord-fetch (0.8.5): downloads the subscribed blocklists over HTTPS, sandboxed (docs/FIREWALL.md, "Blocklists")[ -x server/build/lord-fetch ] && install -m 755 server/build/lord-fetch "$L/bin/lord-fetch"[ -x "$L/bin/lord-fetch" ] && { "$STRIP" --strip-unneeded "$L/bin/lord-fetch" 2>/dev/null || true; }diff --git a/web/content/faq/faq.json b/web/content/faq/faq.jsonindex 6c67e86..1e81116 100644--- a/web/content/faq/faq.json+++ b/web/content/faq/faq.json@@ -384,9 +384,9 @@"pt": "Tem suporte a Flatpak?"},"a": {- "en": "Not yet: LordOS doesn't integrate Flatpak. The Store installs Debian packages and LordOS `.lpk` apps, and isolated apps use LordOS's own sandbox.",- "es": "Todavía no: LordOS no integra Flatpak. La Tienda instala paquetes de Debian y apps `.lpk` de LordOS, y las apps aisladas usan el sandbox propio de LordOS.",- "pt": "Ainda não: o LordOS não integra o Flatpak. A Loja instala pacotes do Debian e apps `.lpk` do LordOS, e os apps isolados usam o sandbox próprio do LordOS."+ "en": "Not yet: LordOS doesn't integrate Flatpak in 0.8.5-beta. The Store installs Debian packages and LordOS `.lpk` apps, and isolated apps use LordOS's own sandbox. A Flathub section is planned for 0.8.6; its design review (how Flatpak apps keep LordOS's per-app firewall, scopes and restrictions) is written and waits for approval before any code.",+ "es": "Todavía no: LordOS 0.8.5-beta no integra Flatpak. La Tienda instala paquetes de Debian y apps `.lpk` de LordOS, y las apps aisladas usan el sandbox propio de LordOS. Para la 0.8.6 está planeada una sección de Flathub; su revisión de diseño (cómo las apps Flatpak conservan el firewall por app, los scopes y las restricciones de LordOS) está escrita y espera aprobación antes de escribir código.",+ "pt": "Ainda não: o LordOS 0.8.5-beta não integra o Flatpak. A Loja instala pacotes do Debian e apps `.lpk` do LordOS, e os apps isolados usam o sandbox próprio do LordOS. Uma seção Flathub está planejada para a 0.8.6; a revisão de design (como os apps Flatpak mantêm o firewall por app, os escopos e as restrições do LordOS) está escrita e aguarda aprovação antes de qualquer código."}},{@@ -694,6 +694,19 @@"es": "Muchos sitios de video (YouTube, por ejemplo) mandan video VP9 o AV1, que cuesta mucho procesador decodificar cuando la placa de video no puede hacerlo: las máquinas virtuales, las PC viejas y la Raspberry Pi 5 los decodifican por software. Desde la 0.8.2 LordOS revisa en cada arranque qué decodifica tu hardware y, si le falta VP9 o AV1, le pide H.264 al navegador, que es mucho más liviano. Está en Ajustes → Pantallas → Video en el navegador: **Automático** (de fábrica), **Siempre** o **Nunca**. Si igual un video pierde cuadros, el navegador muestra un aviso chico que ofrece bajar la calidad; activá **Bajar la calidad automáticamente cuando el video se traba** para que lo haga solo. En Chromium las dos partes funcionan con una extensión chica propia que viene con LordOS; Firefox por ahora solo recibe AV1 desactivado (entonces usa VP9), porque solo carga extensiones firmadas. No se envía nada a ningún lado. Si el video se sigue trabando, elegí 720p o 480p en el reproductor y, en una máquina virtual, dale más procesadores.","pt": "Muitos sites de vídeo (o YouTube, por exemplo) enviam vídeo VP9 ou AV1, que exige muito do processador para decodificar quando a placa de vídeo não consegue: máquinas virtuais, PCs antigos e o Raspberry Pi 5 os decodificam por software. Desde o 0.8.2 o LordOS verifica a cada inicialização o que o seu hardware decodifica e, se faltar VP9 ou AV1, pede H.264 ao navegador, que é muito mais leve. Fica em Ajustes → Telas → Vídeo no navegador: **Automático** (o padrão), **Sempre** ou **Nunca**. Se mesmo assim um vídeo perder quadros, o navegador mostra um pequeno aviso oferecendo uma qualidade mais baixa; ative **Baixar a qualidade automaticamente quando o vídeo travar** para isso acontecer sozinho. No Chromium as duas partes funcionam por uma pequena extensão própria que vem com o LordOS; o Firefox por enquanto só recebe o AV1 desativado (e então usa VP9), porque só carrega extensões assinadas. Nada é enviado para lugar nenhum. Se o vídeo continuar travando, escolha 720p ou 480p no player e, numa máquina virtual, dê mais processadores a ela."}+ },+ {+ "id": "benchmark",+ "q": {+ "en": "Can I measure how fast LordOS runs on my computer?",+ "es": "¿Puedo medir qué tan rápido anda LordOS en mi computadora?",+ "pt": "Posso medir quão rápido o LordOS roda no meu computador?"+ },+ "a": {+ "en": "Coming in 0.8.6 (in development; the latest release is 0.8.5-beta): System Information gets a Performance tab with LordBench, a quick and a full test of the processor, memory, graphics, disk and sustained load, run in an isolated helper that stops near the temperature limit. Results are shown against reference machines measured the same way, with the conditions of each run, never as one score, and nothing is sent anywhere.",+ "es": "Llega en la 0.8.6 (en desarrollo; la última versión es la 0.8.5-beta): Información del sistema suma una pestaña Rendimiento con LordBench, una prueba rápida y una completa del procesador, la memoria, los gráficos, el disco y la carga sostenida, que corre en un ayudante aislado y se detiene cerca del límite de temperatura. Los resultados se muestran frente a máquinas de referencia medidas de la misma forma, con las condiciones de cada prueba, nunca como un único puntaje, y no se envía nada a ningún lado.",+ "pt": "Chega na 0.8.6 (em desenvolvimento; a última versão é a 0.8.5-beta): Informações do sistema ganha uma aba Desempenho com o LordBench, um teste rápido e um completo do processador, da memória, dos gráficos, do disco e da carga contínua, executado num auxiliar isolado que para perto do limite de temperatura. Os resultados aparecem frente a máquinas de referência medidas da mesma forma, com as condições de cada teste, nunca como uma única pontuação, e nada é enviado a lugar nenhum."+ }}]},diff --git a/web/content/paper/paper.en.md b/web/content/paper/paper.en.mdindex cdcfd64..072c1de 100644--- a/web/content/paper/paper.en.md+++ b/web/content/paper/paper.en.md@@ -488,7 +488,7 @@ The Raspberry Pi 5 is the only supported board. Results on a real board (16 GB,### 7.5 Modern PCs-There are no measurements on real PCs in the repository yet. The ISO is tested on virtual machines (UEFI and BIOS); testing on a real AMD machine from the live USB is planned. LordBench (0.8.6) is designed to measure memory and CPU at idle, boot time, frame times, video and app start in a repeatable way, and community hardware reports (0.8.7) to collect them from real machines (`docs/BENCHMARK.md`).+There are no measurements on real PCs in the repository yet. The ISO is tested on virtual machines (UEFI and BIOS); testing on a real AMD machine from the live USB is planned. LordBench (0.8.6) is designed to measure memory and CPU at idle, boot time, frame times, video and app start in a repeatable way, and community hardware reports (0.8.7) to collect them from real machines (`docs/BENCHMARK.md`). In development for 0.8.6 (unreleased; the latest release is 0.8.5-beta), its first part is built: a sandboxed `lord-bench` helper that measures the CPU, memory, the GPU offscreen, storage and a sustained load, stops near the temperature limit or when the processor throttles, and records the conditions of each run, shown in System Information → Performance as "×N" of reference machines; so far the only reference is a virtual machine, and the desktop-impact, compositor and video measurements are not built.### Source files@@ -550,7 +550,7 @@ There are no measurements on real PCs in the repository yet. The ISO is tested o### 10.3 Next-Next, as planned in `docs/ROADMAP.md` and `docs/BENCHMARK.md`: **0.8.6, LordBench**, repeatable measurements of CPU, memory, GPU, the compositor, video and storage, and a Flathub section in the Store, which needs a design review first so Flatpak apps keep LordOS's app scopes, firewall and restrictions; **0.8.7, community hardware reports**, published from System Information with the user's consent; and a connection refused by the per-app firewall checked on the user's own computer. Xwayland and the Lord Classic theme, planned here for 1.0 in 0.8.0, shipped in 0.8.3.+Next, as planned in `docs/ROADMAP.md` and `docs/BENCHMARK.md`: **0.8.6, LordBench**, repeatable measurements of CPU, memory, GPU, the compositor, video and storage, and a Flathub section in the Store, which needs a design review first so Flatpak apps keep LordOS's app scopes, firewall and restrictions; **0.8.7, community hardware reports**, published from System Information with the user's consent; and a connection refused by the per-app firewall checked on the user's own computer. Xwayland and the Lord Classic theme, planned here for 1.0 in 0.8.0, shipped in 0.8.3. The Flatpak design review is written (`docs/FLATPAK.md`) and waits for the maintainer's approval before any code.After 1.0: a desktop virtualization app built on KVM and QEMU; an Android container with LineageOS and apps from LordOS's Store; the firewall's ask mode; accessibility; and a full demo video.diff --git a/web/content/paper/paper.es.md b/web/content/paper/paper.es.mdindex 9b064cb..4f50773 100644--- a/web/content/paper/paper.es.md+++ b/web/content/paper/paper.es.md@@ -488,7 +488,7 @@ La Raspberry Pi 5 es la única placa soportada. Resultados en una placa real (16### 7.5 PC modernas-Todavía no hay mediciones en PC reales en el repositorio. La ISO se prueba en máquinas virtuales (UEFI y BIOS); está planeado probarla en una máquina AMD real desde el USB live. LordBench (0.8.6) está diseñado para medir de forma repetible la memoria y la CPU en reposo, el tiempo de arranque, los tiempos de cuadro, el video y el inicio de apps, y los informes de hardware de la comunidad (0.8.7), para recolectar esas mediciones de máquinas reales (`docs/BENCHMARK.md`).+Todavía no hay mediciones en PC reales en el repositorio. La ISO se prueba en máquinas virtuales (UEFI y BIOS); está planeado probarla en una máquina AMD real desde el USB live. LordBench (0.8.6) está diseñado para medir de forma repetible la memoria y la CPU en reposo, el tiempo de arranque, los tiempos de cuadro, el video y el inicio de apps, y los informes de hardware de la comunidad (0.8.7), para recolectar esas mediciones de máquinas reales (`docs/BENCHMARK.md`). En desarrollo para la 0.8.6 (sin publicar; la última versión es la 0.8.5-beta), su primera parte ya está construida: un ayudante aislado, `lord-bench`, que mide la CPU, la memoria, la GPU fuera de pantalla, el almacenamiento y una carga sostenida, se detiene cerca del límite de temperatura o cuando el procesador baja la velocidad, y registra las condiciones de cada prueba, que Información del sistema → Rendimiento muestra como «×N» de máquinas de referencia; por ahora la única referencia es una máquina virtual, y las mediciones del impacto en el escritorio, del compositor y de video no están construidas.### Archivos fuente@@ -550,7 +550,7 @@ La 0.8.0 Beta fue el primer lanzamiento público (18 de octubre de 2026); la 0.7### 10.3 Lo que viene-Lo próximo, según lo planeado en `docs/ROADMAP.md` y `docs/BENCHMARK.md`: **0.8.6, LordBench**, mediciones repetibles de CPU, memoria, GPU, el compositor, video y almacenamiento, y una sección de Flathub en la Tienda, que antes necesita una revisión de diseño para que las apps Flatpak conserven los scopes de app, el firewall y las restricciones de LordOS; **0.8.7, informes de hardware de la comunidad**, publicados desde Información del sistema con el consentimiento del usuario; y una conexión rechazada por el firewall por app, verificada en el propio equipo del usuario. Xwayland y el tema Lord Classic, planeados aquí para la 1.0 en la 0.8.0, salieron en la 0.8.3.+Lo próximo, según lo planeado en `docs/ROADMAP.md` y `docs/BENCHMARK.md`: **0.8.6, LordBench**, mediciones repetibles de CPU, memoria, GPU, el compositor, video y almacenamiento, y una sección de Flathub en la Tienda, que antes necesita una revisión de diseño para que las apps Flatpak conserven los scopes de app, el firewall y las restricciones de LordOS; **0.8.7, informes de hardware de la comunidad**, publicados desde Información del sistema con el consentimiento del usuario; y una conexión rechazada por el firewall por app, verificada en el propio equipo del usuario. Xwayland y el tema Lord Classic, planeados aquí para la 1.0 en la 0.8.0, salieron en la 0.8.3. La revisión de diseño de Flatpak está escrita (`docs/FLATPAK.md`) y espera la aprobación del responsable antes de escribir código.Después de la 1.0: una app de virtualización de escritorio construida sobre KVM y QEMU; un contenedor Android con LineageOS y apps desde la Tienda de LordOS; el modo "preguntar" del firewall; accesibilidad; y un video de demostración completo.diff --git a/web/content/paper/paper.pt.md b/web/content/paper/paper.pt.mdindex 43db68b..ff71c8f 100644--- a/web/content/paper/paper.pt.md+++ b/web/content/paper/paper.pt.md@@ -488,7 +488,7 @@ O Raspberry Pi 5 é a única placa suportada. Resultados numa placa real (16 GB,### 7.5 PCs modernos-Ainda não há medições em PCs reais no repositório. A ISO é testada em máquinas virtuais (UEFI e BIOS); está planejado testá-la numa máquina AMD real a partir do pendrive live. O LordBench (0.8.6) foi projetado para medir de forma repetível memória e CPU em repouso, tempo de boot, tempos de quadro, vídeo e abertura de apps, e os relatórios de hardware da comunidade (0.8.7), para coletar essas medições de máquinas reais (`docs/BENCHMARK.md`).+Ainda não há medições em PCs reais no repositório. A ISO é testada em máquinas virtuais (UEFI e BIOS); está planejado testá-la numa máquina AMD real a partir do pendrive live. O LordBench (0.8.6) foi projetado para medir de forma repetível memória e CPU em repouso, tempo de boot, tempos de quadro, vídeo e abertura de apps, e os relatórios de hardware da comunidade (0.8.7), para coletar essas medições de máquinas reais (`docs/BENCHMARK.md`). Em desenvolvimento para a 0.8.6 (não publicada; a última versão é a 0.8.5-beta), sua primeira parte já está construída: um auxiliar isolado, `lord-bench`, que mede a CPU, a memória, a GPU fora da tela, o armazenamento e uma carga contínua, para perto do limite de temperatura ou quando o processador reduz a velocidade, e registra as condições de cada teste, que Informações do Sistema → Desempenho mostra como «×N» de máquinas de referência; por enquanto a única referência é uma máquina virtual, e as medições do impacto no desktop, do compositor e de vídeo não estão construídas.### Arquivos-fonte@@ -550,7 +550,7 @@ A 0.8.0 Beta foi o primeiro lançamento público (18 de outubro de 2026); a 0.7.### 10.3 Próximos passos-A seguir, como planejado em `docs/ROADMAP.md` e `docs/BENCHMARK.md`: **0.8.6, LordBench**, medições repetíveis de CPU, memória, GPU, compositor, vídeo e armazenamento, e uma seção Flathub na Loja, que antes precisa de uma revisão de design para que os apps Flatpak mantenham os escopos de app, o firewall e as restrições do LordOS; **0.8.7, relatórios de hardware da comunidade**, publicados a partir das Informações do sistema com o consentimento do usuário; e uma conexão recusada pelo firewall por app, conferida no próprio computador do usuário. O Xwayland e o tema Lord Classic, planejados aqui para a 1.0 na 0.8.0, saíram na 0.8.3.+A seguir, como planejado em `docs/ROADMAP.md` e `docs/BENCHMARK.md`: **0.8.6, LordBench**, medições repetíveis de CPU, memória, GPU, compositor, vídeo e armazenamento, e uma seção Flathub na Loja, que antes precisa de uma revisão de design para que os apps Flatpak mantenham os escopos de app, o firewall e as restrições do LordOS; **0.8.7, relatórios de hardware da comunidade**, publicados a partir das Informações do sistema com o consentimento do usuário; e uma conexão recusada pelo firewall por app, conferida no próprio computador do usuário. O Xwayland e o tema Lord Classic, planejados aqui para a 1.0 na 0.8.0, saíram na 0.8.3. A revisão de design do Flatpak está escrita (`docs/FLATPAK.md`) e aguarda a aprovação do responsável antes de qualquer código.Depois da 1.0: um app de virtualização para desktop construído sobre KVM e QEMU; um contêiner Android com LineageOS e apps da Loja do LordOS; o modo "perguntar" do firewall; acessibilidade; e um vídeo de demonstração completo.