-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add cache miss logging #165
Conversation
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.
Hello,
Thanks for these changes, see my comments inline.
dogpile/cache/region.py
Outdated
@@ -879,6 +882,7 @@ def get_value(): | |||
value.metadata["ct"] | |||
) | |||
): | |||
log.info('Cache miss for key: %s', orig_key) |
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.
Can you reword this with something like Missing cache for key: %s
dogpile/cache/region.py
Outdated
@@ -32,6 +33,8 @@ | |||
|
|||
""" | |||
|
|||
log = logging.getLogger('c2cwsgiutils.' + __name__) |
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.
Any reason to use c2cwsgiutils
here?
The module name is not enough?
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.
Oups, missing to remove ...
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.
hehe no problems :)
Thanks @4383 , done :-) |
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.
OK, this is sqla-tester setting up my work to try to get revision 0b7a5fb of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change 0b7a5fb: https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528 |
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.
Hervé Beraud (4383) wrote:
Code-Review-1
(1 comment)
Some comment related to your commit message:
- /COMMIT_MSG (line 9): I think we can reword the commit message with something like:
Log missing cache keys
When a cache is missing then we log the key to provide some useful informations to users.
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.
hi there -
There was no issue opened for this so this is the first chance we have to talk about the subject area here of "region should include logging". It should! great idea. But I like to create a full feature rather than adding one liners, that is, think about what people would usually want in this area, not just one thing that we thought of. Please review a few comments I have as far as if we do have logging in region, things we would reasonably expect someone to see in those logs. also I hope that you can review the existing logging that's in lock.
as far as tests, I can relax that there are not tests for these logging statements for now as there are also no tests for the logging in lock.py.
mike bayer (zzzeek) wrote: (1 comment) |
@zzzeek I see your comments, I will work on them the next week :-) |
@zzzeek For me do the changes for all your comment, is it OK for you, are the message good or should be improved? |
I might refactor some of the verbosity here but can you make the %s into %r for the orig_key , I think it's safer |
like a function that can be reused in both
|
@zzzeek Good improvement thanks => fixed :-) |
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.
OK, this is sqla-tester setting up my work to try to get revision b46bb31 of this pull request into gerrit so we can run tests and reviews and stuff
Patchset b46bb31 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528 |
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.
OK, this is sqla-tester setting up my work to try to get revision 693b6b0 of this pull request into gerrit so we can run tests and reviews and stuff
Patchset 693b6b0 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528 |
When a cache is missing then we log the key to provide some useful informations to users.
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.
OK, this is sqla-tester setting up my work to try to get revision 9e519cf of this pull request into gerrit so we can run tests and reviews and stuff
Patchset 9e519cf added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528 |
For me it's ready to be merge, thanks in advance :-) |
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.
Hervé Beraud (4383) wrote:
(1 comment)
Hello,
Some comments inline:
new_values = creator(*keys_to_get) | ||
log.debug( | ||
'Generate cache in %.2f s. for key: %r', |
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.
Hervé Beraud (4383) wrote:
IMHO, I think it's most useful to print here the cache creation date and time instead of the used time to generate the cache.
This operation will surely only take just few miliseconds to generate this cache... In other words this information isn't reallly useful.
Also, I'm not sure, I do not have related benchmark, but I guess %.2f
isn't enough to represent a quick treatment like this, possibly you will to only display "0.00 s" the most of the time.
As a user of this module I prefer know when my cache was created rather than the time used to generate it.
Thoughts?
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.
this could be a slow query against a database or web service and can take any arbitrary amount of time, it could be minutes or any amount of time, which is useful to see in the logs as it would describe why a request is hanging. or if the async runner is used it can take minutes or hours while the app continues to run normally. dogpile.cache's use case is for optimizing data fetches that may be slow, it's the most important number to see in the logs really.
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.
Make sense
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.
also the log line will have the timestamp, so that's the time in which the finished value was created
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.
Good point :)
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.
OK, this is sqla-tester setting up my work to try to get revision 9e519cf of this pull request into gerrit so we can run tests and reviews and stuff
Patchset 9e519cf added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528 |
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.
mike bayer (zzzeek) wrote:
(1 comment)
log.debug( | ||
'Generate cache in %.2f s. for key: %r', | ||
time.time() - start_time, orig_key | ||
) |
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.
mike bayer (zzzeek) wrote:
creator is against keys_to_get here. I'll get this fixed up, thanks!
mike bayer (zzzeek) wrote: Okey doke, if one or both people reviewing this could come over to the gerrit, e.g. https://gerrit.sqlalchemy.org/#/c/sqlalchemy/dogpile.cache/+/1528/ , and look over the whole thing and try to find anything wrong, typos, something that won't work, etc., that would be great. I've run some demo scripts to see what the logging looks like and there's also some unit tests. |
Hervé Beraud (4383) wrote: Code-Review+1 LGTM |
mike bayer (zzzeek) wrote: Code-Review+2 Workflow+1 |
Gerrit review https://gerrit.sqlalchemy.org/1528 has been merged. Congratulations! :) |
Thanks :-) When do you plane to have a new release? CU and Thanks in advance :-) |
it's released and note I am slowly starting to use semver on SQLAlchemy projects other than SQLAlchemy itself. |
Excellent, thanks :-) |
It's relay useful to know which keys is regenerated.