-
Notifications
You must be signed in to change notification settings - Fork 223
New method to detect total available RAM on the building machine #1623
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
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
02bf52c
Added method to detect system memory
4aaf51f
Fixed some bugs
f9d6c2b
Merge branch 'runcmd_fix' into availmem
71bce32
Merge branch 'develop' into availmem
15fd6cf
Merge branch 'develop' into availmem
6856184
Merge branch 'develop' into availmem
68a56c0
Merge branch 'develop' into availmem
a6ef955
Merge branch 'develop' into availmem
1535244
Merge branch 'develop' into availmem
b5cd01e
Merge branch 'develop' into availmem
0f3ce85
Merge branch 'develop' into availmem
5336fbf
Merge branch 'develop' into availmem
c509cb3
Merge branch 'develop' into availmem
1d84a68
Merge branch 'develop' into availmem
e4a45d0
Merge branch 'develop' into availmem
d7c7b6f
Replace initial value of 0 with None
d18aedb
Merge branch 'develop' into availmem
d37488c
Minor changes to get_total_memory and a test for same
ac8a838
Make sure get_total_memory is actually available for testing
4b68db6
Add total memory entry to system_info dictionary
85f6a6d
Merge branch 'develop' into availmem
f1f6909
don't raise SystemException, return UNKNOWN if memory could not be de…
boegel 9efefd3
break up test for get_total_memory in tests for Linux, Darwin and native
boegel 5ebe8da
fix implementation of get_total_memory on Darwin
boegel ce0fb44
Merge branch 'develop' into availmem
dd14902
Merge branch 'develop' into availmem
2e68482
Merge branch 'develop' into availmem
0c709ac
Merge pull request #2 from boegel/availmem
valtandor 60bb532
Merge branch 'develop' into availmem
042b1ae
Merge conflicts from Kenneth's PR
f4f34df
fix mocking of 'sysctl -n hw.memsize' in systemtools tests
boegel 3a72d29
Merge pull request #3 from boegel/availmem
valtandor 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ | |
|
|
||
| MAX_FREQ_FP = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' | ||
| PROC_CPUINFO_FP = '/proc/cpuinfo' | ||
| PROC_MEMINFO_FP = '/proc/meminfo' | ||
|
|
||
| CPU_FAMILIES = [ARM, AMD, INTEL, POWER] | ||
| VENDORS = { | ||
|
|
@@ -106,6 +107,36 @@ def get_core_count(): | |
| _log.nosupport("get_core_count() is replaced by get_avail_core_count()", '2.0') | ||
|
|
||
|
|
||
| def get_total_memory(): | ||
| """ | ||
| Try to ascertain this node's total memory | ||
|
|
||
| @return: total memory as an integer, specifically a number of megabytes | ||
| """ | ||
| memtotal = None | ||
| os_type = get_os_type() | ||
|
|
||
| if os_type == LINUX and os.path.exists(PROC_MEMINFO_FP): | ||
| _log.debug("Trying to determine total memory size on Linux via %s", PROC_MEMINFO_FP) | ||
| meminfo = read_file(PROC_MEMINFO_FP) | ||
| mem_mo = re.match(r'^MemTotal:\s*(\d+)\s*kB', meminfo, re.M) | ||
| if mem_mo: | ||
| memtotal = int(mem_mo.group(1)) / 1024 | ||
|
|
||
| elif os_type == DARWIN: | ||
| cmd = "sysctl -n hw.memsize" | ||
| _log.debug("Trying to determine total memory size on Darwin via cmd '%s'", cmd) | ||
| out, ec = run_cmd(cmd, force_in_dry_run=True) | ||
| if ec == 0: | ||
| memtotal = int(out.strip()) / (1024**2) | ||
|
|
||
| if memtotal is None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allowing $BC_MEM_PER_NODE would permit to overcome the limitation on missing or unmounted /proc/meminfo, |
||
| memtotal = UNKNOWN | ||
| _log.warning("Failed to determine total memory, returning %s", memtotal) | ||
|
|
||
| return memtotal | ||
|
|
||
|
|
||
| def get_cpu_vendor(): | ||
| """ | ||
| Try to detect the CPU vendor | ||
|
|
@@ -466,6 +497,7 @@ def get_system_info(): | |
| python_version = '; '.join(sys.version.split('\n')) | ||
| return { | ||
| 'core_count': get_avail_core_count(), | ||
| 'total_memory': get_total_memory(), | ||
| 'cpu_model': get_cpu_model(), | ||
| 'cpu_speed': get_cpu_speed(), | ||
| 'cpu_vendor': get_cpu_vendor(), | ||
|
|
||
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.
If possible, it would be nice, if there was the ability to tune things from the outside about this, such as $BC_MEM_PER_NODE:
http://centers.hpc.mil/consolidated/bc/policies.php?choice=environment
The meaning of this is to be able to modify builds behavior dynamically, by adjusting such a variable.
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 we do that, we should do it consistently (also for other system features), and it should be well documented which environment variables EB picks up on...
So, not in this PR.