[Postgres-xl-developers] GTM code cleanup / round 1

Tomas Vondra tomas.vondra at 2ndquadrant.com
Sun Oct 8 07:39:55 PDT 2017


Hi,

While investigating the GTM memory leak (on postgres-xl-general), I've
been struggling with some parts of the GMT code base - there's not much
description of the overall design, and functions are often somewhat
under-documented.

I've also repeatedly ran into functions that are effectively dead code
(not called from anywhere in the code base), or prototypes without any
implementation.

So I've looked into this last week, and here is my first batch of three
cleanup patches.

1) 0001-Cleanup-GTM-API-make-functions-static-remove-dead-co.patch

The first patch reduces the (public) GTM API as much possible. Functions
that don't need to be in header files are made static, prototypes
without implementation are removed just like unused #defines. Making the
function static also identified a number of unused functions (when the
functions were in .h file the compiler could not do that).

Overall this patch removes ~450 lines (although that's more a
consequence than a goal).

2) 0002-Improve-comments-in-gtm_txn.c-minor-naming-tweaks.patch

This patch significantly improves comments in gtm_txn.c. The new global
comment explains the basics of GTM Transaction management API - concepts
and main methods. It also improves the function comments, describing the
meaning of parameters and return values, and other important details.

3) 0003-Add-explanation-of-the-GTM-snapshot-API-to-gtm_snap..patch

The new global comment adds a brief GTM snapshot API description,
explaining the memory management approach in general.


I believe these changes to be rather non-controversial, as it does not
really change the behavior of anything. I'll push this in a few days,
unless there are objections.

I'd however appreciate opinions on accuracy of the comments. I've been
writing them based on my (possibly incomplete) understanding of the
code, so if you could read through the comments and let me know if I got
something wrong.

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Cleanup-GTM-API-make-functions-static-remove-dead-co.patch
Type: text/x-patch
Size: 40557 bytes
Desc: not available
URL: <http://lists.postgres-xl.org/pipermail/postgres-xl-developers-postgres-xl.org/attachments/20171008/59812928/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Improve-comments-in-gtm_txn.c-minor-naming-tweaks.patch
Type: text/x-patch
Size: 56475 bytes
Desc: not available
URL: <http://lists.postgres-xl.org/pipermail/postgres-xl-developers-postgres-xl.org/attachments/20171008/59812928/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-explanation-of-the-GTM-snapshot-API-to-gtm_snap..patch
Type: text/x-patch
Size: 5446 bytes
Desc: not available
URL: <http://lists.postgres-xl.org/pipermail/postgres-xl-developers-postgres-xl.org/attachments/20171008/59812928/attachment-0005.bin>


More information about the Postgres-xl-developers mailing list