#7690·questdb

Quiet numeric casts allocate an exception per invalid value when running with -ea

Author: bluestreak01Created Sep 30, 2026Updated Sep 30, 2026

Summary

NumericException.instance() (core/src/main/java/io/questdb/std/NumericException.java) contains:

java
// This is to have correct stack trace in local debugging with -ea option
assert (ex = new NumericException()) != null;

The comment treats -ea as a local-debugging flag, but the production launchers enable it:

  • core/src/main/bin/questdb.sh:360 (-ea -Dnoebug)
  • core/docker-entrypoint.sh:124 (-ea -Dnoebug ...)

In both deployments, every throw of NumericException.instance() allocates a new Throwable and fills in its stack trace. Many hot paths use throw/catch for normal control flow. For example, the quiet casts Numbers.parseIntQuiet, parseLongQuiet and parseDoubleQuiet back 'abc'::int and similar casts, and the numeric column-type converters also rely on it. On these paths each invalid value costs about 1 KB of garbage and a stack walk. This breaks the zero-GC guarantee on the query path.

Measurement

A standalone probe on core/target/classes called Numbers.parseIntQuiet("abc") 2M times per round and took the best of 5 rounds:

JVM flags time/call allocated/call
-ea 970 ns 1024 B
(none) 28 ns 0 B

The probe's stack is shallow. Inside a query the stack is deeper, so the cost per row is higher.

Impact

Any query or conversion that casts many unparseable text values to a numeric type (INT, LONG, DOUBLE, etc.) runs about 35x slower than it should on Linux/macOS/Docker installs and puts heavy pressure on the GC. The Windows service does not pass -ea and is not affected.

Possible directions

  • Keep the per-throw allocation for tests only. For example, gate it on a system property that test runs set, instead of on -ea. Or drop -ea from the production launchers. This needs a check that nothing else relies on assertions in production.
  • Alternatively, give the hot quiet parsers non-throwing internal forms (tri-state or sentinel return), so they never reach NumericException.instance().

Location

  • core/src/main/java/io/questdb/std/NumericException.java:49
  • core/src/main/bin/questdb.sh:360, core/docker-entrypoint.sh:124 (launchers passing -ea)

Found while reviewing PR #7680 (branch vi_pgwire_deallocate). That PR's text-to-BOOLEAN casts hit the same cost and were switched to a non-throwing parse in commit 96a8b07bce. The other quiet numeric casts still pay it on master.