Skip to content

perf(lambda-rs): Optimize event dispatch#192

Merged
vmarcella merged 2 commits intomainfrom
vmarcella/optimize-event-dispatch
Mar 12, 2026
Merged

perf(lambda-rs): Optimize event dispatch#192
vmarcella merged 2 commits intomainfrom
vmarcella/optimize-event-dispatch

Conversation

@vmarcella
Copy link
Member

Summary

Optimizes ApplicationRuntime event dispatch by precomputing per-category
listener buckets so each event is delivered only to interested components
instead of scanning the full component stack. This reduces dispatch from
O(C) per event to O(k) per event after a one-time O(C) startup index
build, where C is total components and k is listeners for the event
category.

Related Issues

Changes

  • Added per-category event listener indexing in
    crates/lambda-rs/src/runtimes/application.rs
  • Updated dispatch to iterate only listeners for the current event category
  • Added unit tests for bucket mapping, empty-mask rejection, and listener index
    construction

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (updates to docs, specs, tutorials, or comments)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Performance (change that improves performance)
  • Test (adding or updating tests)
  • Build/CI (changes to build process or CI configuration)

Affected Crates

  • lambda-rs
  • lambda-rs-platform
  • lambda-rs-args
  • lambda-rs-logging
  • Other:

Checklist

  • Code follows the repository style guidelines (cargo +nightly fmt --all)
  • Code passes clippy (cargo clippy --workspace --all-targets -- -D warnings)
  • Tests pass (cargo test --workspace)
  • New code includes appropriate documentation
  • Public API changes are documented
  • Breaking changes are noted in this PR description

Testing

Commands run:

cargo test -p lambda-rs runtimes::application

Manual verification steps (if applicable):

Screenshots/Recordings

N/A

Platform Testing

  • macOS
  • Windows
  • Linux

Additional Notes

@github-actions
Copy link

github-actions bot commented Mar 11, 2026

✅ Coverage Report

📊 View Full HTML Report (download artifact)

Overall Coverage

Metric Value
Total Line Coverage 76.91%
Lines Covered 12762 / 16593

Changed Files in This PR

File Coverage Lines
crates/lambda-rs/src/runtimes/application.rs 35.86% 199/555

PR Files Coverage: 35.85% (199/555 lines)


Generated by cargo-llvm-cov · Latest main coverage

Last updated: 2026-03-12 20:10:50 UTC · Commit: 2c38017

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Optimizes ApplicationRuntime event dispatch by introducing a precomputed per-category listener index, reducing per-event iteration to only components interested in the event’s category.

Changes:

  • Added event_listener_bucket and build_event_listener_index helpers to map event categories to listener buckets and precompute listeners.
  • Updated event dispatch to iterate only the listener indices for the current event category.
  • Added unit tests covering bucket mapping, empty-mask rejection, and listener index construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vmarcella vmarcella merged commit f0895f1 into main Mar 12, 2026
10 checks passed
@vmarcella vmarcella deleted the vmarcella/optimize-event-dispatch branch March 12, 2026 20:17
@vmarcella vmarcella restored the vmarcella/optimize-event-dispatch branch March 12, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants