Discussion:
[Wt-interest] "ThreadPool in parent and child processes (dedicated mode)"
Aarón Bueno Villares
2016-09-16 03:36:37 UTC
Permalink
I don't know if that's intentional or not, but, at least in Wt 3.3.4, the
threadpool of the server and session processes are the same; the
WIOService's threadPool is set by WServer.C, using the corresponding
application option (from wt_config.xml).

If you specifies the num-threads as a command line option or in the wthttpd
config file, it overrides the one specified in wt_config.xml. If you don't
set the thread-count in the wt_config.xml, it takes 10 by default.

In any case, the threadPool is unique, no matter where you specify it.

In dedicated process mode, shouldn't be the thread pool different for the
main server and for each one of the session processes? Because on the
session processes is where user code lives.

For example, if I'm afraid about make my app multithreading, I could set
the thread-count = 0, but that makes the main server's thread-pool 0 as
well, lowering the server responsiveness.
Marco Kinski
2016-09-16 10:09:59 UTC
Permalink
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could set the
thread-count = 0, but that makes the main server's thread-pool 0 as well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.

regards, Marco

------------------------------------------------------------------------------
Aarón Bueno Villares
2016-09-18 05:15:06 UTC
Permalink
I finally did the following trick (only valid in dedicated process mode, of
course):

The wthttpd connector, when throwing a new process session, it launchs a
new instance of the program with the option --parent-port=X at the end, and
X being the port of the main server (as set in --http-port). The server
knows if it is the main process or a child process checking if parent-port
is set or not.

Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);

std::string arg(argv[argc - 1]);
auto* test = "--parent-port";

// If != 0, and thus, the option is not present (as last parameter).
if (arg.compare(0, strlen(test), test)) {
std::string thread_count;
server.readConfigurationProperty("thread-count", thread_count);
// I added it as <property> in my wt_config.xml
server.ioService().setThreadCount(std::stoi(thread_count));
}

After launching the server and a tab with the page loaded, I checked, with
pstree -a, how many threads I have in both the main and child processes,
and effectively, only the thread pool of the main process changed.

Before that trick, I tried to check if it is a parent or child process with
WServer::httpPort(), to see to which port is the server binded to, but
before running start(), the tcp endpoint of the parent process is not yet
set and it crashes (gdb output):

Program received signal SIGSEGV, Segmentation fault.
http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
249 endpoint_type local_endpoint(const implementation_type& impl,
(gdb) back
#0 http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
#1 0x0000000000484e55 in main (argc=11, argv=0x7fffffffe3d8) at main.cpp:25
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could set
the
thread-count = 0, but that makes the main server's thread-pool 0 as well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.
regards, Marco
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
Koen Deforche
2016-09-28 19:12:12 UTC
Permalink
Hey Aaron,

That sounds like a trick, but I wouldn't mind having a proper setting
'dispatcher-thread-pool' that's used only in dedicated process mode. If you
still care for it, can you file a feature request?

Regards,
koen
Post by Aarón Bueno Villares
I finally did the following trick (only valid in dedicated process mode,
The wthttpd connector, when throwing a new process session, it launchs a
new instance of the program with the option --parent-port=X at the end, and
X being the port of the main server (as set in --http-port). The server
knows if it is the main process or a child process checking if parent-port
is set or not.
Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
std::string arg(argv[argc - 1]);
auto* test = "--parent-port";
// If != 0, and thus, the option is not present (as last parameter).
if (arg.compare(0, strlen(test), test)) {
std::string thread_count;
server.readConfigurationProperty("thread-count", thread_count);
// I added it as <property> in my wt_config.xml
server.ioService().setThreadCount(std::stoi(thread_count));
}
After launching the server and a tab with the page loaded, I checked, with
pstree -a, how many threads I have in both the main and child processes,
and effectively, only the thread pool of the main process changed.
Before that trick, I tried to check if it is a parent or child process
with WServer::httpPort(), to see to which port is the server binded to, but
before running start(), the tcp endpoint of the parent process is not yet
Program received signal SIGSEGV, Segmentation fault.
http::server::Server::httpPort (this=0x0) at /usr/include/boost/asio/
socket_acceptor_service.hpp:249
249 endpoint_type local_endpoint(const implementation_type& impl,
(gdb) back
#0 http::server::Server::httpPort (this=0x0) at /usr/include/boost/asio/
socket_acceptor_service.hpp:249
#1 0x0000000000484e55 in main (argc=11, argv=0x7fffffffe3d8) at main.cpp:25
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could
set the
thread-count = 0, but that makes the main server's thread-pool 0 as
well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.
regards, Marco
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
Aarón Bueno Villares
2016-09-28 20:32:10 UTC
Permalink
And how can I do that?
Post by Koen Deforche
Hey Aaron,
That sounds like a trick, but I wouldn't mind having a proper setting
'dispatcher-thread-pool' that's used only in dedicated process mode. If you
still care for it, can you file a feature request?
Regards,
koen
Post by Aarón Bueno Villares
I finally did the following trick (only valid in dedicated process mode,
The wthttpd connector, when throwing a new process session, it launchs a
new instance of the program with the option --parent-port=X at the end, and
X being the port of the main server (as set in --http-port). The server
knows if it is the main process or a child process checking if parent-port
is set or not.
Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
std::string arg(argv[argc - 1]);
auto* test = "--parent-port";
// If != 0, and thus, the option is not present (as last parameter).
if (arg.compare(0, strlen(test), test)) {
std::string thread_count;
server.readConfigurationProperty("thread-count",
thread_count); // I added it as <property> in my wt_config.xml
server.ioService().setThreadCount(std::stoi(thread_count));
}
After launching the server and a tab with the page loaded, I checked,
with pstree -a, how many threads I have in both the main and child
processes, and effectively, only the thread pool of the main process
changed.
Before that trick, I tried to check if it is a parent or child process
with WServer::httpPort(), to see to which port is the server binded to, but
before running start(), the tcp endpoint of the parent process is not yet
Program received signal SIGSEGV, Segmentation fault.
http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
249 endpoint_type local_endpoint(const implementation_type& impl,
(gdb) back
#0 http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
#1 0x0000000000484e55 in main (argc=11, argv=0x7fffffffe3d8) at main.cpp:25
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could
set the
thread-count = 0, but that makes the main server's thread-pool 0 as
well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.
regards, Marco
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
Koen Deforche
2016-09-29 11:21:42 UTC
Permalink
Hey Aaron,

You can do that at http://redmine.emweb.be/projects/wt/issues

Regards,
koen
Post by Aarón Bueno Villares
And how can I do that?
Post by Koen Deforche
Hey Aaron,
That sounds like a trick, but I wouldn't mind having a proper setting
'dispatcher-thread-pool' that's used only in dedicated process mode. If you
still care for it, can you file a feature request?
Regards,
koen
Post by Aarón Bueno Villares
I finally did the following trick (only valid in dedicated process mode,
The wthttpd connector, when throwing a new process session, it launchs a
new instance of the program with the option --parent-port=X at the end, and
X being the port of the main server (as set in --http-port). The server
knows if it is the main process or a child process checking if parent-port
is set or not.
Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
std::string arg(argv[argc - 1]);
auto* test = "--parent-port";
// If != 0, and thus, the option is not present (as last parameter).
if (arg.compare(0, strlen(test), test)) {
std::string thread_count;
server.readConfigurationProperty("thread-count",
thread_count); // I added it as <property> in my wt_config.xml
server.ioService().setThreadCount(std::stoi(thread_count));
}
After launching the server and a tab with the page loaded, I checked,
with pstree -a, how many threads I have in both the main and child
processes, and effectively, only the thread pool of the main process
changed.
Before that trick, I tried to check if it is a parent or child process
with WServer::httpPort(), to see to which port is the server binded to, but
before running start(), the tcp endpoint of the parent process is not yet
Program received signal SIGSEGV, Segmentation fault.
http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
249 endpoint_type local_endpoint(const implementation_type& impl,
(gdb) back
#0 http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
#1 0x0000000000484e55 in main (argc=11, argv=0x7fffffffe3d8) at main.cpp:25
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could
set the
thread-count = 0, but that makes the main server's thread-pool 0 as
well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.
regards, Marco
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
Aarón Bueno Villares
2016-09-29 12:30:47 UTC
Permalink
Done, but, I've created it twice by mistake (due to the format ¬¬ and the
no possibility of edition... and the hope a request made by me could be
erased).
Post by Koen Deforche
Hey Aaron,
You can do that at http://redmine.emweb.be/projects/wt/issues
Regards,
koen
Post by Aarón Bueno Villares
And how can I do that?
Post by Koen Deforche
Hey Aaron,
That sounds like a trick, but I wouldn't mind having a proper setting
'dispatcher-thread-pool' that's used only in dedicated process mode. If you
still care for it, can you file a feature request?
Regards,
koen
Post by Aarón Bueno Villares
I finally did the following trick (only valid in dedicated process
The wthttpd connector, when throwing a new process session, it launchs
a new instance of the program with the option --parent-port=X at the end,
and X being the port of the main server (as set in --http-port). The server
knows if it is the main process or a child process checking if parent-port
is set or not.
Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
std::string arg(argv[argc - 1]);
auto* test = "--parent-port";
// If != 0, and thus, the option is not present (as last parameter).
if (arg.compare(0, strlen(test), test)) {
std::string thread_count;
server.readConfigurationProperty("thread-count",
thread_count); // I added it as <property> in my wt_config.xml
server.ioService().setThreadCount(std::stoi(thread_count));
}
After launching the server and a tab with the page loaded, I checked,
with pstree -a, how many threads I have in both the main and child
processes, and effectively, only the thread pool of the main process
changed.
Before that trick, I tried to check if it is a parent or child process
with WServer::httpPort(), to see to which port is the server binded to, but
before running start(), the tcp endpoint of the parent process is not yet
Program received signal SIGSEGV, Segmentation fault.
http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
249 endpoint_type local_endpoint(const implementation_type& impl,
(gdb) back
#0 http::server::Server::httpPort (this=0x0) at
/usr/include/boost/asio/socket_acceptor_service.hpp:249
#1 0x0000000000484e55 in main (argc=11, argv=0x7fffffffe3d8) at main.cpp:25
Hi Aarón,
[snip]
For example, if I'm afraid about make my app multithreading, I could
set the
thread-count = 0, but that makes the main server's thread-pool 0 as
well,
lowering the server responsiveness.
inside wcoonfig.h is a build option to enable/disable mt-support
(#cmakedefine WT_THREADED).
I never tried it, but it sounds like what your looking for.
regards, Marco
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------
------------------
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
Loading...