Time Limit Exceeded (TLE) error when switching judges for a small coding‑practice app
0 reputation · 12 Nov 2020, 21:12 UTC
0 reputation · 12 Nov 2020, 21:12 UTC
Migrate a small application that relies on LeetCode‑style judging to a new container‑based judge service while maintaining zero downtime, ensuring that submissions that previously passed continue to receive the same verdict.
The exact wall‑clock timeout that triggers a Time Limit Exceeded (TLE) verdict is not published and varies by language and problem, causing the condition to be nondeterministic for solutions that run close to the limit.
30275 reputation · 13 Nov 2020, 08:01 UTC
1. Verify TLE parity without false positives: Build a benchmark suite of 50–200 historically accepted submissions per problem/language that run at 70–95% of the observed limit. Run them on both judges in shadow mode and compare verdicts, wall-clock time, and CPU time. Any divergence in TLE verdicts signals a threshold mismatch.
2. Monitoring strategy during cutover: Mirror 5–10% of live traffic to the new judge while the old judge remains authoritative. Track TLE rate, verdict distribution, and 95th/99th percentile runtimes per problem/language. Alert on a statistically significant shift (e.g., >2σ change in TLE rate using a two-proportion z-test at α=0.01).
3. Safety margin acceptability and calibration: A 10–20% margin on the configured limit is standard to absorb container startup jitter, CPU scheduling variance, and language-runtime differences. Calibrate by measuring the coefficient of variation (CV) of runtimes for the same submission across 100 repeated runs on the new infrastructure; set margin = 2–3 × CV × mean runtime. Avoid margins >30% to prevent inefficient solutions from passing.
--cpus, --memory, ulimit -t) per language. Verify time accounting (wall vs. CPU) and thread aggregation behavior with a multi-threaded test submission.| Check | Target | Method |
|---|---|---|
| Verdict agreement (non-TLE) | >99.5% | Shadow run 24h |
| False TLE rate | <0.5% | Shadow run 24h |
| Runtime CV (CPU-bound) | <5% | 100 repeated executions |
| Canary TLE shift | No significant increase (z-test α=0.01) | 48h at 5% traffic |
| Limit + margin vs. P99.9 | Margin covers P99.9 | Post-canary analysis |
Does the new judge report wall-clock time or CPU time, and is the accounting method documented per language runtime? This determines whether a conversion factor (e.g., 1 CPU second ≈ 1 wall second on dedicated cores) must be validated before the benchmark suite can be trusted.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.