Skip to content

perf: implement header stripping and serialization fast-paths - #10

Merged
protheeuz merged 7 commits into
mainfrom
perf/core-optimizations
May 1, 2026
Merged

perf: implement header stripping and serialization fast-paths#10
protheeuz merged 7 commits into
mainfrom
perf/core-optimizations

Conversation

@suckserberg

Copy link
Copy Markdown
Collaborator

Summary

This pull request introduces core performance optimizations and protocol efficiency improvements. Specifically, it implements "header stripping" for fixed-size packets and adds specialized fast-paths for common array/map types.

Technical Implementation

  • Header Stripping: Implemented a registry in Batcher that tracks fixed-size schemas. When a fixed-size packet is batched, the 2-byte size header is omitted, reducing overhead.
  • Serialization Fast-Paths: Added optimized paths in Types for arrays of primitives (u8, f32, boolean, string8, string16). These paths bypass generic field calculations and use optimized buffer loops.
  • Zero-Allocation Dispatch: Refactored Packet dispatch to use pcall(func, arg1) instead of creating anonymous closures, significantly reducing memory pressure under high-volume traffic.
  • Bounds Check Optimization: Replaced manual Lua-level bounds checks with native buffer bounds checks for fixed-size fields, reducing instruction count on the hot path.

Changelog Entry

  • [Core]: Implementation of header stripping for fixed-size packets and high-performance serialization fast-paths. Reduces protocol overhead and improves CPU efficiency for bulk data.

Type of Change

  • Feature
  • Bug Fix
  • Performance Optimization
  • Documentation Update
  • Maintenance / Chore

Verification and Standards

  • I have adhered to the Development Patterns.
  • I have verified that all CI/CD linting and formatting checks pass.
  • I have confirmed the changes within a Rojo-supported environment.
  • I have updated the technical documentation for any API or architectural changes.

@suckserberg
suckserberg requested a review from protheeuz as a code owner May 1, 2026 12:02
@suckserberg
suckserberg requested a review from a team May 1, 2026 12:02
@github-actions github-actions Bot added the enhancement New feature or request label May 1, 2026

@protheeuz protheeuz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

@protheeuz
protheeuz merged commit 1427db1 into main May 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants