> This is the point where I think I am missing something about patch. > As far as I can understand, it uses the same freelist index > (freelist_idx) for allocating and putting back the entry, so I think > the chance of increment in one list and decrement in another is there > when the value of freelist_idx is calculated differently for the same > input, is it so, or there is something else in patch which I am > missing?
You are right, nentries _can't_ be negative unless we are using getpid() for calculating freelist_idx, since same index of nentries is used when we add (increment) and remove (decrement) element from/to hash table. The fact that we also borrow elements from other freelists if there is no more elements in our freelist doesn't change anything. > One idea is to jigger things so that we maintain a count of the total > number of entries that doesn't change except when we allocate, and > then for each freelist partition we maintain the number of entries in > that freelist partition. So then the size of the hash table, instead > of being sum(nentries) is totalsize - sum(nfree). This is an interesting idea. Still I strongly disagree that is should be implemented in this concrete patch and discussed in this concrete thread. Obviously such type of change deserves a separate research and discussing since it has nothing to do with performance and since we agreed that "change LOG2_NUM_LOCK_PARTITIONS value" and "change the calling convention for ShmemInitHash()" patches should be implemented separately. I added it to my TODO list. Once again I suggest we merge this patch already: http://www.postgresql.org/message-id/CA+Tgmobtf9nH566_jjs=jrtymq5hdqdarf5j7o+abdowqhe...@mail.gmail.com I have a strong feeling that we are just wasting our time here. -- Best regards, Aleksander Alekseev http://eax.me/ -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers