-
Notifications
You must be signed in to change notification settings - Fork 31
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
Profile mem #678
Merged
Merged
Profile mem #678
Changes from 4 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 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 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 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-rss
and--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
--help
output 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
--profile
and--profile-file
into 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.log
for example.For the broader discussion of how to configure processors without adding to many options / parameters and what for, see this old thread
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_PROFILE
andOCRD_PROFILE_FILE
OCRD_PROFILE
not set or empty: no profilingOCRD_PROFILE_FILE
set to a value (== current--profile-file
flag):OCRD_PROFILE
is defined but empty: no profilingOCRD_PROFILE
is not defined: setOCRD_PROFILE
toCPU
* iftoo strict, PROFILE_FILE should imply PROFILE^=CPUOCRD_PROFILE
is defined but does not containCPU
: raise errorOCRD_PROFILE
containsCPU
, do CPU profiling (== current--profile
flag)OCRD_PROFILE
containsRSS
do RSS memory profilingOCRD_PROFILE
containsPSS
: do proportionate mem profilingIftoo strict,OCRD_PROFILE
contains bothPSS
andRSS
: raise errorPSS
takes 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
RSS
andPSS
is 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!