mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] perf: enable #9 items 1+3 in the windows build (zip stdlib + pyc-only deps)
- shrinks python-env 13554 -> 9287 files (~31%); validated: backend.main imports clean with both applied - targets the python-env Defender scan that dominates the 22.5s cold start - guarded (skips if python313.zip already present); non-fatal
This commit is contained in:
@@ -282,6 +282,30 @@ if (-not (Test-Path (Join-Path $ProjectRoot 'electron\python-env'))) {
|
||||
Write-Host "Python environment ready."
|
||||
Write-Host ""
|
||||
|
||||
# --- Step 2b: Shrink the Defender cold-start surface (#9 items 1 + 3). ---
|
||||
# Zip the stdlib into python313.zip and ship site-packages as sourceless .pyc, so
|
||||
# Defender scans ~9.3k files instead of ~13.5k on the first post-update launch
|
||||
# (the python-env scan is the bulk of the 22.5s cold time). Validated: the full
|
||||
# backend.main import tree resolves cleanly with both applied. Guarded on the
|
||||
# zip's absence so a cached/already-shrunk env is not re-processed (re-zipping an
|
||||
# already-zipped tree would write an empty archive). Non-fatal: on failure the
|
||||
# build continues with the un-shrunk env.
|
||||
$StdlibZip = Join-Path $PythonEnv 'python313.zip'
|
||||
if (-not (Test-Path $StdlibZip)) {
|
||||
Write-Host "[2b] Shrinking python-env for cold start (#9 items 1+3)..."
|
||||
try {
|
||||
& (Join-Path $ScriptDir 'zip-python-stdlib.ps1') -PythonEnv $PythonEnv -Apply
|
||||
& (Join-Path $ScriptDir 'strip-py-to-pyc.ps1') -TargetDir (Join-Path $PythonEnv 'Lib\site-packages') -PythonExe $PythonExe -Apply
|
||||
$cnt = (Get-ChildItem -Recurse -File $PythonEnv -EA SilentlyContinue | Measure-Object).Count
|
||||
Write-Host "[2b] python-env shrunk to $cnt files."
|
||||
} catch {
|
||||
Write-Warning "[2b] python-env shrink FAILED: $_ (cold start stays larger; non-fatal)"
|
||||
}
|
||||
} else {
|
||||
Write-Host "[2b] python-env already shrunk (python313.zip present); skipping."
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# --- Step 3: Fetch Router from npm ---
|
||||
# The 9router Next.js server is published as an npm package with a pre-built
|
||||
# standalone output. Stage it directly from npm instead of vendoring + rebuilding.
|
||||
|
||||
Reference in New Issue
Block a user