lweitzendorf opened a new pull request, #3132: URL: https://github.com/apache/jackrabbit-oak/pull/3132
[OAK-12402](https://issues.apache.org/jira/browse/OAK-12402) ## Problem `Validate.checkArgument(boolean, String, Object...)` autoboxes primitive arguments and allocates a varargs `Object[]` on every call — even when the condition holds. `ListRecord` validates its size with this varargs overload: ```java checkArgument(size >= 0, "Negative list size: %s", size); checkArgument(size <= MAX_ELEMENTS, "Too many elements in list: %s", size); ``` `ListRecord` is constructed on the hot record-navigation path (every multi-value / multi-segment / large-string read), so this boxes an `int` and allocates an `Object[]` on every construction. When Oak removed its Guava dependency, `Validate` replaced Guava's `Preconditions`, but the primitive `checkArgument` overloads (`int`, `long`, …) weren't carried over, so there's no allocation-free path for the common single-primitive case. ## Evidence Profiling a segment-store traversal with JFR (`settings=profile`) showed `java.lang.Integer.valueOf` at ~3.3% of on-CPU samples, 100% attributable to `ListRecord.<init>`. ## Change Restore primitive `int`/`long` `checkArgument` overloads in `Validate`, mirroring the varargs contract (`messageTemplate` null-check + `checkTemplate`/`CHECKMESSAGETEMPLATE` diagnostic) so the passing path allocates nothing. Existing single-primitive call sites (e.g. `ListRecord`) bind to them automatically at compile time — no call-site change. ## Notes - Backward-compatible addition to an exported package → minor package version bump (`1.0.0`→`1.1.0`); `bundle:baseline` passes with 0 errors. - Restores parity with Guava `Preconditions`' primitive overloads, lost in the Guava removal. - A boxed `Integer`/`Long` argument now binds to the primitive overload (phase-2 unboxing) rather than varargs — matches Guava's long-standing behaviour; a scan of current callers found no nullable-boxed caller affected. - Added `int`/`long` cases to `ValidateTest` (success, failure formatting, null-template NPE parity). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
