runtime capture: registry heartbeat decodes live DSP tables (WIN 0.540658, freq-axis@48k, per-bin weights), rtsnap_fast/findctx/rtchunk infra
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import subprocess, os, glob, time, struct, sys
|
||||
def mem_open(pid): return os.open(f'/proc/{pid}/mem', os.O_RDONLY)
|
||||
def find_hosts():
|
||||
hosts=[]
|
||||
for p in glob.glob('/proc/[0-9]*'):
|
||||
pid=int(os.path.basename(p))
|
||||
try:
|
||||
cmd=open(f'/proc/{pid}/cmdline','rb').read().replace(b'\0',b' ').decode('utf8','replace')
|
||||
maps=open(f'/proc/{pid}/maps').read()
|
||||
except Exception: continue
|
||||
if 'soothe2' in maps and 'reaper' not in cmd:
|
||||
hosts.append(pid)
|
||||
return hosts
|
||||
os.system("pkill -9 -x reaper 2>/dev/null; pkill -9 -f '[y]abridge' 2>/dev/null; sleep 1")
|
||||
proc=subprocess.Popen(['/usr/bin/reaper','-nosplash','-ignoreerrors','-renderproject','/home/m/soothe-bt/render_long.rpp'],
|
||||
stdout=open('/dev/null','w'),stderr=subprocess.STDOUT)
|
||||
# wait for host
|
||||
t0=time.time(); host=None
|
||||
while time.time()-t0<60 and not host:
|
||||
hs=find_hosts()
|
||||
host=hs[0] if hs else None
|
||||
time.sleep(0.2)
|
||||
print('host',host, flush=True)
|
||||
time.sleep(6) # let render warm up, tables built
|
||||
fd=mem_open(host)
|
||||
out=open('/tmp/snap_all.bin','wb')
|
||||
idx=open('/tmp/snap_all.idx','wb')
|
||||
t0=time.time(); nreg=0; nbytes=0
|
||||
for line in open(f'/proc/{host}/maps').read().splitlines():
|
||||
p=line.split(); lo,hi=(int(x,16) for x in p[0].split('-'))
|
||||
if 'r' not in p[1]: continue
|
||||
a=lo
|
||||
while a<hi:
|
||||
n=min(hi-a, 8*1024*1024)
|
||||
try: d=os.pread(fd,n,a)
|
||||
except Exception: a+=n; continue
|
||||
if not d: a+=n; continue
|
||||
out.write(struct.pack('<QQ',a,len(d))); out.write(d)
|
||||
idx.write(struct.pack('<QQ',a,len(d)))
|
||||
nreg+=1; nbytes+=len(d)
|
||||
a+=n
|
||||
out.close(); idx.close()
|
||||
print('snapshot ok: %d regs %d MB in %.1fs'%(nreg,nbytes/1e6,time.time()-t0), flush=True)
|
||||
if proc.poll() is None: proc.kill()
|
||||
Reference in New Issue
Block a user