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

Parse event data without json #1001

Merged
merged 4 commits into from
Dec 22, 2021
Merged

Parse event data without json #1001

merged 4 commits into from
Dec 22, 2021

Conversation

Chaoba
Copy link
Contributor

@Chaoba Chaoba commented Dec 16, 2021

Summary of changes

This pr removes json in ObservableExtension and parses the event data manually to improve the performance.
Take getMapIdleEventData for example, before the change it will take 3213802ns to parse the data into MapIdleEventData, while with the solution in this pr, it will be 432447ns.

User impact (optional)

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Optimize code for java consumption (@JvmOverloads, @file:JvmName, etc).
  • Add example if relevant.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-android changelog: <changelog>Removes json in ObservableExtension and to improve the performance.</changelog>.
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main firstly and then port to v10.[version] release branch.

Fixes: < Link to related issues that will be fixed by this pull request, if they exist >

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@Chaoba Chaoba self-assigned this Dec 16, 2021
@kiryldz
Copy link
Contributor

kiryldz commented Dec 16, 2021

@Chaoba can you run some tests and record if CPU / mem usage is better?

Copy link
Member

@tobrun tobrun left a comment

Choose a reason for hiding this comment

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

Impressive amount of work!
Do we have any testing in place for this feature already?
If not, can we add?

@alexander-kulikovskii
Copy link
Contributor

btw, @Chaoba do you have any chance to compare your solution with Kotlin serialization?

@tobrun
Copy link
Member

tobrun commented Dec 17, 2021

btw, @Chaoba do you have any chance to compare your solution with Kotlin serialization?

interested in knowing this but not a requirement to close this one out.
Direct mapping will always be faster as a serialization approach.

@Chaoba Chaoba marked this pull request as ready for review December 20, 2021 07:00
@Chaoba Chaoba requested a review from a team as a code owner December 20, 2021 07:00
@Chaoba Chaoba requested a review from yunikkk December 21, 2021 01:54

internal fun Map<String, Value>.nonNullStringWithUpperCase(name: String): String {
return nonNullString(name).toUpperCase(Locale.US).replace(DASH, UNDERLINE)
Copy link
Contributor

Choose a reason for hiding this comment

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

What bothers me is that method is named upperCase but it also replaces dash with underline aside from uppercasing the letters. Maybe rename it if not split to two separate methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, this method actually gets and transforms the string to a valid enum value, which can be used to create an enum instance.
Change the method name to validEnumValue

@Chaoba Chaoba merged commit ec63e1b into main Dec 22, 2021
@Chaoba Chaoba deleted the kl-eventdata branch December 22, 2021 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants