@mytec: before 3.0 REFACTOR

This commit is contained in:
2026-02-01 14:26:17 +02:00
parent acc90fe538
commit 1dde56705a
13 changed files with 1759 additions and 61 deletions

View File

@@ -1 +0,0 @@
{"detail":"Calculation timeout (5 min). Cleaned up 6 workers."}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
@echo off
title RFCP Real-time Resource Monitor
setlocal EnableDelayedExpansion
echo ============================================
echo RFCP Real-time Resource Monitor
echo ============================================
echo Press Ctrl+C to stop
echo ============================================
echo.
echo TIME CPU%% MEM(MB) PROCS FREE_RAM(MB)
echo ---------- ----- ------- ----- ------------
:loop
:: Get current time
set T=%time:~0,8%
:: Count RFCP processes and their memory
set PROC_COUNT=0
set TOTAL_MEM=0
for /f "skip=3 tokens=5 delims= " %%m in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul') do (
set /a PROC_COUNT+=1
set MEM_STR=%%m
set MEM_STR=!MEM_STR:,=!
set MEM_STR=!MEM_STR: =!
if "!MEM_STR!" NEQ "" (
set /a TOTAL_MEM+=!MEM_STR! 2>nul
)
)
set /a TOTAL_MEM_MB=TOTAL_MEM/1024 2>nul
:: Get free RAM (PowerShell — wmic deprecated in Win11)
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory" 2^>nul') do (
set /a FREE_RAM=%%a/1024 2>nul
)
:: Get CPU load (PowerShell — wmic deprecated in Win11)
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_Processor).LoadPercentage" 2^>nul') do (
set CPU=%%a
)
:: Display
echo %T% %CPU%%% %TOTAL_MEM_MB% %PROC_COUNT% %FREE_RAM%
:: Wait 2 seconds
timeout /t 2 /nobreak >nul
goto loop

View File

@@ -0,0 +1,93 @@
@echo off
title RFCP Debug Launcher + Monitor
setlocal EnableDelayedExpansion
echo ============================================
echo RFCP Debug Launcher + Monitor
echo ============================================
echo.
:: Kill any running instance
echo [1/3] Cleaning up existing processes...
taskkill /F /IM rfcp-server.exe 2>nul
if %ERRORLEVEL% EQU 0 (
echo Killed existing rfcp-server.exe
timeout /t 2 /nobreak >nul
) else (
echo No existing process found
)
echo.
:: Environment setup
set PYTHONUNBUFFERED=1
set RFCP_DEBUG=1
set RFCP_HOST=127.0.0.1
set RFCP_PORT=8888
echo [2/3] Environment:
echo PYTHONUNBUFFERED=%PYTHONUNBUFFERED%
echo RFCP_DEBUG=%RFCP_DEBUG%
echo RFCP_HOST=%RFCP_HOST%
echo RFCP_PORT=%RFCP_PORT%
echo.
:: Find executable
if exist "%~dp0dist\rfcp-server.exe" (
set EXE_PATH=%~dp0dist\rfcp-server.exe
set WORK_DIR=%~dp0dist
) else if exist "%~dp0rfcp-server.exe" (
set EXE_PATH=%~dp0rfcp-server.exe
set WORK_DIR=%~dp0
) else (
echo [ERROR] rfcp-server.exe not found!
pause
exit /b 1
)
echo [3/3] Starting server...
echo Executable: %EXE_PATH%
echo Working dir: %WORK_DIR%
echo.
:: Create log directory
set LOG_DIR=%WORK_DIR%\logs
if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
:: Log file with timestamp
set TIMESTAMP=%date:~-4%%date:~3,2%%date:~0,2%-%time:~0,2%%time:~3,2%%time:~6,2%
set TIMESTAMP=%TIMESTAMP: =0%
set LOG_FILE=%LOG_DIR%\server-%TIMESTAMP%.log
echo Log file: %LOG_FILE%
echo.
echo ============================================
echo SERVER OUTPUT (also saved to log)
echo ============================================
echo.
cd /d "%WORK_DIR%"
:: Run server and tee to log file
:: Note: PowerShell tee for dual output
powershell -Command "& '%EXE_PATH%' 2>&1 | Tee-Object -FilePath '%LOG_FILE%'"
echo.
echo ============================================
echo Server stopped
echo Log saved to: %LOG_FILE%
echo ============================================
:: Post-mortem check
echo.
echo [POST-MORTEM] Checking for orphan processes...
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do (
if %%a GTR 0 (
echo WARNING: %%a rfcp-server process(es) still running!
echo Run: taskkill /F /IM rfcp-server.exe
) else (
echo All processes cleaned up properly.
)
)
echo.
pause

View File

@@ -0,0 +1,282 @@
@echo off
title RFCP Coverage API Test + Resource Monitor
setlocal EnableDelayedExpansion
echo ============================================
echo RFCP Coverage API Test + Resource Monitor
echo ============================================
echo.
set API=http://127.0.0.1:8888
set RESULTS_DIR=%~dp0test-results
set TIMESTAMP=%date:~-4%%date:~3,2%%date:~0,2%-%time:~0,2%%time:~3,2%
set TIMESTAMP=%TIMESTAMP: =0%
:: Create results directory
if not exist "%RESULTS_DIR%" mkdir "%RESULTS_DIR%"
:: Log file for this run
set LOG_FILE=%RESULTS_DIR%\test-run-%TIMESTAMP%.log
echo Test started: %date% %time% > "%LOG_FILE%"
echo. >> "%LOG_FILE%"
:: ===========================================
:: SYSTEM INFO
:: ===========================================
echo [SYSTEM] Collecting system info...
echo. >> "%LOG_FILE%"
echo === SYSTEM INFO === >> "%LOG_FILE%"
:: CPU info (PowerShell — wmic deprecated in Win11)
for /f "delims=" %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_Processor).Name"') do (
echo CPU: %%a >> "%LOG_FILE%"
echo CPU: %%a
)
:: RAM info (PowerShell)
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).TotalVisibleMemorySize"') do (
set /a RAM_GB=%%a/1024/1024
echo RAM: !RAM_GB! GB >> "%LOG_FILE%"
echo RAM: !RAM_GB! GB
)
:: GPU info (PowerShell)
echo GPU: >> "%LOG_FILE%"
for /f "delims=" %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_VideoController).Name"') do (
echo %%a >> "%LOG_FILE%"
echo %%a
)
echo. >> "%LOG_FILE%"
echo.
:: ===========================================
:: PRE-TEST BASELINE
:: ===========================================
echo [BASELINE] Capturing baseline resource usage...
:: Get baseline memory
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do (
set /a BASELINE_FREE_MB=%%a/1024
)
echo Free RAM before: %BASELINE_FREE_MB% MB
echo Baseline free RAM: %BASELINE_FREE_MB% MB >> "%LOG_FILE%"
:: Count rfcp processes
set RFCP_COUNT=0
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do set RFCP_COUNT=%%a
echo RFCP processes: %RFCP_COUNT%
echo Baseline RFCP processes: %RFCP_COUNT% >> "%LOG_FILE%"
echo. >> "%LOG_FILE%"
:: ===========================================
:: TEST 1: Health check
:: ===========================================
echo.
echo [TEST 1] Health check...
echo === TEST 1: Health Check === >> "%LOG_FILE%"
curl -s -o nul -w "HTTP %%{http_code}\n" %API%/api/health
curl -s -w "HTTP %%{http_code}" %API%/api/health >> "%LOG_FILE%"
echo. >> "%LOG_FILE%"
:: ===========================================
:: TEST 2: System info
:: ===========================================
echo.
echo [TEST 2] Backend system info:
echo === TEST 2: Backend System Info === >> "%LOG_FILE%"
curl -s %API%/api/system/info
curl -s %API%/api/system/info >> "%LOG_FILE%"
echo.
echo. >> "%LOG_FILE%"
:: ===========================================
:: TEST 3: Fast preset
:: ===========================================
echo.
echo [TEST 3] Coverage - Fast preset (2km, 500m res)
echo Expected: ^< 1 second
echo === TEST 3: Fast Preset === >> "%LOG_FILE%"
:: Capture start memory
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a START_FREE=%%a/1024
set START_TIME=%time%
curl -s -w "\nTime: %%{time_total}s | HTTP: %%{http_code}" ^
-X POST %API%/api/coverage/calculate ^
-H "Content-Type: application/json" ^
-d "{\"sites\": [{\"lat\": 50.45, \"lon\": 30.52, \"height\": 30, \"power\": 43, \"gain\": 15, \"frequency\": 1800}], \"settings\": {\"radius\": 2000, \"resolution\": 500, \"preset\": \"fast\"}}" ^
-o "%RESULTS_DIR%\coverage-fast.json"
set END_TIME=%time%
:: Capture end memory
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a END_FREE=%%a/1024
set /a MEM_USED=START_FREE-END_FREE
echo.
echo Memory delta: %MEM_USED% MB
echo Time: %START_TIME% - %END_TIME% >> "%LOG_FILE%"
echo Memory delta: %MEM_USED% MB >> "%LOG_FILE%"
echo. >> "%LOG_FILE%"
:: ===========================================
:: TEST 4: Standard preset
:: ===========================================
echo.
echo [TEST 4] Coverage - Standard preset (5km, 300m res)
echo Expected: 30-45 seconds
echo === TEST 4: Standard Preset === >> "%LOG_FILE%"
:: Monitor resources during test
echo Starting resource monitor...
start /b cmd /c "for /l %%i in (1,1,120) do (for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory" 2^>nul') do echo [%%i] Free: %%a KB >> "%RESULTS_DIR%\monitor-standard.log") & timeout /t 1 /nobreak >nul 2>&1"
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a START_FREE=%%a/1024
curl -s -w "\nTime: %%{time_total}s | HTTP: %%{http_code}" ^
-X POST %API%/api/coverage/calculate ^
-H "Content-Type: application/json" ^
-d "{\"sites\": [{\"lat\": 50.45, \"lon\": 30.52, \"height\": 30, \"power\": 43, \"gain\": 15, \"frequency\": 1800}], \"settings\": {\"radius\": 5000, \"resolution\": 300, \"preset\": \"standard\"}}" ^
-o "%RESULTS_DIR%\coverage-standard.json"
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a END_FREE=%%a/1024
set /a MEM_USED=START_FREE-END_FREE
set /a PEAK_FROM_BASELINE=BASELINE_FREE_MB-END_FREE
echo.
echo Memory delta: %MEM_USED% MB (peak from baseline: %PEAK_FROM_BASELINE% MB)
echo Memory delta: %MEM_USED% MB >> "%LOG_FILE%"
:: Count RFCP processes
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do set RFCP_COUNT=%%a
echo RFCP processes: %RFCP_COUNT%
echo RFCP processes: %RFCP_COUNT% >> "%LOG_FILE%"
echo. >> "%LOG_FILE%"
:: ===========================================
:: TEST 5: Detailed preset (the big one!)
:: ===========================================
echo.
echo [TEST 5] Coverage - Detailed preset (5km, 300m res)
echo Expected: ^< 90 seconds (was 300s timeout)
echo THIS IS THE VECTORIZATION TEST!
echo === TEST 5: Detailed Preset (VECTORIZATION TEST) === >> "%LOG_FILE%"
:: Start intensive resource monitor
echo Starting intensive resource monitor (every 2s)...
start /b cmd /c "for /l %%i in (1,1,180) do (for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory" 2^>nul') do echo [%%i] Free: %%a KB >> "%RESULTS_DIR%\monitor-detailed.log") & timeout /t 2 /nobreak >nul 2>&1"
:: CPU monitor (approximate via tasklist)
start /b cmd /c "for /l %%i in (1,1,180) do (for /f "skip=2 tokens=5" %%c in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" /FO LIST 2^>nul ^| findstr "Mem"') do echo [%%i] RFCP Mem: %%c >> "%RESULTS_DIR%\monitor-rfcp.log") & timeout /t 2 /nobreak >nul 2>&1"
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a START_FREE=%%a/1024
set START_DETAIL=%time%
echo Start time: %START_DETAIL%
curl -s -w "\nTime: %%{time_total}s | HTTP: %%{http_code}" ^
-X POST %API%/api/coverage/calculate ^
-H "Content-Type: application/json" ^
-d "{\"sites\": [{\"lat\": 50.45, \"lon\": 30.52, \"height\": 30, \"power\": 43, \"gain\": 15, \"frequency\": 1800}], \"settings\": {\"radius\": 5000, \"resolution\": 300, \"preset\": \"detailed\"}}" ^
-o "%RESULTS_DIR%\coverage-detailed.json" ^
2>&1
set END_DETAIL=%time%
echo End time: %END_DETAIL%
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a END_FREE=%%a/1024
set /a MEM_USED=START_FREE-END_FREE
set /a PEAK_FROM_BASELINE=BASELINE_FREE_MB-END_FREE
echo.
echo Memory delta: %MEM_USED% MB (peak from baseline: %PEAK_FROM_BASELINE% MB)
echo Start: %START_DETAIL% >> "%LOG_FILE%"
echo End: %END_DETAIL% >> "%LOG_FILE%"
echo Memory delta: %MEM_USED% MB >> "%LOG_FILE%"
:: Check result
if exist "%RESULTS_DIR%\coverage-detailed.json" (
findstr /C:"timeout" "%RESULTS_DIR%\coverage-detailed.json" >nul 2>&1
if !ERRORLEVEL! EQU 0 (
echo RESULT: TIMEOUT - Vectorization didn't help enough
echo RESULT: TIMEOUT >> "%LOG_FILE%"
) else (
findstr /C:"points" "%RESULTS_DIR%\coverage-detailed.json" >nul 2>&1
if !ERRORLEVEL! EQU 0 (
echo RESULT: SUCCESS - Calculation completed!
echo RESULT: SUCCESS >> "%LOG_FILE%"
:: Extract point count
for /f "tokens=2 delims=:" %%a in ('findstr /C:"count" "%RESULTS_DIR%\coverage-detailed.json"') do (
echo Points calculated: %%a
echo Points: %%a >> "%LOG_FILE%"
)
) else (
echo RESULT: ERROR - Check JSON file
echo RESULT: ERROR >> "%LOG_FILE%"
)
)
)
:: ===========================================
:: POST-TEST CLEANUP CHECK
:: ===========================================
echo.
echo [CLEANUP] Checking post-test state...
echo === POST-TEST CLEANUP === >> "%LOG_FILE%"
timeout /t 3 /nobreak >nul
:: Count RFCP processes
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do set RFCP_COUNT=%%a
echo RFCP processes after test: %RFCP_COUNT%
echo RFCP processes after: %RFCP_COUNT% >> "%LOG_FILE%"
:: Memory recovery
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a FINAL_FREE=%%a/1024
set /a MEM_NOT_FREED=BASELINE_FREE_MB-FINAL_FREE
echo Free RAM now: %FINAL_FREE% MB (baseline was: %BASELINE_FREE_MB% MB)
echo Memory not freed: %MEM_NOT_FREED% MB
echo Final free RAM: %FINAL_FREE% MB >> "%LOG_FILE%"
echo Memory not freed: %MEM_NOT_FREED% MB >> "%LOG_FILE%"
if %MEM_NOT_FREED% GTR 500 (
echo WARNING: Possible memory leak - %MEM_NOT_FREED% MB not freed!
echo WARNING: Memory leak detected >> "%LOG_FILE%"
)
if %RFCP_COUNT% GTR 1 (
echo WARNING: Multiple RFCP processes still running!
echo WARNING: Multiple processes >> "%LOG_FILE%"
)
:: ===========================================
:: SUMMARY
:: ===========================================
echo.
echo ============================================
echo TEST SUMMARY
echo ============================================
echo.
echo Results saved to: %RESULTS_DIR%
echo Log file: %LOG_FILE%
echo.
echo Files created:
echo - coverage-fast.json
echo - coverage-standard.json
echo - coverage-detailed.json
echo - monitor-standard.log (memory during standard)
echo - monitor-detailed.log (memory during detailed)
echo - monitor-rfcp.log (rfcp process memory)
echo.
echo === SUMMARY === >> "%LOG_FILE%"
echo Test completed: %date% %time% >> "%LOG_FILE%"
echo ============================================
pause

View File

@@ -0,0 +1,128 @@
@echo off
title RFCP - Detailed Preset Quick Test
setlocal EnableDelayedExpansion
echo ============================================
echo RFCP - Detailed Preset Quick Test
echo ============================================
echo.
echo This tests ONLY the Detailed preset to check
echo if NumPy vectorization is working.
echo.
echo Expected: ^< 90 seconds (was 300s timeout)
echo ============================================
echo.
set API=http://127.0.0.1:8888
:: Check if server is running
echo [1/4] Checking server...
curl -s -o nul -w "HTTP %%{http_code}" %API%/api/health >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Server not responding! Start rfcp-debug.bat first.
pause
exit /b 1
)
echo Server OK
echo.
:: Get baseline
echo [2/4] Capturing baseline...
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a BASE_FREE=%%a/1024
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do set BASE_PROCS=%%a
echo Free RAM: %BASE_FREE% MB
echo RFCP procs: %BASE_PROCS%
echo.
:: Run test
echo [3/4] Running Detailed preset (5km, 300m)...
echo Start: %time%
echo.
curl -s -w "\n HTTP: %%{http_code}\n Time: %%{time_total} seconds\n" ^
-X POST %API%/api/coverage/calculate ^
-H "Content-Type: application/json" ^
-d "{\"sites\": [{\"lat\": 50.45, \"lon\": 30.52, \"height\": 30, \"power\": 43, \"gain\": 15, \"frequency\": 1800}], \"settings\": {\"radius\": 5000, \"resolution\": 300, \"preset\": \"detailed\"}}" ^
-o detailed-result.json
echo.
echo End: %time%
echo.
:: Check result
echo [4/4] Analyzing result...
:: Check for timeout
findstr /C:"timeout" detailed-result.json >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo.
echo ============================================
echo RESULT: TIMEOUT
echo Vectorization needs more optimization.
echo ============================================
echo.
type detailed-result.json
goto :cleanup
)
:: Check for success (has "points")
findstr /C:"\"points\"" detailed-result.json >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo.
echo ============================================
echo RESULT: SUCCESS!
echo Detailed preset completed without timeout!
echo ============================================
echo.
:: Extract stats
echo Extracting stats from result...
:: Count points (rough)
for /f "tokens=2 delims=:," %%a in ('findstr /C:"\"count\"" detailed-result.json') do (
echo Points calculated: %%a
)
:: Get computation time
for /f "tokens=2 delims=:," %%a in ('findstr /C:"\"computation_time\"" detailed-result.json') do (
echo Computation time: %%a seconds
)
goto :cleanup
)
:: Unknown result
echo.
echo RESULT: UNKNOWN
echo Check detailed-result.json manually
type detailed-result.json
:cleanup
echo.
echo ============================================
echo POST-TEST CLEANUP CHECK
echo ============================================
timeout /t 3 /nobreak >nul
for /f %%a in ('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory"') do set /a END_FREE=%%a/1024
for /f %%a in ('tasklist /FI "IMAGENAME eq rfcp-server.exe" 2^>nul ^| find /c "rfcp-server"') do set END_PROCS=%%a
set /a MEM_DIFF=BASE_FREE-END_FREE
echo Free RAM: %END_FREE% MB (was %BASE_FREE% MB, diff: %MEM_DIFF% MB)
echo RFCP procs: %END_PROCS% (was %BASE_PROCS%)
if %MEM_DIFF% GTR 500 (
echo.
echo WARNING: Memory not fully released!
)
if %END_PROCS% GTR %BASE_PROCS% (
echo.
echo WARNING: Extra RFCP processes still running!
)
echo.
echo ============================================
pause