[postgis-tickets] [PostGIS] #4368: Reorder struct layouts to minimize padding
PostGIS
trac at osgeo.org
Mon Apr 22 04:44:19 PDT 2019
#4368: Reorder struct layouts to minimize padding
--------------------------+---------------------------
Reporter: Algunenano | Owner: Algunenano
Type: enhancement | Status: assigned
Priority: medium | Milestone: PostGIS 3.0.0
Component: postgis | Version: trunk
Resolution: | Keywords:
--------------------------+---------------------------
Comment (by Algunenano):
With Komzpa's idea, I decided to hack both ST_Subdivide and ST_Collect to
print memory stats and test what was the impact using the bigpolygon
table:
{{{
diff --git a/postgis/lwgeom_accum.c b/postgis/lwgeom_accum.c
index db7ccd3fe..1d9c5844e 100644
--- a/postgis/lwgeom_accum.c
+++ b/postgis/lwgeom_accum.c
@@ -240,6 +240,7 @@ pgis_geometry_collect_finalfn(PG_FUNCTION_ARGS)
geometry_array = pgis_accum_finalfn(p, CurrentMemoryContext, fcinfo);
result = PGISDirectFunctionCall1( LWGEOM_collect_garray,
geometry_array );
+ MemoryContextStats(CurrentMemoryContext);
if (!result)
PG_RETURN_NULL();
diff --git a/postgis/lwgeom_dump.c b/postgis/lwgeom_dump.c
index 133a2d7d0..92789c675 100644
--- a/postgis/lwgeom_dump.c
+++ b/postgis/lwgeom_dump.c
@@ -400,6 +400,7 @@ Datum ST_Subdivide(PG_FUNCTION_ARGS)
else
{
/* do when there is no more left */
+ MemoryContextStats(funcctx->multi_call_memory_ctx);
SRF_RETURN_DONE(funcctx);
}
}
}}}
SQL: `Select ST_Collect(geom) from ( select ST_Subdivide(geom) As geom
FROM big_polygon ) _a;`
* Before changes:
ST_Subdivide:
{{{
multi-call context: 11795280 total in 1722 blocks; 3172560 free (9560
chunks); 8622720 used
total: 11795280 bytes in 1722 blocks; 3172560 free (9560 chunks); 8622720
used
}}}
ST_Collect:
{{{
8069592 total in 11 blocks; 494824 free (2 chunks); 7574768 used
total: 8069592 bytes in 11 blocks; 494824 free (2 chunks); 7574768 used
}}}
* After changes:
Subdivide uses 2 blocks less (1710/1712). ~1% less total bytes used:
{{{
multi-call context: 11696976 total in 1710 blocks; 3134384 free (8883
chunks); 8562592 used
total: 11696976 bytes in 1710 blocks; 3134384 free (8883 chunks); 8562592
used
}}}
ST_Collect uses 1 block less (10 vs 11). ~6.5% less total bytes used:
{{{
7545304 total in 10 blocks; 30032 free (2 chunks); 7515272 used
total: 7545304 bytes in 10 blocks; 30032 free (2 chunks); 7515272 used
}}}
I don't see any measurable impact in performance in my machine
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4368#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list