summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2015-12-01 04:15:52 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2015-12-01 04:15:52 +0100
commit1152f9623cede7b16672971643d9b0d10aca2122 (patch)
treeb9275150d072b7954b3c876bfc487a3616be1a63
parent6d2d20f511e2ee93b1a64e50ab7db03a3b088cbc (diff)
downloadpsutil-1152f9623cede7b16672971643d9b0d10aca2122.tar.gz
#708: use buffering for open() only on Python 2; on Python 3 this does not have any effect so it's better to let python decide what to do
-rw-r--r--HISTORY.rst12
-rw-r--r--psutil/_pslinux.py7
2 files changed, 11 insertions, 8 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index bf06e8e3..a5c4a1f2 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,15 +3,15 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
3.3.1 - XXXX-XX-XX
==================
-**Bug fixes**
+**Enhancements**
-- #714: [OpenBSD] virtual_memory().cached value was always set to 0.
+- #708: [Linux] psutil.net_connections() and Process.connections() on Python 2
+ can be up to 3x faster in case of many connections.
+ Also psutil.Process.memory_maps() is slightly faster.
-**Enhancements**
+**Bug fixes**
-- 708: [Linux] psutil.net_connections() and Process.connections() can be up to
- 3x faster in case of many connections. Also psutil.Process.memory_maps()
- is slightly faster.
+- #714: [OpenBSD] virtual_memory().cached value was always set to 0.
3.3.0 - 2015-11-25
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index cd1224ac..61bfe5f1 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -63,7 +63,10 @@ if HAS_PRLIMIT:
CLOCK_TICKS = os.sysconf("SC_CLK_TCK")
PAGESIZE = os.sysconf("SC_PAGE_SIZE")
BOOT_TIME = None # set later
-BIGGER_FILE_BUFFERING = 8192
+# Used when reading "big" files, namely /proc/{pid}/smaps and /proc/net/*.
+# On Python 2, using a buffer with open() for such files may result in a
+# speedup, see: https://github.com/giampaolo/psutil/issues/708
+BIGGER_FILE_BUFFERING = -1 if PY3 else 8192
LITTLE_ENDIAN = sys.byteorder == 'little'
if PY3:
FS_ENCODING = sys.getfilesystemencoding()
@@ -71,7 +74,7 @@ if enum is None:
AF_LINK = socket.AF_PACKET
else:
AddressFamily = enum.IntEnum('AddressFamily',
- {'AF_LINK': socket.AF_PACKET})
+ {'AF_LINK': int(socket.AF_PACKET)})
AF_LINK = AddressFamily.AF_LINK
# ioprio_* constants http://linux.die.net/man/2/ioprio_get