Skip to content

Optimize JRT.compare2(Object, Object, boolean) hot paths #475

@bertysentry

Description

@bertysentry

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions