LearnNewsExamplesServices
Frontmatter
id8719
titleRefactor ServicesCanvas.mjs for Zero-Allocation & Architecture
stateClosed
labels
airefactoringperformance
assigneestobiu
createdAtJan 16, 2026, 6:40 PM
updatedAtJan 16, 2026, 6:43 PM
githubUrlhttps://github.com/neomjs/neo/issues/8719
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 16, 2026, 6:43 PM

Refactor ServicesCanvas.mjs for Zero-Allocation & Architecture

Closed v11.23.0 airefactoringperformance
tobiu
tobiu commented on Jan 16, 2026, 6:40 PM

The ServicesCanvas.mjs component requires a technical overhaul to align with the "Zero Allocations" paradigm and improve maintainability.

Goals:

  1. Eliminate GC Pressure:
    • Refactor getProjection to avoid creating closures and objects per frame.
    • Refactor project() to write to a shared/reusable mutable object instead of returning new objects for every vertex.
    • Optimize findNeighbors to avoid creating arrays in the render loop.
  2. Architecture:
    • Clean up method organization.
    • Ensure strict Neo.mjs coding guidelines (comments, formatting).
  3. Performance:
    • Optimize math operations.
tobiu added the ai label on Jan 16, 2026, 6:40 PM
tobiu added the refactoring label on Jan 16, 2026, 6:40 PM
tobiu added the performance label on Jan 16, 2026, 6:40 PM
tobiu referenced in commit 4f4c30d - "refactor: Optimize ServicesCanvas for zero-allocation performance (#8719)" on Jan 16, 2026, 6:43 PM
tobiu assigned to @tobiu on Jan 16, 2026, 6:43 PM
tobiu
tobiu Jan 16, 2026, 6:43 PM

Input from Gemini 3 Pro:

✦ I have completed the refactoring of ServicesCanvas.mjs.

Changes:

  1. Zero Allocation Projection: Replaced getProjection (which created closures and objects per frame) with updateProjection and a reusable projectionPoint object.
  2. Optimized Draw Methods: Updated drawHex, drawKernel, drawStrata, drawGraph, drawRunners, and drawDebris to use the new allocation-free project method.
  3. Runner Gradients: Optimized drawRunners to reuse projection results, avoiding double-projection and preventing object creation.

The render loop now operates with significantly reduced GC pressure.

tobiu closed this issue on Jan 16, 2026, 6:43 PM