Increase of padding in data structures, at least 25% reserved space for both 32-bit...
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 15 Oct 2012 16:58:30 +0000 (16:58 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 15 Oct 2012 16:58:30 +0000 (16:58 +0000)
org.glite.lb.common/Makefile
org.glite.lb.common/interface/context-int.h
org.glite.lb.common/interface/events.h.T
org.glite.lb.common/test/padding.c [new file with mode: 0644]

index 8c9cfca..b0db5ad 100644 (file)
@@ -34,7 +34,7 @@ SOURCES=\
        m4/*.m4 \
        project/.post* \
        src/*.c src/*.c.T src/*.sh \
-       test/*.cpp test/*.cpp.T \
+       test/*.c test/*.cpp test/*.cpp.T \
        LICENSE Makefile
 SOURCES_EXEC=src/*.sh
 
@@ -222,6 +222,9 @@ test_coverage:
        cd coverage && $(MAKE) -f ../Makefile top_srcdir=../../ COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage" check
        cd coverage && for i in ${OBJS}; do gcov -o .libs/ $$i ; done
 
+padding: padding.o
+       ${LINK} $< -o $@
+
 cjobid.c strmd5.c:
        if [ ! -d ${jobiddir} ]; then echo "Directory ${jobiddir} not found"; exit 1; fi
        mkdir -p glite/jobid
@@ -257,7 +260,8 @@ install:
        ${STAGE_PERFTEST} ;
 
 clean:
-       rm -rvf *.o *.lo .libs lib* *.c *.h *.dox C/ CPP/ test_parse il_test parse.cpp events.tex status.tex test_query_rec
+       rm -rvf *.o *.lo .libs lib* *.c *.h *.dox C/ CPP/
+       rm -fv test_parse il_test parse.cpp events.tex status.tex test_query_rec padding
        rm -rvf ${REPORTS}
        rm -rvf dist ${package}-*.tar.gz
 
index 7d1b5ed..7484812 100644 (file)
@@ -73,7 +73,7 @@ typedef struct _edg_wll_ConnProxy  edg_wll_ConnProxy;
 
 
 /* !!! if adding something malloc-able, update edg_wll_FreeContext too !!! */
-glite_lb_padded_struct(_edg_wll_Context,150,
+glite_lb_padded_struct(_edg_wll_Context,200,
 /// XXX: branch value: glite_lb_padded_struct(_edg_wll_Context,120,
 /* Error handling */
        int             errCode;        /* recent error code */
index c3cb1e6..37642b8 100644 (file)
@@ -380,7 +380,7 @@ _EDG_WLL_EVENT_COMMON
  * \union edg_wll_Event
  * \brief All event types union
  */
-glite_lb_padded_union(_edg_wll_Event,30,
+glite_lb_padded_union(_edg_wll_Event,32,
         edg_wll_EventCode           type; /* it is probably never used */
         edg_wll_AnyEvent            any;
 @@@{
diff --git a/org.glite.lb.common/test/padding.c b/org.glite.lb.common/test/padding.c
new file mode 100644 (file)
index 0000000..57ee8d1
--- /dev/null
@@ -0,0 +1,39 @@
+#define CC /*
+gcc -W -Wall -g -O2 padding.c -o padding -I../../stage/usr/include
+exit $?
+*/
+
+/*
+ * quick analysis of padding usage
+ */
+
+#include <stdio.h>
+
+#include "glite/lb/connpool.h"
+#include "glite/lb/context-int.h"
+#include "glite/lb/events.h"
+#include "glite/lb/lb_plain_io.h"
+
+
+void out(const char *name, size_t size, size_t padding) {
+       printf("%s:\n", name);
+       printf("        sizeof %lu      padding %lu     padno %d        use %0.02f %%\n", size, padding, size/(sizeof(void *)), (double)(size - padding)/size*100);
+       printf("\n");
+}
+
+
+int main() {
+       struct _edg_wll_ConnPool connpool;
+       struct _edg_wll_ConnProxy connproxy;
+       struct _edg_wll_Context context;
+       union _edg_wll_Event event;
+       struct _edg_wll_PlainConnection plainconnection;
+
+       out("struct _edg_wll_ConnPool", sizeof(connpool), sizeof(connpool._padding));
+       out("struct _edg_wll_ConnProxy", sizeof(connproxy),  sizeof(connproxy._padding));
+       out("struct _edg_wll_Context", sizeof(context), sizeof(context._padding));
+       out("union _edg_wll_Event", sizeof(event), sizeof(event._pad) - sizeof(union _edg_wll_Event_to_pad__dont_use));
+       out("struct _edg_wll_PlainConnection", sizeof(plainconnection), sizeof(plainconnection._padding));
+
+       return 0;
+}