Bug #74949 GIS performance issue: too many reallocs
Submitted: 21 Nov 2014 6:30 Modified: 26 Jan 2015 13:54
Reporter: Wei Zhao Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: CPU Architecture:Any

[21 Nov 2014 6:30] Wei Zhao
Description:
This is a performance issue.

Geometry data in practical use cases often are at least hundreds of bytes, so we should use more aggressive allocation increments i.e. this version
int String::reserve(size_t space_needed, size_t grow_by)

to reserve memory space.

This function is dedicated for GIS data, it allocates memory by bigger chunks, should be called by GIS code. Now when calling this function, we grow by 512 bytes normally, and only grow by smaller steps if we know for sure we are reaching the end of the geometry data.

We should not use the int reserve(size_t space_needed) version as some of the GIS code does currently, otherwise we would be reallocating multiple times incrementally for a single geometry when generating/producing the geometry data piece by piece, which is a lot of overhead.

How to repeat:
Run GIS tests.
[26 Jan 2015 13:54] Paul DuBois
Noted in 5.7.6 changelog.

Spatial functions now allocate memory in larger chunks to reduce
number of allocation calls and reduce overhead.