Take the catalogue's composition rules into the node-engine
ADR 0593 §7: the composer with its refusals leaves mesh-sdk, so mesh-sdk carries no composition rule. The catalogue functions only the node-engine's composition reaches (Resolve, Resolution's Compose, Declaration, DataItems, LeftOut, Rules and the rest, the settings, placeholder and template refusals, the rendering helpers) are copied with their tests into internal/compose/resolution; a method of a mesh-sdk shape becomes a function taking it first. The composition calls its own copies, and the captured catalogue its tests read lives here now, shared by mesh-compose's tests. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
# Transparent huge pages as the mesh sets them on this machine (module kernel, novox/hq issue 746).
|
||||
# Written by the mesh from this machine's setting transparent-huge-pages and run by
|
||||
# mesh-kernel-huge-pages.service: `apply` at boot and whenever the setting changes, `restore` when the
|
||||
# unit stops (the module unassigned, or the machine shutting down). Replaced on every push; change the
|
||||
# setting, never this file. A change of the setting reloads the unit, which runs `apply` again: the mode
|
||||
# moves straight to the new value and never passes back through the one the machine was found with.
|
||||
#
|
||||
# huge-pages apply|restore [<the kernel's transparent_hugepage directory> [<this module's state>]]
|
||||
#
|
||||
# The two directories are arguments only so the module's tests can run this against a stand-in tree.
|
||||
set -eu
|
||||
|
||||
want='${config:transparent-huge-pages}'
|
||||
sys=/sys/kernel/mm/transparent_hugepage
|
||||
state='${dir:state}'
|
||||
[ $# -ge 2 ] && sys=$2
|
||||
[ $# -ge 3 ] && state=$3
|
||||
|
||||
case "$want" in
|
||||
always | madvise | never) ;;
|
||||
*)
|
||||
echo "the setting transparent-huge-pages is '$want'; the kernel takes always, madvise or never" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
[ -f "$sys/enabled" ] || {
|
||||
echo "this kernel has no $sys/enabled: it was built without transparent huge pages, so there is nothing to set" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# The mode in force is the word the kernel brackets: "always [madvise] never". A file holding one bare
|
||||
# word (the stand-in tree of the tests) is read as that word.
|
||||
mode() { sed -n -e 's/.*\[\([a-z]*\)\].*/\1/p' -e t -e 's/^ *\([a-z]*\) *$/\1/p' "$sys/enabled"; }
|
||||
|
||||
[ $# -ge 1 ] || set -- usage
|
||||
case "$1" in
|
||||
apply)
|
||||
now=$(mode)
|
||||
# What the machine had before the mesh first set it, kept once, so `restore` gives it back.
|
||||
[ -s "$state/found" ] || printf '%s\n' "$now" >"$state/found"
|
||||
if [ "$now" = "$want" ]; then
|
||||
echo "transparent huge pages: $want, as set"
|
||||
exit 0
|
||||
fi
|
||||
printf '%s\n' "$want" >"$sys/enabled"
|
||||
got=$(mode)
|
||||
[ "$got" = "$want" ] || {
|
||||
echo "wrote $want to $sys/enabled and the kernel says $got" >&2
|
||||
exit 1
|
||||
}
|
||||
echo "transparent huge pages: $now -> $want"
|
||||
# A file folio already in the page cache keeps its size: the active journal files, mapped by journald
|
||||
# and by every reader, stay in 2 MiB folios until they are archived (issue 746). Rotating starts new
|
||||
# files that are mapped under the new mode. A failed rotation is said and does not fail the setting.
|
||||
# At boot nothing is in huge folios yet, and the persistent journal opens only after this unit: no rotation
|
||||
# while the service manager is still bringing the machine up.
|
||||
booting=$(systemctl is-system-running 2>/dev/null || true)
|
||||
case "$booting" in
|
||||
initializing | starting) echo "the machine is still starting: nothing to rotate yet" ;;
|
||||
*)
|
||||
if [ "$want" != always ] && command -v journalctl >/dev/null 2>&1; then
|
||||
journalctl --rotate || echo "the journal could not be rotated: its active files keep their huge pages until they are archived" >&2
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
restore)
|
||||
found=$(cat "$state/found" 2>/dev/null || true)
|
||||
case "$found" in
|
||||
always | madvise | never)
|
||||
printf '%s\n' "$found" >"$sys/enabled"
|
||||
echo "transparent huge pages: back to $found, as the machine had them"
|
||||
;;
|
||||
*) echo "transparent huge pages: nothing recorded as found, left at $(mode)" ;;
|
||||
esac
|
||||
# Unassigned or shut down: nothing of the module is kept; the next start records what it finds again.
|
||||
rm -f "$state/found"
|
||||
;;
|
||||
*)
|
||||
echo "usage: huge-pages apply|restore [<transparent_hugepage directory> [<state directory>]]" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
[Unit]
|
||||
Description=Transparent huge pages as the mesh sets them on this machine
|
||||
# Module kernel, novox/hq issue 746. Starting this unit sets the mode from the setting
|
||||
# transparent-huge-pages; reloading it (the setting changed) sets the new mode; stopping it gives back the
|
||||
# mode the machine had before. It runs early in boot, before the services that fill the page cache.
|
||||
DefaultDependencies=no
|
||||
After=local-fs.target
|
||||
Before=sysinit.target shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=${dir:state}/huge-pages apply
|
||||
ExecReload=${dir:state}/huge-pages apply
|
||||
ExecStop=${dir:state}/huge-pages restore
|
||||
# It writes one file under /sys and its own state, and asks the journal daemon to rotate over its socket.
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=${dir:state}
|
||||
ProtectHome=yes
|
||||
PrivateNetwork=yes
|
||||
NoNewPrivileges=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"module": "kernel",
|
||||
"version": "1",
|
||||
"capabilities": [
|
||||
"service-manager"
|
||||
],
|
||||
"config": {
|
||||
"transparent-huge-pages": {
|
||||
"type": "string",
|
||||
"description": "madvise is the value the mesh chose for every node (novox/hq ADR 0381), not the always the distribution's kernel boots with; a machine that needs another value is given it as its own setting; madvise gives huge pages only to programs that ask for them, which stops a small write to a mapped file (the journal) dirtying and writing back a whole 2 MiB page on a machine whose disks are slow (novox/hq issue 746)",
|
||||
"trusted": true,
|
||||
"default": "madvise"
|
||||
}
|
||||
},
|
||||
"tools": [
|
||||
"kernel_huge_pages"
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"id": "state",
|
||||
"type": "directory",
|
||||
"mode": "0700",
|
||||
"place": ".",
|
||||
"unknown": "program"
|
||||
},
|
||||
{
|
||||
"id": "huge-pages",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/huge-pages",
|
||||
"mode": "0755",
|
||||
"trusted": true,
|
||||
"template": "files/huge-pages.sh"
|
||||
},
|
||||
{
|
||||
"id": "unit",
|
||||
"type": "file",
|
||||
"path": "/etc/systemd/system/mesh-kernel-huge-pages.service",
|
||||
"mode": "0644",
|
||||
"template": "files/mesh-kernel-huge-pages.service"
|
||||
},
|
||||
{
|
||||
"id": "apply",
|
||||
"type": "service",
|
||||
"unit": "mesh-kernel-huge-pages.service",
|
||||
"state": "running",
|
||||
"boot": "enabled",
|
||||
"restart-on": [
|
||||
"unit"
|
||||
],
|
||||
"reload-on": [
|
||||
"huge-pages"
|
||||
],
|
||||
"health": {
|
||||
"kind": "unit"
|
||||
}
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
"artifacts": [
|
||||
{
|
||||
"name": "tools",
|
||||
"kind": "bundle",
|
||||
"language": "go",
|
||||
"system": "arch",
|
||||
"from": "cmd/kernel-tools",
|
||||
"binary": "kernel-tools",
|
||||
"loads": [
|
||||
"kernel-tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "files",
|
||||
"kind": "archive",
|
||||
"from": "files"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user