Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -125,8 +125,8 @@ _ENGINE_IO_LOCK = asyncio.Lock()
|
|
| 125 |
|
| 126 |
def _engine_hash_mb() -> int:
|
| 127 |
try:
|
| 128 |
-
# Default
|
| 129 |
-
v = int(os.environ.get("ENGINE_HASH_MB", "
|
| 130 |
except ValueError:
|
| 131 |
v = 128
|
| 132 |
return max(8, min(512, v))
|
|
@@ -593,9 +593,12 @@ async def get_analysis_move(request: MoveRequest):
|
|
| 593 |
del result
|
| 594 |
del info
|
| 595 |
|
| 596 |
-
# FIX:
|
| 597 |
async with _ENGINE_IO_LOCK:
|
| 598 |
-
|
|
|
|
|
|
|
|
|
|
| 599 |
force_memory_release()
|
| 600 |
|
| 601 |
return MoveResponse(
|
|
@@ -910,9 +913,12 @@ async def analyze_game(request: AnalyzeRequest):
|
|
| 910 |
accuracy = max(10.0, min(100.0, 100.0 * math.exp(-0.005 * avg_cpl)))
|
| 911 |
estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.015 * avg_cpl)))))
|
| 912 |
|
| 913 |
-
# FIX: Clear engine
|
| 914 |
async with _ENGINE_IO_LOCK:
|
| 915 |
-
|
|
|
|
|
|
|
|
|
|
| 916 |
force_memory_release()
|
| 917 |
|
| 918 |
return AnalyzeResponse(
|
|
|
|
| 125 |
|
| 126 |
def _engine_hash_mb() -> int:
|
| 127 |
try:
|
| 128 |
+
# Default used for transposition table size testing.
|
| 129 |
+
v = int(os.environ.get("ENGINE_HASH_MB", "512"))
|
| 130 |
except ValueError:
|
| 131 |
v = 128
|
| 132 |
return max(8, min(512, v))
|
|
|
|
| 593 |
del result
|
| 594 |
del info
|
| 595 |
|
| 596 |
+
# FIX: clear/restart engine to keep memory stable after hint
|
| 597 |
async with _ENGINE_IO_LOCK:
|
| 598 |
+
if _RESTART_ENGINE_AFTER_MOVE:
|
| 599 |
+
await _detach_and_quit_engine(engine)
|
| 600 |
+
elif _CLEAR_HASH_AFTER_MOVE:
|
| 601 |
+
await _clear_engine_hash(engine)
|
| 602 |
force_memory_release()
|
| 603 |
|
| 604 |
return MoveResponse(
|
|
|
|
| 913 |
accuracy = max(10.0, min(100.0, 100.0 * math.exp(-0.005 * avg_cpl)))
|
| 914 |
estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.015 * avg_cpl)))))
|
| 915 |
|
| 916 |
+
# FIX: Clear/restart engine to keep memory stable after full game analysis
|
| 917 |
async with _ENGINE_IO_LOCK:
|
| 918 |
+
if _RESTART_ENGINE_AFTER_MOVE:
|
| 919 |
+
await _detach_and_quit_engine(engine)
|
| 920 |
+
elif _CLEAR_HASH_AFTER_MOVE:
|
| 921 |
+
await _clear_engine_hash(engine)
|
| 922 |
force_memory_release()
|
| 923 |
|
| 924 |
return AnalyzeResponse(
|