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

RESTEasy http performance #5220

Merged
merged 4 commits into from
Nov 7, 2019

Conversation

Sanne
Copy link
Member

@Sanne Sanne commented Nov 5, 2019

A couple minor optimisations in VertxHttpRequest based on profiling data.

Also, removed some unused fields.

@Sanne Sanne added this to the 0.29.0 milestone Nov 5, 2019
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Looks good to me but I would like @stuartwdouglas to check the isFlushed() method shouldn't have been used somehow.

}

@Override
public ResteasyAsynchronousContext getAsyncContext() {
return executionContext;
}

public boolean isFlushed() {
return flushed;
}
Copy link
Member

Choose a reason for hiding this comment

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

@stuartwdouglas just to be sure that this shouldn't have been consumed somehow?

@gsmet gsmet requested a review from stuartwdouglas November 5, 2019 14:16
@gsmet
Copy link
Member

gsmet commented Nov 5, 2019

Test failures doesn't look related, I asked for a recheck.

@Sanne
Copy link
Member Author

Sanne commented Nov 5, 2019

Is the need for @stuartwdouglas 's opinion blocking? I'd suggest it shouldn't, as while it indeed looks fishy, that was definitely dead code. I can open a different issue to have him have a look as independent task.

Or if you'd rather wait for his feedback first I could split this PR so to get the performance fix already :)

@Sanne
Copy link
Member Author

Sanne commented Nov 5, 2019

For more context: making that address field lazy makes a significant difference ;)

@patriot1burke
Copy link
Contributor

LGTM

@geoand
Copy link
Contributor

geoand commented Nov 5, 2019

Is there a reason why I can't rerun the failed tests? I used to be able to :)

@gsmet
Copy link
Member

gsmet commented Nov 5, 2019

It comes and go. Sometimes I don't have the buttons either.

@geoand
Copy link
Contributor

geoand commented Nov 5, 2019

Gotcha, thanks!

String host = socketAddress != null ? socketAddress.host() : null;
// client address may not be available with VirtualHttp;
// using a supplier to make the remote Address resolution lazy: often it's not needed.
Supplier<String> hostNameProvider = () -> {
Copy link
Member

Choose a reason for hiding this comment

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

We try and avoid lambdas in the runtime part of the code as they are much more costly in terms of metaspsace than an anonymous class.

If this is expensive shouldn't the result of this be cached either in the Supplier or in VertxHttpRequest in case getRemoteAddress is called multiple times?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok I can change the lambda to an anonymous class. I know the metaspace cost, TBH I gave up on avoiding them in runtime code as we have many of them anyway, I had the impression nobody except me was still following that recommendation :)

It's not clear to me if it's worth caching the result. I can do that "just in case", but FYI the getter is not invoked during hot-path code in the benchmarks I've run: I verified this by initially running a modified version which was throing an exception.
I had to remove the exception-throwing code as some tests would fail, but it seems seldomly used - I don't know for sure though I guess I could have seen an happy path in my runs.

Copy link
Member Author

Choose a reason for hiding this comment

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

P.S. the reason I ask if it's worth caching, is because null is a valid value - so to cache it I will need to add multiple additional fields.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe don't bother then, it is probably not a big deal.

Copy link
Member

Choose a reason for hiding this comment

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

@Sanne Just for the record, you're not the only one avoiding lambdas in runtime code. We have some in build time but we really try to be careful for the runtime part.

But certainly some have slipped along the way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm what @gsmet mentions from my part as well.
We have instructed contributors multiple times to avoid them.
Of course some can sneak in 😁

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 mean there's plenty in the libraries we use - even if we avoid them in io.quarkus.* code ...

But I agree with the principle of not opting for a lambda without a strong reason, I'll be more careful. Thanks!

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