Thread: partial header cleanup

partial header cleanup

From
Zdenek Kotala
Date:
This replace xlog.h with xlogdefs.h in bufpage.h. All other changes are
forgotten include somewhere. It reduce e.g. bloat to half in itup.h. But, There
are still unresolved problems. htup should include bufpage.h, because it needs
PageHeader size, but there is still unnecessary bufmgr.h include in bufpage
which generates bloat.

See itup.h bloating:

http://doxygen.postgresql.org/itup_8h.html

this patch reduce xlog side. But there still about 18 unnecessary includes.



        Zdenek

PS: Thanks to Stefan K. He enabled graphs.
Index: src/backend/nodes/print.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/nodes/print.c,v
retrieving revision 1.87
diff -c -r1.87 print.c
*** src/backend/nodes/print.c    1 Jan 2008 19:45:50 -0000    1.87
--- src/backend/nodes/print.c    30 May 2008 15:13:42 -0000
***************
*** 20,25 ****
--- 20,26 ----
  #include "postgres.h"

  #include "access/printtup.h"
+ #include "lib/stringinfo.h"
  #include "nodes/print.h"
  #include "optimizer/clauses.h"
  #include "parser/parsetree.h"
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.557
diff -c -r1.557 postmaster.c
*** src/backend/postmaster/postmaster.c    4 May 2008 21:13:35 -0000    1.557
--- src/backend/postmaster/postmaster.c    30 May 2008 15:13:42 -0000
***************
*** 93,98 ****
--- 93,99 ----
  #endif

  #include "access/transam.h"
+ #include "access/xlog.h"
  #include "bootstrap/bootstrap.h"
  #include "catalog/pg_control.h"
  #include "lib/dllist.h"
Index: src/backend/utils/adt/domains.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/domains.c,v
retrieving revision 1.6
diff -c -r1.6 domains.c
*** src/backend/utils/adt/domains.c    1 Jan 2008 19:45:52 -0000    1.6
--- src/backend/utils/adt/domains.c    30 May 2008 15:13:42 -0000
***************
*** 33,38 ****
--- 33,39 ----

  #include "commands/typecmds.h"
  #include "executor/executor.h"
+ #include "lib/stringinfo.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"

Index: src/backend/utils/fmgr/fmgr.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v
retrieving revision 1.119
diff -c -r1.119 fmgr.c
*** src/backend/utils/fmgr/fmgr.c    15 May 2008 00:17:40 -0000    1.119
--- src/backend/utils/fmgr/fmgr.c    30 May 2008 15:13:42 -0000
***************
*** 19,24 ****
--- 19,25 ----
  #include "catalog/pg_language.h"
  #include "catalog/pg_proc.h"
  #include "executor/functions.h"
+ #include "lib/stringinfo.h"
  #include "miscadmin.h"
  #include "parser/parse_expr.h"
  #include "pgstat.h"
Index: src/include/access/gin.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/gin.h,v
retrieving revision 1.20
diff -c -r1.20 gin.h
*** src/include/access/gin.h    16 May 2008 16:31:01 -0000    1.20
--- src/include/access/gin.h    30 May 2008 15:13:43 -0000
***************
*** 14,19 ****
--- 14,20 ----

  #include "access/itup.h"
  #include "access/relscan.h"
+ #include "access/xlog.h"
  #include "fmgr.h"
  #include "nodes/tidbitmap.h"
  #include "storage/block.h"
Index: src/include/access/heapam.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/heapam.h,v
retrieving revision 1.134
diff -c -r1.134 heapam.h
*** src/include/access/heapam.h    12 May 2008 00:00:53 -0000    1.134
--- src/include/access/heapam.h    30 May 2008 15:13:43 -0000
***************
*** 17,22 ****
--- 17,23 ----
  #include "access/htup.h"
  #include "access/relscan.h"
  #include "access/sdir.h"
+ #include "access/xlog.h"
  #include "nodes/primnodes.h"
  #include "storage/lock.h"
  #include "utils/snapshot.h"
Index: src/include/access/nbtree.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/nbtree.h,v
retrieving revision 1.118
diff -c -r1.118 nbtree.h
*** src/include/access/nbtree.h    16 Apr 2008 23:59:40 -0000    1.118
--- src/include/access/nbtree.h    30 May 2008 15:13:43 -0000
***************
*** 17,22 ****
--- 17,23 ----
  #include "access/itup.h"
  #include "access/relscan.h"
  #include "access/sdir.h"
+ #include "access/xlog.h"
  #include "access/xlogutils.h"


Index: src/include/storage/bufpage.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/storage/bufpage.h,v
retrieving revision 1.79
diff -c -r1.79 bufpage.h
*** src/include/storage/bufpage.h    12 May 2008 16:06:10 -0000    1.79
--- src/include/storage/bufpage.h    30 May 2008 15:13:43 -0000
***************
*** 14,20 ****
  #ifndef BUFPAGE_H
  #define BUFPAGE_H

! #include "access/xlog.h"
  #include "storage/bufmgr.h"
  #include "storage/item.h"
  #include "storage/off.h"
--- 14,20 ----
  #ifndef BUFPAGE_H
  #define BUFPAGE_H

! #include "access/xlogdefs.h"
  #include "storage/bufmgr.h"
  #include "storage/item.h"
  #include "storage/off.h"

Re: partial header cleanup

From
Alvaro Herrera
Date:
Zdenek Kotala wrote:
> This replace xlog.h with xlogdefs.h in bufpage.h. All other changes are
> forgotten include somewhere. It reduce e.g. bloat to half in itup.h. But,
> There are still unresolved problems. htup should include bufpage.h,
> because it needs PageHeader size, but there is still unnecessary bufmgr.h
> include in bufpage which generates bloat.

I agree with this patch -- in fact I had done the same before PGCon and
then neglected it for some reason.  (I think I was distracted trying to
get the struct RelationData definition out of rel.h, but that did not
turn out too well).

I was thinking maybe we need a third buffer manager header file.  One
would have the current bufmgr.h, another would have the page stuff that
does not know about bufmgr.h (so most of current bufpage.h), and the
third one would be both plus the #define that needs both (which is
currently in bufpage.h).  I am not sure what kind of fallout that
causes.  Maybe that would help you too.  We need to come up with a good
name for that file however ... bufmgrpage.h seems ugly.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: partial header cleanup

From
Zdenek Kotala
Date:
Alvaro Herrera napsal(a):
> Zdenek Kotala wrote:
>> This replace xlog.h with xlogdefs.h in bufpage.h. All other changes are
>> forgotten include somewhere. It reduce e.g. bloat to half in itup.h. But,
>> There are still unresolved problems. htup should include bufpage.h,
>> because it needs PageHeader size, but there is still unnecessary bufmgr.h
>> include in bufpage which generates bloat.
>
> I agree with this patch -- in fact I had done the same before PGCon and
> then neglected it for some reason.  (I think I was distracted trying to
> get the struct RelationData definition out of rel.h, but that did not
> turn out too well).

I think rel.h is atomic. There is no space to split it.

> I was thinking maybe we need a third buffer manager header file.  One
> would have the current bufmgr.h, another would have the page stuff that
> does not know about bufmgr.h (so most of current bufpage.h), and the
> third one would be both plus the #define that needs both (which is
> currently in bufpage.h).  I am not sure what kind of fallout that
> causes.  Maybe that would help you too.  We need to come up with a good
> name for that file however ... bufmgrpage.h seems ugly.

I don't think that we need third header file. It seems to me, that only macros
BufferGetPage requires both headers (Page and Buffer datatype). Other content
seems to me independent.

I'm thinking about renaming bufpage.h to page.h, but it is cosmetic change and
IIRC CVS does not like file renaming.

        Zdenek




Re: partial header cleanup

From
Alvaro Herrera
Date:
Zdenek Kotala wrote:
> This replace xlog.h with xlogdefs.h in bufpage.h.

Applied, thanks.




--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.