Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise response event listener #455

Merged

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Aug 22, 2019

Problem

ResponseEventListener adds unnecessary pressure on heap:

  • It constructs a StateMachine for the response that is being monitored. The underlying StateMachine loads of Map.Entry and Key objects.
  • It uses a separate LiveHttpResponse builder for each ContentError, ContentEnd and ContentCancelled events.

Fix

  • Replace StateMachine object with nested switch/case and if/else statements.
  • Collapse ContentError, ContentEnd, and ContentCancelled event response body content callbacks in a single LiveHttpResponse builder to avoid excessive HTTP header copying.

Impact

On routing object based application router:

  • HeaderEntry: ~ 40% less objects
  • HeaderEntry[]: ~ 33% less objects
  • Object[]: ~ 37% less objects
    And so on.

- Bundle all body event callbacks in one builder call.
- Implement FSM using switch case statements.
whenFinishedAction.run();
state = TERMINATED;
} else if (event instanceof MessageCompleted) {
// TODO: Add custom exception type?
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we deal with this TODO / remove it? What do you think of dating TODO comments?

Copy link
Contributor Author

@mikkokar mikkokar Sep 2, 2019

Choose a reason for hiding this comment

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

Hi David. This is an old TODO that appears in added lines because the code has been refactored.

A date could be helpful for code reviewers to spot old TODO items that have merely moved around. But I'm not opinionated about this.

@mikkokar mikkokar merged commit 22847eb into ExpediaGroup:master Sep 3, 2019
@mikkokar mikkokar deleted the optimise-response-event-listener branch September 3, 2019 11:56
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