Question about lazy_space_alloc() / linux over-commit - Mailing list pgsql-hackers

From Jim Nasby
Subject Question about lazy_space_alloc() / linux over-commit
Date
Msg-id 54EE474A.4040601@BlueTreble.com
Whole thread Raw
Responses Re: Question about lazy_space_alloc() / linux over-commit
List pgsql-hackers
Could the large allocation[2] for the dead tuple array in 
lazy_space_alloc cause problems with linux OOM? [1] and some other 
things I've read indicate that a large mmap will count towards total 
system memory, including producing a failure if overcommit is disabled.

Would it be worth avoiding the full size allocation when we can?

If we did this, I think allocate reltuples * autovacuum_vacuum_threshold 
slots initially, and then growing the array if needed.

1: 
http://stackoverflow.com/questions/9129004/why-does-calling-mmap-with-large-size-not-fail

2:
In lazy_space_alloc() we will palloc the dead tuple array to be as large 
as maintenance_work_mem, with the only limit being that we won't make it 
larger than the maximum possible number of tuples in the relation.

My understanding is that this doesn't suck only because palloc passes 
such a large allocation direct to malloc, which in turn uses mmap, which 
won't actually allocate the memory until we access it.
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: INSERT ... ON CONFLICT UPDATE and logical decoding
Next
From: Andrew Dunstan
Date:
Subject: Re: contrib/fuzzystrmatch/dmetaphone.c license