Skip to content

Implement high-performance LobbySessionStateFrame processing and streaming codecs #3

@thesprockee

Description

@thesprockee

Overview

Implement the following features with a focus on extreme performance and efficiency, as these operations will be invoked up to 600 times per second. All code must minimize memory allocations and avoid unnecessary overhead.


1. High-Performance Frame Processing

  • Implement code to take a sessionResponseData and userBonesResponse (both as []byte), parse them into gameapi.SessionResponse{} and gameapi.UserBonesResponse{}.
  • Build a new LobbySessionStateFrame using these parsed objects, determining all appropriate events.
  • The implementation must be able to reference the previous frame to accurately detect and emit events.
  • The parsing and event detection must be extremely efficient and optimized for high-frequency invocation.

2. Streaming Codecs

  • Zstd Codec: Implement a streaming codec that writes the HEADER and one or more LobbySessionStateFrame objects to a Zstd-compressed .nevrcap file on disk.
  • WebSocket Codec: Implement a streaming codec that connects to a WebSocket server and streams LobbySessionStateFrame objects. Add toggles to choose whether to send session data, user bones as raw bytes, or to unmarshal and detect events (generating and sending LobbySessionStateFrame).
  • EchoReplay Codec: Implement a streaming codec that writes a .echoreplay file (zip format) to disk.

3. File Conversion Utilities

  • Write a function to process a .echoreplay file into a .nevrcap file.
  • Write a function to process a .nevrcap file into a .echoreplay file.

4. Acceptance and Benchmark Tests

  • Provide acceptance tests for the .echoreplay file processors (external format compatibility).
  • Provide a benchmark for uncompressed .echoreplay ➔ uncompressed .nevrcap processing performance.
  • Provide a benchmark comparing .echoreplay vs .nevrcap file size.

5. BENCHMARKS.md and Automation

  • Create a BENCHMARKS.md to capture the latest benchmark values.
  • Implement a script to run all benchmarks and automatically update BENCHMARKS.md.

Acceptance Criteria:

  • All codecs and utilities are implemented and tested for performance.
  • Benchmarks and acceptance tests are present and automated.
  • BENCHMARKS.md is created and kept up to date via script.
  • Code is suitable for high-frequency, low-latency processing scenarios.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions