Re: Unhappy about API changes in the no-fsm-for-small-rels patch
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, John Naylor <john.naylor@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-05-06T15:27:32Z
Lists: pgsql-hackers
Hi, On 2019-05-06 11:10:15 -0400, Robert Haas wrote: > I'm really surprised that the original design of this patch involved > storing state in global variables. That seems like a pretty poor > decision. This is properly per-relation information, and any approach > like that isn't going to work well when there are multiple relations > involved, unless the information is only being used for a single > attempt to find a free page, in which case it should use parameters > and function-local variables, not globals. I'm was too. > I think it's legitimate to question whether sending additional > invalidation messages as part of the design of this feature is a good > idea. If it happens frequently, it could trigger expensive sinval > resets more often. I don't understand the various proposals well > enough to know whether that's really a problem, but if you've got a > lot of relations for which this optimization is in use, I'm not sure I > see why it couldn't be. I don't think it's an actual problem. We'd only do so when creating an FSM, or when freeing up additional space that'd otherwise not be visible to other backends. The alternative to sinval would thus be a) not discovering there's free space and extending the relation b) checking disk state for a new FSM all the time. Which are much more expensive. > I think at some point it was proposed that, since an FSM access > involves touching 3 blocks, it ought to be fine for any relation of 4 > or fewer blocks to just check all the others. I don't really > understand why we drifted off that design principle, because it seems > like a reasonable theory. Such an approach doesn't require anything > in the relcache, any global variables, or an every-other-page > algorithm. It's not that cheap to touch three heap blocks every time a new target page is needed. Requires determining at least the target relation size or the existance of the FSM fork. We'll also commonly *not* end up touching 3 blocks in the FSM - especially when there's actually no free space. And the FSM contents are much less contended than the heap pages - the hot paths don't update the FSM, and if so, the exclusive locks are held for a very short time only. Greetings, Andres Freund
Commits
-
Revert "Avoid the creation of the free space map for small heap relations".
- 7db0cde6b58e 12.0 landed
-
Improve code comments in b0eaa4c51b.
- 06c8a5090ed9 12.0 cited
-
During pg_upgrade, conditionally skip transfer of FSMs.
- 13e8643bfc29 12.0 cited
-
Add more tests for FSM.
- 6f918159a97a 12.0 cited
-
Fix typos in commit 8586bf7ed8.
- a6e48da08844 12.0 cited
-
tableam: introduce table AM infrastructure.
- 8586bf7ed888 12.0 cited
-
Clear the local map when not used.
- 9c32e4c35026 12.0 cited
-
Doc: Update the documentation for FSM behavior for small tables.
- 29d108cdecbe 12.0 cited
-
Make FSM test portable.
- 08ecdfe7e5e0 12.0 cited
-
Avoid creation of the free space map for small heap relations, take 2.
- b0eaa4c51bbf 12.0 cited