-
Notifications
You must be signed in to change notification settings - Fork 3.7k
perf(intellij): implement GsonService singleton to reduce memory allocation #8524
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
perf(intellij): implement GsonService singleton to reduce memory allocation #8524
Conversation
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 4 files
|
@houssemzaier looks like several e2e tests are failing. Have you been able to run this locally? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@houssemzaier looks good but failing tests
…cation Replace 31+ scattered Gson() instantiations with a centralized application-level GsonService singleton. This eliminates redundant object creation, particularly in hot message handling paths (28 instances in IdeProtocolClient alone). Changes: - Created GsonService as application-scoped singleton (@service annotation) - Updated IdeProtocolClient to use GsonService via default constructor parameter - Updated CoreMessenger to use GsonService via default constructor parameter - Updated ContinueBrowser to use GsonService via default constructor parameter Performance impact: - Eliminates 31+ Gson object allocations per session - Reduces reflection overhead from repeated Gson initialization - Improves message handling performance in IDE-Core communication Addresses: continuedev#8452
7109240 to
dc0e86e
Compare
|
Hi @RomneyDa! 👋 I've rebased on the latest Why I think these are unrelated: This PR only touches 4 Kotlin files in the IntelliJ extension (
All 5 failures are specifically on the I also noticed that 8 out of the last 10 PRs in the CLI PR Checks workflow have been failing with similar issues, which suggests this might be a broader flaky test issue or CI environment problem rather than something introduced by these changes. Are these known flaky tests on macOS with Node 24, or should I investigate further? Thanks for reviewing! 🙏 |
|
@houssemzaier the mac 24 is known flake, thanks for rebasing! |
Description
The IntelliJ plugin created 31+ new
Gson()instances throughout the codebase:IdeProtocolClient(message handling hot path)ContinueBrowserandCoreMessengerEach instantiation incurred object allocation overhead, reflection-based initialization cost, and GC pressure.
Solution
Created an application-scoped
GsonServicesingleton following IntelliJ Platform's Light Service pattern.Implementation:
Performance Impact
Files Changed
4 files modified:
GsonService.kt(new) - Application-scoped singleton serviceIdeProtocolClient.kt- Replaced 28 Gson instantiationsCoreMessenger.kt- Replaced 1 Gson instantiationContinueBrowser.kt- Replaced 2 Gson instantiationsAll changes are backward compatible.
Closes #8452
Checklist
Tests
All existing tests pass. The singleton pattern maintains the same Gson behavior while reducing memory allocation. Constructor injection with default parameters ensures backward compatibility.
Summary by cubic
Introduce a GsonService application singleton to replace 31+ new Gson() allocations. Reduces GC pressure and speeds up hot-path message handling, addressing Linear #8452.
Written for commit dc0e86e. Summary will update automatically on new commits.