A lot of bots/tools I see posted here advertise multithreading support and even go as far to suggest that you can run it with 100s of threads and it'll make it run ungodly fast. This is not how computers work.
Your computer can only execute as many threads as you have CPU cores. That means if you have a quad-core processor, at most 4 threads can be executing at the same time. Using 100 threads will most likely slow down your application!
What happens is your operating systems scheduler is trying to balance all these threads that are asking for execution time. Since only X threads can run concurrently, it will pause active threads after they get a bit of execution time and awaken other threads that are waiting for their turn. Not only are you wasting a lot of time doing expensive context switches (suspending and resuming threads), an overwhelming majority of your unholy army of threads will spend most of their time waiting for the scheduler to put them in the game.
On top of all this, most bots are mostly doing network requests. That means they are I/O bound, not CPU bound. Throwing more threads at it simply isn't the solution. You should be creating a fixed amount of worker threads (around the same number as CPU cores) and using your platforms asynchronous I/O APIs. This way you can still make plenty of concurrent I/O requests (you don't need to wait for a previous one to finish before starting another one) without wasting system resources and time on context switching. Not to mention it's much, much, much more memory and CPU friendly.
The point of this rant being, buyers please, don't pay extra for "unlimited threads!!!!" (as I've seen in some listings).
And bot developers: Threads are for concurrently executing CPU-bound tasks (solving a captcha) or background work, use asynchronous I/O for I/O bound tasks (network stuff, reading/writing files, etc)
Your computer can only execute as many threads as you have CPU cores. That means if you have a quad-core processor, at most 4 threads can be executing at the same time. Using 100 threads will most likely slow down your application!
What happens is your operating systems scheduler is trying to balance all these threads that are asking for execution time. Since only X threads can run concurrently, it will pause active threads after they get a bit of execution time and awaken other threads that are waiting for their turn. Not only are you wasting a lot of time doing expensive context switches (suspending and resuming threads), an overwhelming majority of your unholy army of threads will spend most of their time waiting for the scheduler to put them in the game.
On top of all this, most bots are mostly doing network requests. That means they are I/O bound, not CPU bound. Throwing more threads at it simply isn't the solution. You should be creating a fixed amount of worker threads (around the same number as CPU cores) and using your platforms asynchronous I/O APIs. This way you can still make plenty of concurrent I/O requests (you don't need to wait for a previous one to finish before starting another one) without wasting system resources and time on context switching. Not to mention it's much, much, much more memory and CPU friendly.
The point of this rant being, buyers please, don't pay extra for "unlimited threads!!!!" (as I've seen in some listings).
And bot developers: Threads are for concurrently executing CPU-bound tasks (solving a captcha) or background work, use asynchronous I/O for I/O bound tasks (network stuff, reading/writing files, etc)