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

filter: Add HttpCache interface and helpers #9878

Merged
merged 4 commits into from
Feb 8, 2020

Conversation

toddmgreer
Copy link
Contributor

Description: Adds HttpCache, the pluggable interface for CacheFilter (#868, #7198)

Risk Level: Low. Nothing calls or any of the new code.

Testing: Unit tests.

Docs Changes: none.

Release Notes: N/A

#868

Signed-off-by: Todd Greer <tgreer@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #9878 was opened by toddmgreer.

see: more, trace.

@jmarantz jmarantz self-assigned this Jan 30, 2020
Signed-off-by: Todd Greer <tgreer@google.com>
@toddmgreer
Copy link
Contributor Author

I messed up some of the protoc magic. I'll take another stab at it as soon as I'm back in the office or otherwise find time--sorry for the premature review request.

jmarantz
jmarantz previously approved these changes Jan 31, 2020
Copy link
Contributor

@jmarantz jmarantz 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 modulo 1 nit; will need API approval though.

I have a question about that -- really for @htuch or other @envoyproxy/senior-maintainers -- this is an extension but there is a modification here to what appears to be the core Envoy API. Should we have a different directory for the API provided by an extension, that doesn't require API maintainer review?

source/extensions/filters/http/cache/http_cache.cc Outdated Show resolved Hide resolved
@mattklein123 mattklein123 self-assigned this Jan 31, 2020
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Quick high level question, thank you.

/wait

api/BUILD Outdated Show resolved Hide resolved
Signed-off-by: Todd Greer <tgreer@google.com>
@toddmgreer toddmgreer changed the title CacheFilter: Add HttpCache interface and helpers filter: Add HttpCache interface and helpers Feb 7, 2020
@toddmgreer
Copy link
Contributor Author

PTAL.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

I need to run but flushing out one comment now and will look more later. Very cool stuff!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM from a high level skim. Just some small random comments. Thank you!

/wait

source/extensions/filters/http/cache/http_cache.h Outdated Show resolved Hide resolved
source/extensions/filters/http/cache/http_cache.h Outdated Show resolved Hide resolved
source/extensions/filters/http/cache/http_cache.h Outdated Show resolved Hide resolved
Comment on lines +116 to +117
// Headers of the cached response.
Http::HeaderMapPtr headers_;
Copy link
Member

Choose a reason for hiding this comment

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

This will require copying the headers for every cached response, which seems not-optimal. Since this is in the encoding path and I think we encode with a const ref do we need to copy here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

StreamDecoderFilterCallbacks::encodeHeaders takes a HeaderMapPtr&&, so I don't think I have any alternatives. It seems fine though: we're going to have to create a HeaderMap for the cache entry; handing its ownership to the callbacks makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

OK but then we have to needlessly copy on every cached hit response? In any case, we can deal with this later, but maybe put in a perf TODO somewhere relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not seeing where the needless copy is. Cache storage implementations will generally store a serialized form of the response headers. When ready to serve an entry, they'll create a HeaderMap from it, owned by a HeaderMapPtr, which they'll give to encodeHeaders. Implementations might copy the headers into the HeaderMap, or they might create a new subclass that references the serialized form. If an implementation chooses zero-copy, these interfaces won't get in the way.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like an in-memory implementation could store the actual HeaderMap object. In any case, we can deal with this later.

source/extensions/filters/http/cache/http_cache.cc Outdated Show resolved Hide resolved
Signed-off-by: Todd Greer <tgreer@google.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@toddmgreer
Copy link
Contributor Author

Thank you for the rapid reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants