From bab567a14afb7e9cdb112503e8adc32f32875714 Mon Sep 17 00:00:00 2001 From: Pathompum Jirakarnpaisan <107536914+Saannddy@users.noreply.github.com> Date: Thu, 9 Apr 2026 21:59:53 +0700 Subject: [PATCH 1/3] refactor: optimize Java compilation and execution by setting release version, clearing environment variables, and adjusting JVM memory settings --- README.md | 4 ++-- src/core/executor.py | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 39d3c94..ed2b979 100644 --- a/README.md +++ b/README.md @@ -110,8 +110,8 @@ Seed the database with Java MCQs, riddles, and problems tagged as `JAV_RESTROOM` ```bash # Running via Docker (Must rebuild if scripts are modified) -docker compose --profile local up -d --build -docker compose --profile local exec local-code-api python3 -m scripts.seeders.seed_restroom_java +docker compose --profile local up -d --builddocker compose --profile local exec local-code-api python3 -m scripts.seeders.seed_restroom_java + # Running Locally (Ensure .env is configured or set DATABASE_URL) export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/code_executor diff --git a/src/core/executor.py b/src/core/executor.py index b791ef1..cecb0b0 100644 --- a/src/core/executor.py +++ b/src/core/executor.py @@ -122,26 +122,28 @@ def _run_java(code, tests=None, timeout=None): f.write(code) try: - # Added JVM args to javac to speed up its own startup time + # Compile with --release 11 for broad compatibility and fast startup comp = subprocess.run([ - "javac", - "-J-XX:+TieredCompilation", - "-J-XX:TieredStopAtLevel=1", + "javac", + "-J-XX:+TieredCompilation", + "-J-XX:TieredStopAtLevel=1", + "--release", "11", src, "-d", d - ], capture_output=True, text=True, timeout=max(timeout, 10), cwd=d) + ], capture_output=True, text=True, timeout=max(timeout, 10), cwd=d, + env={**os.environ, "JAVA_TOOL_OPTIONS": ""}) if comp.returncode: return {"status": "incorrect", "message": "Compilation failed", "compiler_output": comp.stderr} except subprocess.TimeoutExpired: return {"status": "error", "message": "Compilation timed out"} - - # Optimized JVM startup arguments + + # Optimized JVM startup arguments (removed deprecated -noverify) cmd = [ - "java", - "-cp", d, - f"-Xmx{MAX_MEMORY_MB}m", - "-XX:+TieredCompilation", - "-XX:TieredStopAtLevel=1", - "-noverify", + "java", + "-cp", d, + f"-Xmx{MAX_MEMORY_MB}m", + f"-Xms32m", + "-XX:+TieredCompilation", + "-XX:TieredStopAtLevel=1", class_name ] if tests is None: From 1d3058c4f847794012a61be6b74237e72f97fd7b Mon Sep 17 00:00:00 2001 From: Pathompum Jirakarnpaisan <107536914+Saannddy@users.noreply.github.com> Date: Thu, 9 Apr 2026 22:01:01 +0700 Subject: [PATCH 2/3] docs: fix formatting of docker compose commands in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed2b979..47cddc0 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,8 @@ Seed the database with Java MCQs, riddles, and problems tagged as `JAV_RESTROOM` ```bash # Running via Docker (Must rebuild if scripts are modified) -docker compose --profile local up -d --builddocker compose --profile local exec local-code-api python3 -m scripts.seeders.seed_restroom_java +docker compose --profile local up -d --build +docker compose --profile local exec local-code-api python3 -m scripts.seeders.seed_restroom_java # Running Locally (Ensure .env is configured or set DATABASE_URL) From 12ea78fe55542eb698d74500329b2fb081c03ef5 Mon Sep 17 00:00:00 2001 From: Pathompum Jirakarnpaisan <107536914+Saannddy@users.noreply.github.com> Date: Thu, 9 Apr 2026 22:01:24 +0700 Subject: [PATCH 3/3] docs: remove redundant whitespace from README setup instructions --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 47cddc0..39d3c94 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,6 @@ Seed the database with Java MCQs, riddles, and problems tagged as `JAV_RESTROOM` docker compose --profile local up -d --build docker compose --profile local exec local-code-api python3 -m scripts.seeders.seed_restroom_java - # Running Locally (Ensure .env is configured or set DATABASE_URL) export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/code_executor PYTHONPATH=src python3 src/scripts/seeders/seed_restroom_java.py