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

Move serialization to LogEvent.getBody(). #201

Merged
merged 1 commit into from
Aug 1, 2018

Conversation

mikecdavis
Copy link
Contributor

This PR moves the serialization from POJO to JSON into LogEvent#getBody(). This allows the serialization of the event to be offloaded to with the event handler when the HTTP request is built. This should be 100% backwards compatible with any existing EventHandler implementations. Initial benchmarks are much improved over the current master in tight loop simulations.

Stats after 100,000 calls to activate(...) in my simulation:

Metric (us) PR-199 2.0.0-beta2 2.0.0-SNAPSHOT THIS PR
Min 21 2 3 1
Median 29 2 9 6
Mean 41 3.8 10.2 6.1
75th Pct 40 3 11 7
95th Pct 85 7 18 11
99th Pct 126 26 43 21
999th Pct 713 65 237 232
Max 11825 17732 34384 12845

Note 2.0.0-beta2 was pre-batch endpoint, so isn't a valid comparison. Also performance runs can have some volatility, but the overall trends remain.

I've also wrapped some calls to logger.debug in logger.isDebugEnabled() to prevent unused log statement from triggering the serialization synchronously.

@coveralls
Copy link

coveralls commented Aug 1, 2018

Pull Request Test Coverage Report for Build 567

  • 14 of 15 (93.33%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 89.373%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/event/LogEvent.java 6 7 85.71%
Totals Coverage Status
Change from base Build 566: -0.03%
Covered Lines: 2338
Relevant Lines: 2616

💛 - Coveralls

@aliabbasrizvi
Copy link
Contributor

THANK YOU !! Taking a closer look now.

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

Awesome. LGTM.

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

I had tried this approach but it turns out that the class loader and possibly some of the annotations evaluated at class loading time are actually taking up 60% of initial startup on first activate.

That said, I wanted to make this change anyway, as I would like to decouple json serialization implementation from core.

@mikecdavis mikecdavis merged commit 199b0dc into master Aug 1, 2018
@mikecdavis mikecdavis deleted the mikecdavis/OASIS-3183-async-serialization branch August 1, 2018 19:17
@ceimaj
Copy link

ceimaj commented Aug 1, 2018

@thomaszurkan-optimizely can we get this into the 2.1 Android release?

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.

5 participants