Summary
JRT.compare2(Object, Object, boolean) appears on the hot path for comparison-heavy AWK programs and should be reviewed for micro-optimization opportunities.
Motivation
During recent performance work around the typed tuple refactor and mandelbrot benchmark, comparison opcodes remained visible in profiling output. JRT.compare2(Object, Object, boolean) likely contributes to comparison opcode cost and may be doing more conversion/type work than necessary for common operand shapes.
Areas to investigate
- Fast paths for common pairs such as
Long/Long, Double/Double, String/String, and numeric scalar combinations
- Avoiding repeated numeric/string coercion where operand types already determine the path
- Branch ordering based on common runtime operand types
- Reducing allocation, boxing, or temporary string creation
- Preserving AWK comparison semantics, especially mixed numeric/string behavior
Suggested validation
- Add focused unit tests for comparison semantics before changing behavior
- Add or run a microbenchmark for common
compare2 operand combinations
- Re-run tuple profiling on comparison-heavy scripts and
mandelbrot.awk
Non-goals
Do not change AWK comparison semantics for performance. Any optimization should be behavior-preserving.
Summary
JRT.compare2(Object, Object, boolean)appears on the hot path for comparison-heavy AWK programs and should be reviewed for micro-optimization opportunities.Motivation
During recent performance work around the typed tuple refactor and mandelbrot benchmark, comparison opcodes remained visible in profiling output.
JRT.compare2(Object, Object, boolean)likely contributes to comparison opcode cost and may be doing more conversion/type work than necessary for common operand shapes.Areas to investigate
Long/Long,Double/Double,String/String, and numeric scalar combinationsSuggested validation
compare2operand combinationsmandelbrot.awkNon-goals
Do not change AWK comparison semantics for performance. Any optimization should be behavior-preserving.