Skip to content

Conversation

carl-mastrangelo
Copy link
Contributor

Metadata.removeAll creates an iterator for looking through removed
values even if the call doens't use it. This change adds a similar
method which doesn't create garbage.

This change makes it easier in the future to alter the internals
of Metadata where it may be expensive to return removed values.

Found by using Yourkit. I personally would have expected the JVM to remove those as dead code, but apparently it does not.

@carl-mastrangelo
Copy link
Contributor Author

@ejona86 FYI

@buchgr
Copy link
Contributor

buchgr commented Sep 8, 2016

LGTM.

Generally, I am unsure whether it's a good idea to change public APIs for small performance improvements. Even if those methods/interfaces are marked experimental or internal. Well, I think designing APIs with performance in mind is a good idea. Say if we can show an impact of 1%, 2% or more.

For example, taking the recents changes in #2238 , #2233 and this PR together. How much does that buy us in terms of real QPS / latency? Do you know?

* optimization if you do not need the previous values.
*/
@ExperimentalApi
public <T> void discardAll(Key<T> key) {
Copy link
Member

Choose a reason for hiding this comment

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

Need to update storeCount.

@ejona86
Copy link
Member

ejona86 commented Sep 8, 2016

@carl-mastrangelo LGTM. Hopefully the failure to update storeCount is the reason for the test failures.

Metadata.removeAll creates an iterator for looking through removed
values even if the call doens't use it.  This change adds a similar
method which doesn't create garbage.

This change makes it easier in the future to alter the internals
of Metadata where it may be expensive to return removed values.
@carl-mastrangelo
Copy link
Contributor Author

@ejona86 yep, that was it.

@buchgr I know sold this as a perf CL, but really I think the API is better this way. Every single call of removeAll in our own code base didn't use the results. The removeAll varies between types, returning boolean for List and Set, Collection for Multimap.

If we weren't maintaining API compat, I would just change removeAll to not return, and add a special method for returning those values.

@carl-mastrangelo carl-mastrangelo merged commit f78644d into grpc:master Sep 8, 2016
@carl-mastrangelo carl-mastrangelo deleted the parseMeMaybe branch September 8, 2016 17:43
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants