fix: wait for DHCP before WireGuard startup and record PCIe benchmark
This commit is contained in:
1 parent
3c7ba8ba49
commit
b7e7fb05b6
7 files changed
+299
-5
No files matched your search
@@ -44,11 +44,13 @@ def main():
|
||||
Description=Athena Deck native WireGuard and restricted access service
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
StartLimitIntervalSec=0
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory={base}
|
||||
ExecStart=/usr/bin/python3 -m network.native --client-uid {a.client_uid} --client-gid {a.client_gid}
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
RuntimeDirectory=athena-deck-network
|
||||
RuntimeDirectoryMode=0755
|
||||
RuntimeDirectoryPreserve=yes
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# IQ3 after pci=pcie_bus_perf — 2026-10-13
|
||||
|
||||
Matched rerun of the six-request `tuned-1024` suite used immediately before
|
||||
reboot. Same harness, synthetic prompts and order, temperature zero, thinking
|
||||
off, 512 output tokens each, resident experts, layer split 16 and 1024-MiB
|
||||
GPU reserves. Both runs use IQ3 and its experts package on the Samsung 980 PRO,
|
||||
a fresh isolated server, and Strata 0.1.43.1. No settings or weights were changed
|
||||
for the benchmark. WireGuard was repaired only after measurements finished.
|
||||
|
||||
| Backend metric | Before boot change | After reboot | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Output median, six requests | 80.3 tok/s | 83.1 tok/s | +3.49% |
|
||||
| Output range | 73.0–90.4 | 75.5–95.5 | — |
|
||||
| Input, 6728 tokens | 1160.9 tok/s | 1185.0 tok/s | +2.08% |
|
||||
| Input, 26696 tokens | 1709.8 tok/s | 1716.7 tok/s | +0.40% |
|
||||
| Output after 26696-token input | 79.1 tok/s | 76.4 tok/s | -3.41% |
|
||||
|
||||
All runs produced 512 output tokens; prompt cache counts were zero and both
|
||||
long-input identifiers were recovered. No low-VRAM warning was reported.
|
||||
This single rerun suggests a small median gain, not a statistically established
|
||||
universal speedup. Long-input output did not improve. PCIe MPS and MRRS both
|
||||
changed, and this comparison includes a host reboot, so it does not isolate
|
||||
MPS alone. No cold model-loading speed comparison was made.
|
||||
|
||||
Verified post-boot: both GPUs MPS 256 and MRRS 256 bytes; the 3060 ancestor
|
||||
bridges MPS/MRRS 512/512. The temporary benchmark container exits and the
|
||||
wrapper reloads normal IQ3; `restore.json` confirms successful restoration.
|
||||
No private chats or credentials are committed.
|
||||
@@ -0,0 +1 @@
|
||||
{"iq3_loaded": true, "benchmark_returncode": 0}
|
||||
@@ -0,0 +1,183 @@
|
||||
[
|
||||
{
|
||||
"candidate": "tuned-1024",
|
||||
"split": 16,
|
||||
"gpu": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"tuning": {
|
||||
"STRATA_ROUTE_TAIL_SKIP": "0",
|
||||
"STRATA_RESIDENT_HEADROOM_GIB": "6",
|
||||
"STRATA_STAGE_TRIM": "1",
|
||||
"--pcie-frac": "0.35",
|
||||
"--spec-min-p": "0.70",
|
||||
"--adapt-every": "1",
|
||||
"--adapt-swaps": "80",
|
||||
"--adapt-decay": "0.97",
|
||||
"--vram-reserve-mib": "1024",
|
||||
"--vram-reserve-later-mib": "1024"
|
||||
},
|
||||
"runs": [
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 80,
|
||||
"prompt_ms": 1002.9,
|
||||
"prompt_per_token_ms": 12.536,
|
||||
"prompt_per_second": 79.8,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 6170.2,
|
||||
"predicted_per_token_ms": 12.051,
|
||||
"predicted_per_second": 83.0,
|
||||
"draft_n": 323,
|
||||
"draft_n_accepted": 210
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 80,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 592,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 7.176080922999972,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
},
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 81,
|
||||
"prompt_ms": 649.9,
|
||||
"prompt_per_token_ms": 8.023,
|
||||
"prompt_per_second": 124.6,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 5732.5,
|
||||
"predicted_per_token_ms": 11.196,
|
||||
"predicted_per_second": 89.3,
|
||||
"draft_n": 338,
|
||||
"draft_n_accepted": 256
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 81,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 593,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 6.385179853999944,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
},
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 80,
|
||||
"prompt_ms": 687.9,
|
||||
"prompt_per_token_ms": 8.599,
|
||||
"prompt_per_second": 116.3,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 6154.3,
|
||||
"predicted_per_token_ms": 12.02,
|
||||
"predicted_per_second": 83.2,
|
||||
"draft_n": 313,
|
||||
"draft_n_accepted": 206
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 80,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 592,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 6.844654257999991,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
},
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 81,
|
||||
"prompt_ms": 657.0,
|
||||
"prompt_per_token_ms": 8.111,
|
||||
"prompt_per_second": 123.3,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 5362.0,
|
||||
"predicted_per_token_ms": 10.473,
|
||||
"predicted_per_second": 95.5,
|
||||
"draft_n": 366,
|
||||
"draft_n_accepted": 284
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 81,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 593,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 6.021396521999918,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
},
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 6728,
|
||||
"prompt_ms": 5677.8,
|
||||
"prompt_per_token_ms": 0.844,
|
||||
"prompt_per_second": 1185.0,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 6778.2,
|
||||
"predicted_per_token_ms": 13.239,
|
||||
"predicted_per_second": 75.5,
|
||||
"draft_n": 309,
|
||||
"draft_n_accepted": 208
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 6728,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 7240,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 12.461525198999993,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
},
|
||||
{
|
||||
"timings": {
|
||||
"cache_n": 0,
|
||||
"prompt_n": 26696,
|
||||
"prompt_ms": 15551.2,
|
||||
"prompt_per_token_ms": 0.583,
|
||||
"prompt_per_second": 1716.7,
|
||||
"predicted_n": 512,
|
||||
"predicted_ms": 6700.4,
|
||||
"predicted_per_token_ms": 13.087,
|
||||
"predicted_per_second": 76.4,
|
||||
"draft_n": 269,
|
||||
"draft_n_accepted": 159
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 26696,
|
||||
"completion_tokens": 512,
|
||||
"total_tokens": 27208,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
}
|
||||
},
|
||||
"seconds": 22.26660490000006,
|
||||
"nonempty": true,
|
||||
"identifier_ok": true
|
||||
}
|
||||
],
|
||||
"decode_median": 83.1,
|
||||
"passed": true,
|
||||
"vram_warning": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
# WireGuard DHCP startup race — 2026-10-13
|
||||
|
||||
The enabled `athena-deck-network.service` failed before activating its persisted
|
||||
tunnel. Its fifth startup failure was at 11:42:06 CEST; dhcpcd assigned the
|
||||
configured LAN address at 11:42:09.595 CEST. `networking.service` had completed
|
||||
at 11:42:05 without waiting for the DHCP lease. The network helper initially
|
||||
binds LAN listeners and treated every failure as a port collision. Thus a
|
||||
missing address was reported as "port occupied", and rapid retries exhausted
|
||||
systemd's default start limit before the address appeared.
|
||||
|
||||
## Fix
|
||||
|
||||
- `network.native.main` waits up to 60 seconds for the configured address on
|
||||
the configured interface before constructing listeners.
|
||||
- Binding errors distinguish address unavailability, occupied ports and other
|
||||
listener failures without exposing credentials or raw configuration.
|
||||
- A failed connection cleanup preserves the user's persisted activation;
|
||||
explicit disconnect still disables it.
|
||||
- Failed persisted-tunnel startup fails the service rather than leaving it
|
||||
alive permanently without the tunnel, allowing systemd to retry.
|
||||
- Native setup recipe: `RestartSec=5`, `StartLimitIntervalSec=0`.
|
||||
- Existing host has matching overrides in
|
||||
`/etc/systemd/system/athena-deck-network.service.d/boot-retry.conf`.
|
||||
|
||||
Only the failed network service was started; no host/Deck restart for this fix.
|
||||
Tunnel configuration, keys, routes policy and access mode were not changed.
|
||||
|
||||
## Verification and restore
|
||||
|
||||
Ten native unit tests pass, including delayed address acquisition, bounded
|
||||
wait, distinct bind errors and preservation of activation after a failed
|
||||
connection. Installed source matches the tested code. The service is running,
|
||||
the tunnel address 192.168.1.212 is present, its handshake is recent, and SSH
|
||||
via this home address works. Deck is healthy. No second full reboot was
|
||||
performed: actual next-boot verification is still pending.
|
||||
|
||||
On native restore, use the committed network code and setup recipe; existing
|
||||
private tunnel configuration remains in its normal protected restore storage,
|
||||
never Git. Keep the same policy and persisted enabled flag. Existing installs
|
||||
can use the listed systemd overrides, daemon-reload and reset-failed before
|
||||
starting the service. Do not silently fall back to broader network access.
|
||||
+18
-4
@@ -2,6 +2,7 @@
|
||||
No wg-quick hooks, default route replacement, DNS changes or Docker operations.
|
||||
"""
|
||||
import argparse
|
||||
import errno
|
||||
import http.client
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
import ipaddress
|
||||
@@ -36,6 +37,14 @@ def save(path,value):
|
||||
with os.fdopen(fd,'w') as f:json.dump(value,f);f.flush();os.fsync(f.fileno())
|
||||
temp.replace(path)
|
||||
|
||||
def wait_for_lan(policy,timeout=60):
|
||||
deadline=time.monotonic()+timeout
|
||||
while True:
|
||||
devices=json.loads(run(['ip','-j','address','show']))
|
||||
if any(d.get('ifname')==policy['lan_interface'] and any(v.get('local')==policy['lan_address'] for v in d.get('addr_info',[])) for d in devices):return
|
||||
if time.monotonic()>=deadline:raise ValueError('Konfigurierte LAN-Adresse noch nicht verfügbar; Netzwerkdienst startet erneut.')
|
||||
time.sleep(1)
|
||||
|
||||
class Manager:
|
||||
def __init__(self,state,policy):
|
||||
self.root=Path(state);self.root.mkdir(mode=0o700,exist_ok=True);self.settings=policy
|
||||
@@ -86,7 +95,7 @@ class Manager:
|
||||
run(['ip','-'+version,'rule','add','priority',PRIORITIES[a.version],'from',str(a.ip)+('/32' if a.version==4 else '/128'),'lookup',TABLE])
|
||||
self.reconcile();save(self.root/'enabled.json',True);self.error=None
|
||||
except Exception:
|
||||
self.disconnect();raise
|
||||
self.disconnect(persist=False);raise
|
||||
def disconnect(self,persist=True):
|
||||
if self.enabled:
|
||||
self.enabled=False;self.reconcile()
|
||||
@@ -107,9 +116,13 @@ class Manager:
|
||||
cls=GUI if port==self.settings['gui_port'] else Relay
|
||||
server=Listener(address,port,ingress,cls,self)
|
||||
threading.Thread(target=server.serve_forever,daemon=True).start();added.append(server)
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
for s in added:s.shutdown();s.server_close()
|
||||
raise ValueError('Netzwerkport ist belegt; bestehende Listener bleiben unverändert.') from None
|
||||
if isinstance(error,OSError) and error.errno==errno.EADDRINUSE:
|
||||
raise ValueError('Netzwerkport ist belegt; bestehende Listener bleiben unverändert.') from None
|
||||
if isinstance(error,OSError) and error.errno==errno.EADDRNOTAVAIL:
|
||||
raise ValueError('Konfigurierte Netzwerkadresse ist noch nicht verfügbar; bestehende Listener bleiben unverändert.') from None
|
||||
raise ValueError('Netzwerk-Listener konnte nicht gestartet werden; bestehende Listener bleiben unverändert.') from None
|
||||
self.listeners+=added
|
||||
for s in self.listeners[:]:
|
||||
if (s.bind_address,s.port,s.ingress) not in desired:
|
||||
@@ -226,6 +239,7 @@ class Server(socketserver.ThreadingUnixStreamServer):daemon_threads=True
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--client-uid',type=int,required=True);p.add_argument('--client-gid',type=int,required=True);p.add_argument('--state',default='/var/lib/athena-deck-network');args=p.parse_args()
|
||||
root=Path(args.state);policy=json.loads((root/'policy.json').read_text())
|
||||
wait_for_lan(policy)
|
||||
manager=Manager(root,policy)
|
||||
runtime=Path('/run/athena-deck-network');runtime.mkdir(exist_ok=True)
|
||||
token=runtime/'proxy-token';token.write_text(manager.token);os.chown(token,0,args.client_gid);token.chmod(0o640)
|
||||
@@ -235,7 +249,7 @@ def main():
|
||||
# enabled is persisted only on explicit successful activation; native service owns recovery.
|
||||
if manager.read('enabled.json',False):
|
||||
try:manager.connect()
|
||||
except Exception:manager.error='Gespeicherter Tunnel konnte nicht aktiviert werden; Hostzustand prüfen.'
|
||||
except Exception:raise ValueError('Gespeicherter Tunnel konnte nicht aktiviert werden; Netzwerkdienst startet erneut.') from None
|
||||
signal.signal(signal.SIGTERM,lambda *_:threading.Thread(target=server.shutdown,daemon=True).start())
|
||||
try:server.serve_forever()
|
||||
finally:
|
||||
|
||||
+26
-1
@@ -1,10 +1,11 @@
|
||||
import json
|
||||
import errno
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from network.config import parse_config,ConfigError
|
||||
from network.native import Manager
|
||||
from network.native import Manager,wait_for_lan
|
||||
|
||||
CONF='''[Interface]
|
||||
PrivateKey = AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
|
||||
@@ -18,6 +19,30 @@ Endpoint = vpn.example.test:51820
|
||||
PersistentKeepalive = 25
|
||||
'''
|
||||
class NativeTests(unittest.TestCase):
|
||||
def test_start_waits_for_configured_lan_address(self):
|
||||
policy=dict(lan_address='192.0.2.11',lan_interface='lan0')
|
||||
devices=json.dumps([{'ifname':'lan0','addr_info':[{'local':'192.0.2.11'}]}])
|
||||
with patch('network.native.run',side_effect=['[]',devices]),patch('network.native.time.sleep') as sleep:
|
||||
wait_for_lan(policy);sleep.assert_called_once_with(1)
|
||||
def test_start_wait_is_bounded(self):
|
||||
with patch('network.native.run',return_value='[]'),patch('network.native.time.monotonic',side_effect=[0,61]):
|
||||
with self.assertRaisesRegex(ValueError,'LAN-Adresse'):wait_for_lan(dict(lan_address='192.0.2.11',lan_interface='lan0'))
|
||||
def test_bind_error_distinguishes_missing_address(self):
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
m=self.manager(t)
|
||||
with patch('network.native.Listener',side_effect=OSError(errno.EADDRNOTAVAIL,'missing')):
|
||||
with self.assertRaisesRegex(ValueError,'Netzwerkadresse'):m.reconcile()
|
||||
def test_failed_connection_preserves_autostart(self):
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
m=self.manager(t);m.dispatch(dict(action='import',config=CONF))
|
||||
from network.native import save
|
||||
save(Path(t)/'enabled.json',True)
|
||||
def command(args,check=True):
|
||||
if args[:2]==['wg','setconf']:raise ValueError('synthetic failure')
|
||||
return '[]' if '-j' in args else ''
|
||||
with patch('network.native.run',side_effect=command),patch.object(m,'reconcile'):
|
||||
with self.assertRaises(ValueError):m.connect()
|
||||
self.assertTrue(json.loads((Path(t)/'enabled.json').read_text()));self.assertFalse(m.enabled)
|
||||
def manager(self,root):
|
||||
with patch.object(Manager,'reconcile'):return Manager(root,dict(lan_address='192.0.2.11',gui_port=8108,ports=[8108,8120]))
|
||||
def test_dual_stack_repeated_dns(self):
|
||||
|
||||
Reference in new issue
Block a user