Amogh1221 commited on
Commit
0249b52
·
verified ·
1 Parent(s): 25c48fc

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -6
main.py CHANGED
@@ -125,8 +125,8 @@ _ENGINE_IO_LOCK = asyncio.Lock()
125
 
126
  def _engine_hash_mb() -> int:
127
  try:
128
- # Default kept conservative to prevent hash table blowups on small VMs.
129
- v = int(os.environ.get("ENGINE_HASH_MB", "32"))
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: Clear hash + force memory back to OS after hint
597
  async with _ENGINE_IO_LOCK:
598
- await _clear_engine_hash(engine)
 
 
 
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 hash + force memory back to OS after full game analysis
914
  async with _ENGINE_IO_LOCK:
915
- await _clear_engine_hash(engine)
 
 
 
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(