Skip to content

perf(core): specialize string fingerprint fields and inline separators#99

Closed
Arbousier1 wants to merge 1 commit into
devfrom
perf/delimited-fingerprint-string-overload
Closed

perf(core): specialize string fingerprint fields and inline separators#99
Arbousier1 wants to merge 1 commit into
devfrom
perf/delimited-fingerprint-string-overload

Conversation

@Arbousier1

Copy link
Copy Markdown
Collaborator

Summary

Optimize DelimitedFingerprintBuilder to reduce allocation and method dispatch on the hot fingerprint path.

Changes

  • Add field(String) overload so string fields bypass Objects.toString and go directly to StringBuilder.append(String)
  • Replace Objects.toString(value, "") in field(Object) with an explicit null check — null still appends nothing, non-null still appends toString()
  • Inline appendFieldSeparator() / finishField() into each field(...) overload to eliminate private helper calls
  • Remove unused import java.util.Objects

Behavior equivalence

All existing semantics are preserved:

  • field((Object) null) still appends an empty string (no-op)
  • field("literal") now resolves to field(String) — same output, shorter path
  • raw(Object) and entrySeparator() are unchanged

Verification

Target the infra performance profile (DelimitedFingerprintBuilderBenchmark.buildRepresentativeFingerprint).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Arbousier1 Arbousier1 added the performance-ab Run the base-owned paired performance gate label Jul 18, 2026
Add a field(String) overload so the hot fingerprint path appends string
fields directly via StringBuilder.append(String) instead of routing
through Objects.toString in the field(Object) overload. Replace the
Objects.toString(value, "") call with an explicit null check to avoid
the wrapper allocation, and inline appendFieldSeparator/finishField so
each field(...) overload emits the separator and flag update in the
same frame. Behavior is unchanged: null fields still append nothing,
non-null fields still append toString(), and raw/entrySeparator keep
their existing semantics.
@Arbousier1
Arbousier1 force-pushed the perf/delimited-fingerprint-string-overload branch from 7fc0023 to df2c1f9 Compare July 18, 2026 14:09
@Arbousier1 Arbousier1 removed the performance-ab Run the base-owned paired performance gate label Jul 18, 2026
@Arbousier1

Copy link
Copy Markdown
Collaborator Author

Closing per the refreshed performance gate. The candidate was replayed onto current dev (49d4d2dd) as df2c1f9684c603779436dbe577ae131d3821d62e, then the trusted infra workflow completed all eight paired measurement shards successfully. The final decision was INCONCLUSIVE_NOISE_OR_NO_GAIN, so this specialization does not meet the merge threshold.

Evidence: https://github.com/EllanServer/MahjongEngine/actions/runs/29647578878

@Arbousier1 Arbousier1 closed this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant