This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Errors in resource.getpagesize module documentation
Type: Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: [doc] resource module documentation is incorrect
View: 20468
Assigned To: docs@python Nosy List: docs@python, jrunyon, mahmoud, martin.panter, r.david.murray
Priority: normal Keywords:

Created on 2015-05-13 06:21 by mahmoud, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg243043 - (view) Author: Mahmoud Hashemi (mahmoud) * Date: 2015-05-13 06:21
The resource module's description of resource.getpagesize is woefully misguiding. Reproduced in full for convenience:

resource.getpagesize()

    Returns the number of bytes in a system page. (This need not be the same as the hardware page size.) This function is useful for determining the number of bytes of memory a process is using. The third element of the tuple returned by getrusage() describes memory usage in pages; multiplying by page size produces number of bytes.

Besides being vague by not referring to the third element as ru_maxrss, the peak RSS for the process (i.e., not the current memory usage), tests on Linux, Darwin, and FreeBSD show the following:

  * Linux: ru_maxrss is in kilobytes
  * Darwin (OS X): ru_maxrss is in bytes
  * FreeBSD: ru_maxrss is in kilobytes (same as Linux)

Knowing the page size is probably useful to someone, but the misinformation has definitely sent more than one person down the wrong path here. Additionally, the correct information should be up in the getrusage() method documentation, closer to relevant field descriptions.

Mahmoud
msg243081 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-13 12:31
Indeed, we should probably be referring people to their system's man pages for the authoritative definition of most of these fields.

According to the man pages project getpagesize is no longer a POSIX API, and that should probably be noted as well (ie: it isn't present on all systems, and furthermore it is isn't accurate on all systems where it is present...apparently older GCCs got it wrong).
msg254795 - (view) Author: John Runyon (jrunyon) * Date: 2015-11-17 11:52
This is a duplicate of 20468, which has a patch submitted (over a year ago).
msg254817 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-17 22:20
The documentation already says to consult the getrusage(2) man page.

Regarding the getpagesize() API, Python’s implementation actually falls back to Posix’s sysconf(). Perhaps it should prefer sysconf() over getpagesize(), but that would be a separate issue.

Anyway I will commit the important half of the Issue 20468’s patch, so I think we can close this.
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68360
2015-11-17 22:20:07martin.pantersetstatus: open -> closed

superseder: [doc] resource module documentation is incorrect
versions: + Python 3.6
nosy: + martin.panter

messages: + msg254817
resolution: duplicate
stage: needs patch -> resolved
2015-11-17 11:52:43jrunyonsetnosy: + jrunyon
messages: + msg254795
2015-05-13 12:31:51r.david.murraysetstage: needs patch
versions: - Python 3.2, Python 3.3, Python 3.6
2015-05-13 12:31:30r.david.murraysetnosy: + r.david.murray
messages: + msg243081
2015-05-13 06:21:32mahmoudcreate