Use StandardCharsets.UTF_8 in JacksonSerializer#49
Merged
jaredmixpanel merged 2 commits intofeature/jackson-performance-optimizationfrom Nov 21, 2025
Merged
Use StandardCharsets.UTF_8 in JacksonSerializer#49jaredmixpanel merged 2 commits intofeature/jackson-performance-optimizationfrom
jaredmixpanel merged 2 commits intofeature/jackson-performance-optimizationfrom
Conversation
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix optional Jackson serialization for performance improvement
Use StandardCharsets.UTF_8 in JacksonSerializer
Nov 21, 2025
jaredmixpanel
approved these changes
Nov 21, 2025
jaredmixpanel
added a commit
that referenced
this pull request
Nov 24, 2025
…n large batches (#48) * feat: Add optional Jackson serialization for 5x performance improvement Implements high-performance JSON serialization using Jackson's streaming API while maintaining complete backward compatibility with the existing org.json public API. Key improvements: - Automatic detection and use of Jackson when available on classpath - Up to 5x performance improvement for large batch imports (50+ messages) - Zero breaking changes - all public APIs remain unchanged - Graceful fallback to org.json when Jackson is not available Performance benchmarks show: - Small batches (1-10 messages): 1.2-1.5x faster - Medium batches (50-100 messages): ~5x faster - Large batches (500-2000 messages): ~5x faster consistently Implementation details: - Created internal JsonSerializer interface for pluggable implementations - JacksonSerializer uses streaming API to avoid conversion overhead - SerializerFactory automatically selects best available implementation - Modified dataString() method to use the new serialization layer This is particularly beneficial for the /import endpoint which handles up to 2000 messages per batch (40x larger than regular /track endpoint). Users simply add jackson-databind dependency to enable this optimization. No code changes required - the library automatically detects and uses it. * Add exception logging to Jackson serialization fallback (#50) * Initial plan * Add logging for Jackson serialization fallback Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> * Use StandardCharsets.UTF_8 in JacksonSerializer (#49) * Initial plan * Use StandardCharsets.UTF_8 instead of "UTF-8" string literal Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> * Update src/test/java/com/mixpanel/mixpanelapi/internal/SerializerBenchmark.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Update Jackson version to 2.20.0 Updates Jackson dependency from 2.15.3 to 2.20.0 for the latest performance improvements and security patches. * Update src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces string literal
"UTF-8"withStandardCharsets.UTF_8inJacksonSerializer.serializeArrayToBytes()to eliminate unnecessary checked exception handling and improve type safety.Changes:
java.nio.charset.StandardCharsetsimport"[]".getBytes("UTF-8")to"[]".getBytes(StandardCharsets.UTF_8)on line 46This aligns
JacksonSerializerwith the existing pattern inOrgJsonSerializer(line 32).💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.