[Maria-developers] MariaDB 10.4 on AIX. Issue with: HAVE_POOL_OF_THREADS
![](https://secure.gravatar.com/avatar/02228e920929e124bf7736a5e3cdff24.jpg?s=120&d=mm&r=g)
Hi,
In my environment (AIX & MariaDB v10.4.3 or 10.4.4), I have an issue with HAVE_POOL_OF_THREADS.
When building, I have the following trace and error (full line of g++ compilation at end of email) :
[ 44%] Linking CXX executable explain_filename-t
/opt/freeware/bin/cmake -E cmake_link_script CMakeFiles/explain_filename-t.dir/link.txt --verbose=1
/opt/freeware/bin/g++ ........... -o explain_filename-t ....
ld: 0711-317 ERROR: Undefined symbol: .TP_pool_generic::TP_pool_generic()
ld: 0711-317 ERROR: Undefined symbol: .TP_pool_generic::init()
This seems to be due to the following lines of the file:
sql/CMakeLists.txt :
IF (CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "Windows" OR
CMAKE_SYSTEM_NAME MATCHES "SunOS" OR
HAVE_KQUEUE)
ADD_DEFINITIONS(-DHAVE_POOL_OF_THREADS)
IF(WIN32)
SET(SQL_SOURCE ${SQL_SOURCE} threadpool_win.cc)
ENDIF()
SET(SQL_SOURCE ${SQL_SOURCE} threadpool_generic.cc)
ENDIF()
In case the Operating System is not Linux, Windows, or SunOS, then there is NO -DHAVE_POOL_OF_THREADS and the file: threadpool_generic.cc is NOT compiled.
However, the C++ code of MariaDB still looks at least for 2 routines of threadpool_generic.cc :
TP_pool_generic::TP_pool_generic()
TP_pool_generic::init()
but these routines are not available since threadpool_generic.cc was not compiled.
So, in my opinion, there are some #ifdef HAVE_POOL_OF_THREADS lines that are missing in common threadpool code that would prevent to use threadpool generic routines.
However, I do not master this code.
Why not implement on AIX the generic pool of thread and thus add AIX to the above IF( ) test of sql/CMakeLists.txt ??
The reason if that, out of the 4 possibilities listed in sql/threadpool_generic.cc : epoll, KQUEUE, port, and IOCP, none of them are available on AIX with the EXACT required behavior. We have to implement something miming epoll(), we think. Before fixing this performance improvement, we'd like to be able to build & test MariaDB for all its other features.
sql/threadpool_generic.cc :
#ifdef __linux__
#include
![](https://secure.gravatar.com/avatar/894faf5db658166b45527a9136dc970c.jpg?s=120&d=mm&r=g)
Hi Tony,
I fixed this in https://jira.mariadb.org/browse/MDEV-19274 .
I do not think it makes a lot of sense to implement generic, poll()-based threadpool . epoll-like APIs exists almost everywhere, except very exotic (for MariaDB) platforms we do not build on.
I googled, and I found that AIX has Windows-like IOCP with GetQueuedCompletionStatus/CreateIoCompletionPort etc. Maybe, it does not behave exactly like on Windows, but perhaps you can figure out what’s the difference and what is required to port that code.
Regards,
Wlad
From: REIX, Tonymailto:tony.reix@atos.net
Sent: Tuesday, 16 April 2019 11:26
To: maria-developers@lists.launchpad.netmailto:maria-developers@lists.launchpad.net
Subject: [Maria-developers] MariaDB 10.4 on AIX. Issue with: HAVE_POOL_OF_THREADS
Hi,
In my environment (AIX & MariaDB v10.4.3 or 10.4.4), I have an issue with HAVE_POOL_OF_THREADS.
When building, I have the following trace and error (full line of g++ compilation at end of email) :
[ 44%] Linking CXX executable explain_filename-t
/opt/freeware/bin/cmake -E cmake_link_script CMakeFiles/explain_filename-t.dir/link.txt --verbose=1
/opt/freeware/bin/g++ ........... -o explain_filename-t ....
ld: 0711-317 ERROR: Undefined symbol: .TP_pool_generic::TP_pool_generic()
ld: 0711-317 ERROR: Undefined symbol: .TP_pool_generic::init()
This seems to be due to the following lines of the file:
sql/CMakeLists.txt :
IF (CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "Windows" OR
CMAKE_SYSTEM_NAME MATCHES "SunOS" OR
HAVE_KQUEUE)
ADD_DEFINITIONS(-DHAVE_POOL_OF_THREADS)
IF(WIN32)
SET(SQL_SOURCE ${SQL_SOURCE} threadpool_win.cc)
ENDIF()
SET(SQL_SOURCE ${SQL_SOURCE} threadpool_generic.cc)
ENDIF()
In case the Operating System is not Linux, Windows, or SunOS, then there is NO -DHAVE_POOL_OF_THREADS and the file: threadpool_generic.cc is NOT compiled.
However, the C++ code of MariaDB still looks at least for 2 routines of threadpool_generic.cc :
TP_pool_generic::TP_pool_generic()
TP_pool_generic::init()
but these routines are not available since threadpool_generic.cc was not compiled.
So, in my opinion, there are some #ifdef HAVE_POOL_OF_THREADS lines that are missing in common threadpool code that would prevent to use threadpool generic routines.
However, I do not master this code.
Why not implement on AIX the generic pool of thread and thus add AIX to the above IF( ) test of sql/CMakeLists.txt ??
The reason if that, out of the 4 possibilities listed in sql/threadpool_generic.cc : epoll, KQUEUE, port, and IOCP, none of them are available on AIX with the EXACT required behavior. We have to implement something miming epoll(), we think. Before fixing this performance improvement, we'd like to be able to build & test MariaDB for all its other features.
sql/threadpool_generic.cc :
#ifdef __linux__
#include
![](https://secure.gravatar.com/avatar/02228e920929e124bf7736a5e3cdff24.jpg?s=120&d=mm&r=g)
Hi Wlad,
Thanks for fixing this issue. :-)
About thread-pool, the implementation of IOCP on AIX has limitations. That works ONLY with Asynchronous I/O (AIO).
On AIX, we have the pollset API. Within our port of Go on AIX, we did not use pollset since Go wants netpoll to be edge-triggered (epoll with EPOLLET flag) and not level-triggered. However, this is very unefficient to implement edge-triggerered behavior with pollset (one has to continuously modify the pollset, destroying the performance).
So, we have to understand if MariaDB requires edge-triggered or level-triggered. Do you know?
Thanks/Regards,
Cordialement,
Tony Reix
tony.reix@atos.net
ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.nethttps://mail.ad.bull.net/owa/redir.aspx?C=PvphmPvCZkGrAgHVnWGsdMcDKgzl_dEIsM6rX0g4u4v8V81YffzBGkWrtQeAXNovd3ttkJL8JIc.&URL=http%3a%2f%2fwww.atos.net%2f
________________________________
De : Vladislav Vaintroub
![](https://secure.gravatar.com/avatar/894faf5db658166b45527a9136dc970c.jpg?s=120&d=mm&r=g)
Hi Tony,
MariaDB uses EPOLLETT| EPOLLONESHOT on Linux.
By now, I forgot which EPOLLXXX flag does what exactly.
The intention is to remove the socket from the “pollset” once we determine there is some data to read. Then server executes query, and after that threadpool puts socket back to pollset. The reason to remove socket from pollset is that we want to prevent multiple worker threads handling the same connection at the same time.
Also, when query is finished, and we add the socket back to the set, and there is already some new data in the socket (e.g new query), threadpool wants to be informed about this fact.
This way it works on all platforms in sql/threadpool_generic.cc, and the flags on Linux were chosen to satisfy the above conditions.
________________________________
From: REIX, Tony
![](https://secure.gravatar.com/avatar/894faf5db658166b45527a9136dc970c.jpg?s=120&d=mm&r=g)
Addition to the previous comment : we want exactly the behaviour that is described in this answer
https://stackoverflow.com/a/46142976/547065 , under “Level-triggered EPOLLONESHOT”
thus we use the EPOLL flags that we use.
As original author remarks, on Linux, the socket is not physically removed from set after one-shot. Just event notification is disabled, until reenabled again, with epoll_ctl / EPOLL_CTL_MOD . This should be a really fast syscall, because it does almost nothing.
From: Vladislav Vaintroubmailto:vvaintroub@gmail.com
Sent: Thursday, 18 April 2019 19:19
To: REIX, Tonymailto:tony.reix@atos.net; maria-developers@lists.launchpad.netmailto:maria-developers@lists.launchpad.net
Cc: GUESNET, ETIENNE (ext)mailto:etienne.guesnet.external@atos.net
Subject: RE: [Maria-developers] MariaDB 10.4 on AIX. Issue with: HAVE_POOL_OF_THREADS
Hi Tony,
MariaDB uses EPOLLETT| EPOLLONESHOT on Linux.
By now, I forgot which EPOLLXXX flag does what exactly.
The intention is to remove the socket from the “pollset” once we determine there is some data to read. Then server executes query, and after that threadpool puts socket back to pollset. The reason to remove socket from pollset is that we want to prevent multiple worker threads handling the same connection at the same time.
Also, when query is finished, and we add the socket back to the set, and there is already some new data in the socket (e.g new query), threadpool wants to be informed about this fact.
This way it works on all platforms in sql/threadpool_generic.cc, and the flags on Linux were chosen to satisfy the above conditions.
From: REIX, Tony
participants (2)
-
REIX, Tony
-
Vladislav Vaintroub