Impact of hundreds of idle threads

Asked
Active3 hr before
Viewed126 times

7 Answers

hundredsimpact
90%

But then, other issues have to be accounted for. Having 100s of threads waiting will likely increase memory usage on the kernel, due to the need of wait queues or other similar resources. There's also a latency issue, which looks non-deterministic. To check the responsiveness and memory usage of each solution one should measure it and compare.,I am considering the use of potentially hundreds of threads to implement tasks that manage devices over a network. ,If you have a 32-bit processor, address space will be the main limitation once you hit 1000s of threads, you can easily exhaust the AS.,EboMike has already answered the question directly - provided threads are blocked and not busy-waiting then they won't consume much in the way of resources although they will occupy memory and swap for all the per-thread state.

I would be worried about offering 1:1 thread-connections mappings, if nothing else because it leaves you rather exposed to denial of service attacks. (pthread_create() is a fairly expensive operation compared to just a call to accept())

pthread_create()
load more v
88%

This is a C++ application running on a powerpc processor with a linux kernel.,After an initial phase when each task does synchronization to copy data from the device into the task, the task becomes idle, and only wakes up when it receives an alarm, or needs to change some data (configuration), which is rare after the start phase. Once all tasks reach the "idle" phase, I expect that only a few per second will need to wake.,I also assume that you will need to do some object sharing an synchronization. In this case, your code may get slower because of the need to wake up all processes waiting on a resource, as I mentioned earlier.,I am considering the use of potentially hundreds of threads to implement tasks that manage devices over a network.

Answer #3:

I would be worried about offering 1:1 thread-connections mappings, if nothing else because it leaves you rather exposed to denial of service attacks. (pthread_create() is a fairly expensive operation compared to just a call to accept())

pthread_create()
load more v
72%

So, my main concern is, if I have hundreds of threads will they have a negative impact on the system once they become idle?,I am considering the use of potentially hundreds of threads to implement tasks that manage devices over a network. ,But then, other issues have to be accounted for. Having 100s of threads waiting will likely increase memory usage on the kernel, due to the need of wait queues or other similar resources. There's also a latency issue, which looks non-deterministic. To check the responsiveness and memory usage of each solution one should measure it and compare.,If you find copyright violations, you can contact us at info-generacodice.com to request the removal of the content.

??????1:1??????,??????,???????????????? (pthread_create()?????accept()??????????)

pthread_create()
load more v
65%

Leave the connections in idle state.,The pgbench run with the custom script and without any idle connections shows the following result:,The post also shows that PostgreSQL connections consume resources even when they’re idle, so the common assumption that idle connections don’t have any performance impact is not correct.,The first post of this series, Resources consumed by idle PostgreSQL connections, talked about how PostgreSQL manages connections and how even idle connections consume memory and CPU. In this post, I discuss how idle connections impact PostgreSQL performance.

SELECT table_schema || '.' || table_name as relname from information_schema.tables WHERE table_schema = 'information_schema';
load more v
75%

Thread pool is a core concept in multithreaded programming which, simply put, represents a collection of idle threads that can be used to execute tasks.,In this manner, the thread pool is preconfigured for the most common cases. The number of threads can be controlled by setting the parameters:,A thread is an execution context that can run a set of instructions within a process – aka a running program. Multithreaded programming refers to using threads to execute multiple tasks concurrently. Of course, this paradigm is well supported on the JVM.,Java provides its own implementations of the thread pool pattern, through objects called executors. These can be used through executor interfaces or directly through thread pool implementations – which does allow for finer-grained control.

Let’s use these two classes in conjunction with an example that creates a single-thread pool, then uses it to execute a simple statement:

Executor executor = Executors.newSingleThreadExecutor();
executor.execute(() - > System.out.println("Single thread pool test"));
load more v
40%

A thread is a basic unit of CPU utilization, consisting of a program counter, a stack, and a set of registers, ( and a thread ID. ) ,As multi-threading becomes more pervasive and more important ( thousands instead of tens of threads ), CPUs have been developed to support more simultaneous threads per core in hardware.,Task parallelism divides the different tasks to be performed among the different cores and performs them simultaneously.,Q: When a multi-threaded process receives a signal, to what thread should that signal be delivered?

      #pragma omp parallel {
         /* some parallel code here */
      }
22%

It would be interesting in making this test on MariaDB with threadpoll based connection handling (event based)…,@Yves, connections are not multiplexed inside normal mysql, i.e there is no select() or poll() that would be waiting for activity on some connections, instead server thread is stuck in recv() call, as long as client is idle. ,Great find ! It was for long well known the active connections significantly limit performance but it is good to have a data idle connections are not free ether., Raine It would be interesting in making this test on MariaDB with threadpoll based connection handling (event based)… December 17, 2010 at 2:46 pm

As Vladislav Vaintroub said, you are testing a debug-compiled server with safemalloc enabled. This totally kills performance, as it uses a really expensive memory sanity check that has quadratic cost in the number of active malloc() allocations.

(Note that a “debug build” in MySQL is much more than just gcc -g, it enables lots of extra testing code that is very costly for performance, safemalloc is only one of them (but a particularly expensive one).

gcc - g

Other "hundreds-impact" queries related to "Impact of hundreds of idle threads"