m.litsa...@postgrespro.ru writes: >> What does this patch give on aglobal scale? Does it save much memory or >> increase performance? How many times?
> This patch makes the code semantically more correct and we don't lose > anything. It is obviously not about performance or memory optimisation. Indeed not: on my machine I see sizeof(pgssEntry) = 432. It's full of int64 fields, so the alignment requirement is 8 bytes, meaning that the mutex field accounts for 8 bytes even though it's likely just 1 or 4 bytes wide. Still, that means what you suggest is only going to save 8/432 = 1.8% of the on-disk size of the struct. Given that we also store the SQL query text for each entry, the net savings fraction is even smaller. I don't really agree that this is adding any semantic correctness either. If we were reading directly into a live hashtable entry, overwriting the mutex field could indeed be bad. But the fread() call is reading into a local variable "temp" and we only copy selected fields out of that. So it's just some bytes in a transient stack entry. On the whole therefore, I'm inclined to reject this on several grounds: * The savings is not worth the costs of bumping the stats file format magic number (and thereby invalidating everyone's stored statistics). * I'd rather keep the flexibility to put the mutex wherever we want in the struct. Right now that isn't worth much either, but depending on what fields get added in future, we might have the opportunity to move the mutex to someplace where it fits into padding space and hence adds nothing to sizeof(pgssEntry). * Adding the requirement on where the mutex is makes the code more fragile, since somebody might ignore the comment and place things incorrectly. I'd like to think that such an error would be spotted immediately, but we've committed sillier mistakes. The consequences would likely be that some fields don't get stored/reloaded correctly, which might escape notice for awhile. regards, tom lane