-
Jon Olav Hauglid authored
STACK OVERFLOW IN PINBOX ALLOCATOR The problem was that the allocator used by the lock-free container implementations misused alloca() when scanning for objects which could be safely deallocated. The code tried to calculate how much memory could safely be allocated on the stack for qsort based pre-sort, but these calculations were not accurate. This could manifest itself as stack overflow errors with high number of concurrent connections to the server. (e.g. 8000 connections with default 256Kb stack size). This patch fixes the problem by removing the use of alloca and replacing qsort approach by a linear scan through all pointers (pins) owned by each thread. We remove each such pointer from the list of pointers to objects the current thread has marked as unused (purgatory). At the end we have a list of pointers to objects not in use by any thread. Since there are few active (non-null) pointers at any given time, this turns out to be quite efficent. The patch also fixes a bug in the code determining when scanning for unused objects should be performed. Instead of doing this scan only at certain intervals (for perf reasons), the old code did this scan almost always. Micro-benchmarks show that these two changes give a a clear performance improvement over the old approach. Some #include directives in the LF code was also changed so that they only use <> for system headers. This reduces the likelyhood of conflicts between system headers and MySQL headers with generic names (e.g. hash.h). The patch also reduces usage of thread-local storage and is a step towards implementing WL#6817. Based on patch written by Dmitry Lenev.
Jon Olav Hauglid authoredSTACK OVERFLOW IN PINBOX ALLOCATOR The problem was that the allocator used by the lock-free container implementations misused alloca() when scanning for objects which could be safely deallocated. The code tried to calculate how much memory could safely be allocated on the stack for qsort based pre-sort, but these calculations were not accurate. This could manifest itself as stack overflow errors with high number of concurrent connections to the server. (e.g. 8000 connections with default 256Kb stack size). This patch fixes the problem by removing the use of alloca and replacing qsort approach by a linear scan through all pointers (pins) owned by each thread. We remove each such pointer from the list of pointers to objects the current thread has marked as unused (purgatory). At the end we have a list of pointers to objects not in use by any thread. Since there are few active (non-null) pointers at any given time, this turns out to be quite efficent. The patch also fixes a bug in the code determining when scanning for unused objects should be performed. Instead of doing this scan only at certain intervals (for perf reasons), the old code did this scan almost always. Micro-benchmarks show that these two changes give a a clear performance improvement over the old approach. Some #include directives in the LF code was also changed so that they only use <> for system headers. This reduces the likelyhood of conflicts between system headers and MySQL headers with generic names (e.g. hash.h). The patch also reduces usage of thread-local storage and is a step towards implementing WL#6817. Based on patch written by Dmitry Lenev.
Loading