- Notifications
You must be signed in to change notification settings - Fork5.1k
Commit38b602b
committed
Move dynamically-allocated LWLock tranche names to shared memory.
There are two ways for shared libraries to allocate their ownLWLock tranches. One way is to call RequestNamedLWLockTranche() ina shmem_request_hook, which requires the library to be loaded viashared_preload_libraries. The other way is to callLWLockNewTrancheId(), which is not subject to the samerestrictions. However, LWLockNewTrancheId() does require eachbackend to store the tranche's name in backend-local memory viaLWLockRegisterTranche(). This API is a little cumbersome and leadsto things like unhelpful pg_stat_activity.wait_event values inbackends that haven't loaded the library.This commit moves these LWLock tranche names to shared memory, thuseliminating the need for each backend to callLWLockRegisterTranche(). Instead, the tranche name must beprovided to LWLockNewTrancheId(), which immediately makes the nameavailable to all backends. Since the tranche name array isappend-only, lookups can ordinarily avoid locking as long as theirlocal copy of the LWLock counter is greater than the requestedtranche ID.One downside of this approach is that we now have a hard limit onboth the length of tranche names (NAMEDATALEN-1 bytes) and thenumber of dynamically-allocated tranches (256). Besides a limit ofNAMEDATALEN-1 bytes for tranche names registered viaRequestNamedLWLockTranche(), no such limits previously existed. Wecould avoid these new limits by using dynamic shared memory, butthe complexity involved didn't seem worth it. We brieflyconsidered making the tranche limit user-configurable butultimately decided against that, too. Since there is still a lotof time left in the v19 development cycle, it's possible we willrevisit this choice.Author: Sami Imseih <samimseih@gmail.com>Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Rahila Syed <rahilasyed90@gmail.com>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/CAA5RZ0vvED3naph8My8Szv6DL4AxOVK3eTPS0qXsaKi%3DbVdW2A%40mail.gmail.com1 parent7b0fb9f commit38b602b
File tree
11 files changed
+130
-174
lines changed- contrib/pg_prewarm
- doc/src/sgml
- src
- backend
- postmaster
- storage
- ipc
- lmgr
- include/storage
- test/modules
- test_dsa
- test_dsm_registry
- test_radixtree
- test_slru
- test_tidstore
11 files changed
+130
-174
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
864 | 864 |
| |
865 | 865 |
| |
866 | 866 |
| |
867 |
| - | |
| 867 | + | |
868 | 868 |
| |
869 | 869 |
| |
870 | 870 |
| |
| |||
883 | 883 |
| |
884 | 884 |
| |
885 | 885 |
| |
886 |
| - | |
887 | 886 |
| |
888 | 887 |
| |
889 | 888 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3759 | 3759 |
| |
3760 | 3760 |
| |
3761 | 3761 |
| |
3762 |
| - | |
| 3762 | + | |
3763 | 3763 |
| |
3764 | 3764 |
| |
3765 | 3765 |
| |
| |||
3777 | 3777 |
| |
3778 | 3778 |
| |
3779 | 3779 |
| |
3780 |
| - | |
3781 |
| - | |
3782 |
| - | |
3783 |
| - | |
3784 |
| - | |
3785 |
| - | |
3786 |
| - | |
3787 |
| - | |
3788 |
| - | |
3789 |
| - | |
3790 |
| - | |
| 3780 | + | |
| 3781 | + | |
3791 | 3782 |
| |
3792 | 3783 |
| |
3793 | 3784 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 |
| - | |
| 104 | + | |
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| |||
761 | 761 |
| |
762 | 762 |
| |
763 | 763 |
| |
764 |
| - | |
| 764 | + | |
765 | 765 |
| |
766 | 766 |
| |
767 | 767 |
| |
| |||
1022 | 1022 |
| |
1023 | 1023 |
| |
1024 | 1024 |
| |
1025 |
| - | |
| 1025 | + | |
1026 | 1026 |
| |
1027 | 1027 |
| |
1028 | 1028 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
299 | 299 |
| |
300 | 300 |
| |
301 | 301 |
| |
302 |
| - | |
303 |
| - | |
| 302 | + | |
304 | 303 |
| |
305 | 304 |
| |
306 | 305 |
| |
| |||
321 | 320 |
| |
322 | 321 |
| |
323 | 322 |
| |
324 |
| - | |
325 |
| - | |
326 |
| - | |
327 | 323 |
| |
328 | 324 |
| |
329 | 325 |
| |
| |||
378 | 374 |
| |
379 | 375 |
| |
380 | 376 |
| |
381 |
| - | |
382 |
| - | |
| 377 | + | |
383 | 378 |
| |
384 | 379 |
| |
385 | 380 |
| |
| |||
409 | 404 |
| |
410 | 405 |
| |
411 | 406 |
| |
412 |
| - | |
413 |
| - | |
414 |
| - | |
415 | 407 |
| |
416 | 408 |
| |
417 | 409 |
| |
|
0 commit comments
Comments
(0)