Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Improve Packet Listener Performance #19

@twisti-dev

Description

@twisti-dev

What Needs Improvement?

The current packet listener system lacks optimal performance and does not take advantage of modern Spring features or low-level performance enhancements. It uses a more traditional listener pattern which can become a bottleneck, especially under high concurrency or frequent packet event conditions.

Proposed Improvement

Enhance the packet listener system by integrating:

  1. Spring’s Event System:

    • Use a modified version of springs @EventListener annotations for event handling.
    • Enable conditional listeners using SpEL expressions.
    • Leverage Spring’s automatic bean registration and AOP support for clean, modular handling.
  2. LambdaEvents Library:

    • Use LambdaEvents for ASM-based bytecode generation of listener dispatchers.
    • Replace or wrap the current event dispatch mechanism to benefit from significantly faster runtime performance.
    • Maintain event lifecycle integration with Spring to preserve consistency and manageability.
  3. Hybrid Dispatcher:

    • Create a dispatcher that supports both Spring-managed and LambdaEvents-managed listeners.
    • Allow configuration to toggle ASM optimization per event type or globally.

Benefits of the Improvement

  • Improved Performance: LambdaEvents significantly reduces the overhead of event dispatch via bytecode rewriting.
  • Enhanced Flexibility: Spring’s system supports filtering, conditional execution, and async handling natively.
  • Cleaner Architecture: AOP and DI features from Spring improve separation of concerns and testability.
  • Scalability: The hybrid system allows for modular event handling, scaling efficiently for both light and heavy event traffic scenarios.

Additional Context

  • LambdaEvents GitHub: https://github.com/Lenni0451/LambdaEvents/
  • Consider combining listener registration with a Spring @Configuration class and integrating a custom ApplicationEventMulticaster if needed for custom dispatch logic.

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions