-
Notifications
You must be signed in to change notification settings - Fork 33
Profile mem #678
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
Merged
Merged
Profile mem #678
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3449cf7
ocrd process: simple memory usage measurement
kba 0cfa612
fix profiler logging test
kba 7e78a5d
ocrd process: memory_usage w/ multiprocess and include_children
kba f005897
Merge branch 'master' into profile-mem
bertsky 342316e
Update ocrd/ocrd/processor/helpers.py
kba a103ac9
mem_usage: run process only once
kba 4fdfbf3
Implement OCRD_PROFILE{_FILE} environemnt variable to configure CPU/m…
kba 97a14b0
describe OCRD_PROFILE{,_FILE} in README
kba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,5 @@ Flask | |
| jsonschema | ||
| pyyaml | ||
| Deprecated == 1.2.0 | ||
| memory-profiler >= 0.58.0 | ||
| sparklines >= 0.4.2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
If it is really that simple – let's make this configurable (PSS vs RSS measuring). Did you try this?
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.
Sure, however we first need a mechanism to toggle this behavior. Simple idea would be to add CLI flags
--mem-profile-rssand--mem-profile-pss.@bertsky prefers a way to have this configurable via the logging configuration - @M3ssman do you have a good idea how that might work? That way, we could keep the CLI arguments small and the
--helpoutput less confusing.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.
Perhaps for the moment it could be as simple as
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.
I like environment variables in general, but when the choice is between environment variables and CLI flags, I prefer the latter, because at least it's consistent. Because otherwise you could get
OCRD_PROFILE=PSS ocrd-dummy --profile-file my.prof ....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.
@kba I agree, however I did not argue env var plus cli arg, but only the former. Perhaps we could also move
--profileand--profile-fileinto env var control entirely.Or we go the other direction and put everything into a single CLI arg, just with multi-faceted value:
--profile mem=rss,cpu,file=foo.logfor example.For the broader discussion of how to configure processors without adding to many options / parameters and what for, see this old thread
Uh oh!
There was an error while loading. Please reload this page.
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, now that the wonky multiple-process-call behavior is fixed, I'll implement this via environment variable
OCRD_PROFILEandOCRD_PROFILE_FILEOCRD_PROFILEnot set or empty: no profilingOCRD_PROFILE_FILEset to a value (== current--profile-fileflag):OCRD_PROFILEis defined but empty: no profilingOCRD_PROFILEis not defined: setOCRD_PROFILEtoCPU* iftoo strict, PROFILE_FILE should imply PROFILE^=CPUOCRD_PROFILEis defined but does not containCPU: raise errorOCRD_PROFILEcontainsCPU, do CPU profiling (== current--profileflag)OCRD_PROFILEcontainsRSSdo RSS memory profilingOCRD_PROFILEcontainsPSS: do proportionate mem profilingIftoo strict,OCRD_PROFILEcontains bothPSSandRSS: raise errorPSStakes precedenceDid I catch everything?
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.
Implemented in 4fdfbf3
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.
Environment variables look good to me.
In the readme, I would also suggest to reference an external link where the difference between
RSSandPSSis explained or at least briefly described. May not be the best suggestion, but consider this.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.
yes, sounds reasonable and complete AFAICS – thx!