Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -447,8 +447,6 @@ class CodeExecutor:
|
|
| 447 |
|
| 448 |
return self._combine_results(results, main_files)
|
| 449 |
|
| 450 |
-
# Thay thế method _execute_java trong CodeExecutor class
|
| 451 |
-
|
| 452 |
async def _execute_java(
|
| 453 |
self,
|
| 454 |
main_files: List[str],
|
|
@@ -461,25 +459,28 @@ class CodeExecutor:
|
|
| 461 |
java_files = list(Path(workspace).glob("*.java"))
|
| 462 |
needs_compilation = len(java_files) > 0
|
| 463 |
|
| 464 |
-
# JVM options for container environment
|
| 465 |
jvm_opts = [
|
| 466 |
-
"-
|
| 467 |
-
"-
|
| 468 |
-
"-XX:ReservedCodeCacheSize=
|
| 469 |
-
"-XX:InitialCodeCacheSize=
|
| 470 |
-
"-XX:+UseSerialGC", # Simple GC
|
| 471 |
-
"-XX
|
| 472 |
-
"-XX:
|
| 473 |
-
"-XX
|
| 474 |
-
"-XX:
|
|
|
|
|
|
|
|
|
|
| 475 |
]
|
| 476 |
|
| 477 |
# If we have .java files, compile them
|
| 478 |
if needs_compilation:
|
| 479 |
logger.info(f"Found {len(java_files)} Java source files, compiling...")
|
| 480 |
|
| 481 |
-
# Compile with memory
|
| 482 |
-
compile_cmd = ["javac", "-J-
|
| 483 |
|
| 484 |
compile_process = await asyncio.create_subprocess_exec(
|
| 485 |
*compile_cmd,
|
|
|
|
| 447 |
|
| 448 |
return self._combine_results(results, main_files)
|
| 449 |
|
|
|
|
|
|
|
| 450 |
async def _execute_java(
|
| 451 |
self,
|
| 452 |
main_files: List[str],
|
|
|
|
| 459 |
java_files = list(Path(workspace).glob("*.java"))
|
| 460 |
needs_compilation = len(java_files) > 0
|
| 461 |
|
| 462 |
+
# JVM options for very limited container environment (HuggingFace)
|
| 463 |
jvm_opts = [
|
| 464 |
+
"-Xms8m", # Minimal initial heap
|
| 465 |
+
"-Xmx64m", # Very small max heap
|
| 466 |
+
"-XX:ReservedCodeCacheSize=8m", # Minimal code cache
|
| 467 |
+
"-XX:InitialCodeCacheSize=1m", # Tiny initial code cache
|
| 468 |
+
"-XX:+UseSerialGC", # Simple GC
|
| 469 |
+
"-XX:NewRatio=3", # Small young generation
|
| 470 |
+
"-XX:SurvivorRatio=4", # Optimize survivor space
|
| 471 |
+
"-XX:MaxMetaspaceSize=32m", # Limit metaspace
|
| 472 |
+
"-XX:CompressedClassSpaceSize=8m", # Compress class space
|
| 473 |
+
"-Xss256k", # Small stack size
|
| 474 |
+
"-XX:-TieredCompilation", # Disable tiered compilation to save memory
|
| 475 |
+
"-Djava.awt.headless=true", # Headless mode
|
| 476 |
]
|
| 477 |
|
| 478 |
# If we have .java files, compile them
|
| 479 |
if needs_compilation:
|
| 480 |
logger.info(f"Found {len(java_files)} Java source files, compiling...")
|
| 481 |
|
| 482 |
+
# Compile with minimal memory for javac
|
| 483 |
+
compile_cmd = ["javac", "-J-Xmx32m", "-J-Xms8m"] + [str(f) for f in java_files]
|
| 484 |
|
| 485 |
compile_process = await asyncio.create_subprocess_exec(
|
| 486 |
*compile_cmd,
|