[PR #990] [MERGED] perf(comparison): reuse canonical sort keys #2559

Closed
opened 2026-10-17 21:07:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/990
Author: @morluto
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: codex/reference-sort-keys-api2


📝 Commits (1)

  • 0c1afae perf(comparison): reuse canonical sort keys

📊 Changes

2 files changed (+119 additions, -9 deletions)

View changed files

📝 src/domain/functionComparison.test.ts (+106 -0)
📝 src/domain/functionComparisonNormalization.ts (+13 -9)

📄 Description

compareFunctions normalizes complete function collections by sorting canonical JSON projections. Its comparator previously serialized both values again for every sort comparison. The workflow profile showed repeated canonicalization as a major CPU cost, so the sort now computes each key once and retains the established locale collation, code-point tie-break, and stable duplicate ordering.

Validation and evidence:

  • npm run build:cached
  • Focused function comparison and reconstruction function-source tests (88 passed)
  • npm run check:fast
  • npm run format:check
  • npm run docs:check
  • Alternating paired runs at 32, 256, and 1,000 collection entries per dossier: median 6.01→4.56 ms, 45.05→31.73 ms, and 192.70→137.63 ms. Full JSON and SHA-256 matched at every scale, including absent/null fields, nullable endpoints, duplicates, and composed/decomposed Unicode.
  • CPU profile canonicalizer samples fell from 445/1,701 (26.2%) to 97/1,303 (7.4%) on paired public-workflow inputs.

Raw timing data and compiled-module/profile provenance are preserved in the ignored .cache/codebase-audit-20261007/reference-profile/ artifacts. The claim is limited to function comparison; the separate reference-import profile was dominated by filesystem work and showed no demonstrated optimization opportunity.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/990 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/reference-sort-keys-api2` --- ### 📝 Commits (1) - [`0c1afae`](https://github.com/morluto/rea/commit/0c1afae0265bc7585b915dceee88c95985cfea25) perf(comparison): reuse canonical sort keys ### 📊 Changes **2 files changed** (+119 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/functionComparison.test.ts` (+106 -0) 📝 `src/domain/functionComparisonNormalization.ts` (+13 -9) </details> ### 📄 Description `compareFunctions` normalizes complete function collections by sorting canonical JSON projections. Its comparator previously serialized both values again for every sort comparison. The workflow profile showed repeated canonicalization as a major CPU cost, so the sort now computes each key once and retains the established locale collation, code-point tie-break, and stable duplicate ordering. Validation and evidence: - `npm run build:cached` - Focused function comparison and reconstruction function-source tests (88 passed) - `npm run check:fast` - `npm run format:check` - `npm run docs:check` - Alternating paired runs at 32, 256, and 1,000 collection entries per dossier: median 6.01→4.56 ms, 45.05→31.73 ms, and 192.70→137.63 ms. Full JSON and SHA-256 matched at every scale, including absent/null fields, nullable endpoints, duplicates, and composed/decomposed Unicode. - CPU profile canonicalizer samples fell from 445/1,701 (26.2%) to 97/1,303 (7.4%) on paired public-workflow inputs. Raw timing data and compiled-module/profile provenance are preserved in the ignored `.cache/codebase-audit-20261007/reference-profile/` artifacts. The claim is limited to function comparison; the separate reference-import profile was dominated by filesystem work and showed no demonstrated optimization opportunity. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:07:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2559
No description provided.