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

perf: improve DSPLaunchDelegate debug adapter monitor performance #1080

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented Aug 23, 2024

This commit replaces Collections.synchronizedList(new LinkedList<Byte>()) with new ConcurrentLinkedQueue<Byte>() and only determines the console encoding once and not on every text output.

If the console encoding was not specified in the launch config it now falls back to the JVM's default encoding instead of throwing an exception.

@@ -323,16 +324,14 @@ public int read() throws IOException {
return -1;
}
};
DSPLaunchDelegateLaunchBuilder finalBuilder = builder;
final var consoleEncoding = builder.launch.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING);
final var consoleCharset = consoleEncoding == null //
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add to the PR description why are you adding this two calls to Charset instead of just passing consoleEncoding?

Copy link
Member Author

@sebthom sebthom Aug 23, 2024

Choose a reason for hiding this comment

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

consoleEncoding might return null or what do you mean? I just moved the instruction out of the listener where it is unnecessarily reevaluated on each callback

Copy link
Contributor

Choose a reason for hiding this comment

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

Previously the value returned by builder.launch.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING) was passed to text.getBytes as is (just casting to NonNull).
Now if the value is null we map it to a default charset. Is that an intentional change? If so I think it would be worth putting in the commit and PR messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because getBytes(String) would first lookup the CharSet object. If we obtain the Charset before and directly pass it to getBytes() we save that lookup on each listener event.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. To be equivalent as before, we should throw a NPE if builder.launch.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING), otherwise we are changing the behavior, are we not?

I am fine changing the behaviour, but I think it should be added to the commit an PR messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually think falling back to the default charset is more sensible than throwing an exception if the encoding is not overwritten in the launch config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, me too.

Could you amend the commit message and add "If the console encoding was not specified in the launch config it now falls back to the JVM's default encoding instead of throwing an exception." there as well?

Then I am good

This commit replaces `Collections.synchronizedList(new
LinkedList<Byte>())` with `new ConcurrentLinkedQueue<Byte>()` and only
determines the console encoding once and not on every text output. If
the console encoding was not specified in the launch config it now falls
back to the JVM's default encoding instead of throwing an exception.
@sebthom sebthom merged commit 1064aa6 into eclipse:main Aug 26, 2024
6 checks passed
@sebthom sebthom deleted the dsp-launch-delegate branch August 26, 2024 10:39
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