Change xl_hash_vacuum_one_page.ntuples from int to uint16

Поиск
Список
Период
Сортировка
От Drouvot, Bertrand
Тема Change xl_hash_vacuum_one_page.ntuples from int to uint16
Дата
Msg-id b0e20c40-cb7a-fc1c-c607-2a78dac5021e@gmail.com
обсуждение исходный текст
Ответы Re: Change xl_hash_vacuum_one_page.ntuples from int to uint16  (Nathan Bossart <nathandbossart@gmail.com>)
Список pgsql-hackers
Hi hackers,

While working on [1], I noticed that xl_hash_vacuum_one_page.ntuples is an int.

Unless I'm missing something, It seems to me that it would make more sense to use an uint16 (like this is done for
gistxlogDelete.ntodelete for example).

Please find attached a patch proposal to do so.

While that does not currently change the struct size:

No patch:

(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset      |    size */  type = struct xl_hash_vacuum_one_page {
/*      0      |       4 */    TransactionId snapshotConflictHorizon;
/*      4      |       4 */    int ntuples;

                                /* total size (bytes):    8 */
                              }
With patch:

(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset      |    size */  type = struct xl_hash_vacuum_one_page {
/*      0      |       4 */    TransactionId snapshotConflictHorizon;
/*      4      |       2 */    uint16 ntuples;
/* XXX  2-byte padding   */

                                /* total size (bytes):    8 */
                              }

It could reduce it when adding new fields (like this is is done in [1]).

We would get:

No patch:

(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset      |    size */  type = struct xl_hash_vacuum_one_page {
/*      0      |       4 */    TransactionId snapshotConflictHorizon;
/*      4      |       4 */    int ntuples;
/*      8      |       1 */    _Bool isCatalogRel;
/* XXX  3-byte padding   */

                                /* total size (bytes):   12 */
                              }

With patch:

(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset      |    size */  type = struct xl_hash_vacuum_one_page {
/*      0      |       4 */    TransactionId snapshotConflictHorizon;
/*      4      |       2 */    uint16 ntuples;
/*      6      |       1 */    _Bool isCatalogRel;
/* XXX  1-byte padding   */

                                /* total size (bytes):    8 */
                              }

Means saving 4 bytes in that case.

Looking forward to your feedback,

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Collation version tracking for macOS
Следующее
От: Dean Rasheed
Дата:
Сообщение: Re: Add proper planner support for ORDER BY / DISTINCT aggregates