mirror of
https://github.com/archr-linux/Arch-R.git
synced 2026-07-12 18:19:42 -07:00
perf: corrigir gaps detectados via SSH no R36S
5 ganhos mensuráveis identificados rodando o sistema vivo: 1. /etc/sysctl.d → /storage/.config/sysctl.d, e systemd-sysctl roda Before=sysinit.target — /storage só monta em local-fs.target. O symlink ficava dangling quando systemd-sysctl lia, então archr.conf (BBR/fq_codel, vm.dirty_writeback_centisecs=1500, ip_forward, etc.) nunca era aplicado no boot. Verificado: rodando sysctl -p manual depois do boot, dirty_writeback_centisecs vai de 500 → 1500. Replicar os defaults da distro em /usr/lib/sysctl.d (rootfs, sempre disponível) garante aplicação antes de /storage subir; o /etc/ sysctl.d permanece como ponto de override do usuário. 2. enable.turbo-mode=1 em system.cfg padrão. A baseline validada do R36S inclui CPU turbo @ 1512 MHz via cpufreq/boost (vdd_arm regulator-max=1.45V), mas o default era 0 — clamp em 1416 MHz sem opt-in. O nó scaling_max_freq sobe para 1512000 assim que boost=1, comprovado live no device. Quem precisar do clamp térmico de 1416 desliga via Settings > Advanced. 3. rpcbind.service rodando idle custava ~11 MB de RAM em um device com 1 GB total, sem nada usando NFS. O upstream já fornece rpcbind.socket (Listen :111 + /run/rpcbind.sock) e systemd faz activation on-demand — mount.nfs dispara o daemon quando o user realmente monta um share. Trocado enable_service rpcbind.service por rpcbind.socket. 4. archr-touchscreen-keyboard ficava acordando a cada 5s mesmo em devices sem touchscreen (R36S, R33S, etc), e com Restart=always um exit do helper provocava restart infinito. Adicionado bail-out precoce quando DEVICE_HAS_TOUCHSCREEN != true, e Restart trocado para on-failure para honrar o exit limpo. Em devices sem touchscreen o serviço passa a ficar inativo após o primeiro boot. 5. setrootpass cryptpw sha512 + smbpasswd + syncthing generate custavam ~6s a cada boot — chamado pelo autostart 007-rootpw com a senha já configurada. Adicionado short-circuit que compara o hash sha256 da senha contra o cache em /storage/.cache/.archr-rootpass. sha256: se nada mudou, sai em 20ms. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -20,5 +20,10 @@ PKG_CONFIGURE_OPTS_TARGET="ac_cv_header_rpcsvc_mount_h=no \
|
||||
--with-rpcuser=root"
|
||||
|
||||
post_install() {
|
||||
enable_service rpcbind.service
|
||||
# rpcbind.service rodando idle custa ~11 MB de RAM em um device com
|
||||
# 1 GB. O upstream já fornece rpcbind.socket com Listen :111 e
|
||||
# /run/rpcbind.sock; habilitar só o socket entrega o mesmo
|
||||
# comportamento funcional (mount.nfs ativa o daemon sob demanda)
|
||||
# sem o overhead permanente quando o handheld não está usando NFS.
|
||||
enable_service rpcbind.socket
|
||||
}
|
||||
|
||||
+11
-5
@@ -4,13 +4,19 @@
|
||||
|
||||
. /etc/profile
|
||||
|
||||
# Em devices sem touchscreen (a maioria dos handhelds RK3326 — R33S,
|
||||
# R36S, etc.) o while loop adiante nunca executa o ramo útil mas
|
||||
# continua acordando a cada 5s para conferir as mesmas variáveis e
|
||||
# voltar a dormir. Em um device de 1 GB RAM e quad Cortex-A35 cada
|
||||
# wakeup desnecessário é overhead. Bail out cedo quando o quirk diz
|
||||
# que não há touchscreen.
|
||||
if [ "${DEVICE_HAS_TOUCHSCREEN}" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TSKEY=$(get_setting "archr.touchscreen-keyboard.enabled")
|
||||
if [ ! -n "${TSKEY}" ]; then
|
||||
if [ "$DEVICE_HAS_TOUCHSCREEN" == "true" ]; then
|
||||
set_setting "archr.touchscreen-keyboard.enabled" "1"
|
||||
else
|
||||
set_setting "archr.touchscreen-keyboard.enabled" "0"
|
||||
fi
|
||||
set_setting "archr.touchscreen-keyboard.enabled" "1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
+5
-1
@@ -8,7 +8,11 @@ StartLimitIntervalSec=0
|
||||
[Service]
|
||||
Environment=HOME=/storage
|
||||
ExecStart=/usr/bin/archr-touchscreen-keyboard
|
||||
Restart=always
|
||||
# Em devices sem touchscreen o helper sai com exit 0; com Restart=
|
||||
# always isso significava restart infinito a cada segundo. on-failure
|
||||
# preserva o auto-restart em crashes reais (exit !=0) e respeita o
|
||||
# bail-out limpo do helper.
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -181,7 +181,7 @@ system.battery.warning=0
|
||||
system.battery.warning_threshold=25
|
||||
system.hostname=@DEVICENAME@
|
||||
system.language=en_US
|
||||
enable.turbo-mode=0
|
||||
enable.turbo-mode=1
|
||||
system.cpugovernor=ondemand
|
||||
system.loglevel=none
|
||||
system.merged.storage=0
|
||||
|
||||
@@ -9,6 +9,18 @@ ROOTPASS="$1"
|
||||
LPC=$(awk -F: '/^root/{print $3}' /storage/.cache/shadow)
|
||||
CURRENT=$(awk -F: '/^root/{print $2}' /storage/.cache/shadow)
|
||||
|
||||
# Short-circuit no-op runs. 007-rootpw chama setrootpass a cada boot
|
||||
# com a senha já gravada — cryptpw sha512 + smbpasswd + syncthing
|
||||
# generate juntos custam ~6s mesmo quando nada vai mudar. Comparar a
|
||||
# senha contra o último valor escrito por nós e bail out se for igual.
|
||||
LAST_PASS_HASH="/storage/.cache/.archr-rootpass.sha256"
|
||||
if [ -n "${ROOTPASS}" ] && [ -f "${LAST_PASS_HASH}" ]; then
|
||||
CURRENT_HASH=$(printf '%s' "${ROOTPASS}" | sha256sum | awk '{print $1}')
|
||||
if [ "$(cat "${LAST_PASS_HASH}" 2>/dev/null)" = "${CURRENT_HASH}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Turn it into a usable hash
|
||||
NEW=$(cryptpw -m sha512 "${ROOTPASS}" 2>/dev/null)
|
||||
|
||||
@@ -24,6 +36,9 @@ syncthing generate --gui-user "root" --gui-password "${ROOTPASS}" >/dev/null 2>&
|
||||
# Save the password so we can display it in ES
|
||||
set_setting root.password "${ROOTPASS}"
|
||||
|
||||
# Lembrar o hash da senha gravada para o short-circuit no próximo boot.
|
||||
printf '%s' "${ROOTPASS}" | sha256sum | awk '{print $1}' >"${LAST_PASS_HASH}" 2>/dev/null
|
||||
|
||||
# Restart syncthing if it was enabled.
|
||||
SYNCSTATUS=$(get_setting syncthing.enabled)
|
||||
SYNCACTIVE=$(systemctl status syncthing | awk '/active/ {print $2}')
|
||||
|
||||
@@ -264,6 +264,16 @@ post_makeinstall_target() {
|
||||
ln -sf /storage/.config/timesyncd.conf.d ${INSTALL}/etc/systemd/timesyncd.conf.d
|
||||
safe_remove ${INSTALL}/etc/sysctl.d
|
||||
ln -sf /storage/.config/sysctl.d ${INSTALL}/etc/sysctl.d
|
||||
# /etc/sysctl.d aponta para /storage que ainda não está montado
|
||||
# quando systemd-sysctl roda (Before=sysinit.target). Resultado: os
|
||||
# archr.conf / 99-archr-networking.conf nunca eram aplicados no boot
|
||||
# — dirty_writeback_centisecs, BBR/fq_codel, ip_forward etc. ficavam
|
||||
# no default do kernel. Replicar os defaults da distro em
|
||||
# /usr/lib/sysctl.d (rootfs, sempre acessível) garante a aplicação
|
||||
# antes de /storage subir. A cópia em /etc/sysctl.d continua sendo o
|
||||
# ponto de override do usuário (last-wins).
|
||||
mkdir -p ${INSTALL}/usr/lib/sysctl.d
|
||||
cp -PR ${PKG_DIR}/config/sysctl.d/*.conf ${INSTALL}/usr/lib/sysctl.d/
|
||||
safe_remove ${INSTALL}/etc/tmpfiles.d
|
||||
ln -sf /storage/.config/tmpfiles.d ${INSTALL}/etc/tmpfiles.d
|
||||
safe_remove ${INSTALL}/etc/udev/hwdb.d
|
||||
|
||||
Reference in New Issue
Block a user