8000 Use mmap.PAGESIZE constant as value for first read. (#505) · lifehacking/client_python@e583016 · GitHub
[go: up one dir, main page]

Skip to content

Commit e583016

Browse files
authored
Use mmap.PAGESIZE constant as value for first read. (prometheus#505)
This size can have a real impact on performance when a lot of files need to be read. The performance relies heavily on the file system cache so reading as little pages as possible helps a lot on memory constrained systems. Signed-off-by: Xavier Fernandez <xavier.fernandez@polyconseil.fr>
1 parent 470b2d3 commit e583016

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prometheus_client/mmap_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def read_all_values_from_file(filename):
8383
with open(filename, 'rb') as infp:
8484
# Read the first block of data, including the first 4 bytes which tell us
8585
# how much of the file (which is preallocated to _INITIAL_MMAP_SIZE bytes) is occupied.
86-
data = infp.read(65535)
86+
data = infp.read(mmap.PAGESIZE)
8787
used = _unpack_integer(data, 0)[0]
8888
if used > len(data): # Then read in the rest, if needed.
8989
data += infp.read(used - len(data))

0 commit comments

Comments
 (0)
0