DLTcollab / dcurl

Hardware-accelerated Multi-threaded IOTA PoW, drop-in replacement for ccurl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow dcurl to affect the thread pool size of libtuv

marktwtn opened this issue · comments

There are two methods to set the thread pool size of libtuv:

  1. Change the default size(=4) in the libtuv source code.
  2. Use the environment variable UV_THREADPOOL_SIZE to overwrite the default size.

Based on the previous advice of method 1 pull request:

I dislike such modifications. The default value is valid for libtuv's motivation and purpose on IoT devices. We can refer to runtime configurations in order to calibrate CPU resources. Also, consider the case when HyperThreading is enabled.

Objective:
Offer other acceptable methods to set the thread pool size and apply it to the current design.

You might learn from xmrig by searching affinity.

I would like to add a new function in the src/threadpool.c of libtuv.
The new function is mainly for setting the thread pool size with the passed in function argument.
And it will be called by the dcurl_entry() function in src/dcurl.c of dcurl.

I would like to add a new function in the src/threadpool.c of libtuv.
The new function is mainly for setting the thread pool size with the passed in function argument.
And it will be called by the dcurl_entry() function in src/dcurl.c of dcurl.

Continue from the last comment.
If the new function is implemented, then there will be two functions which can set the threadpool size.

  • uv_queue_work(): Set with the default size or environment variable.
  • new_function(int poolSize): Set with the passed in argument.

The function which is called first is important.

If we continue this way, it might have some concern.
For example, if tangle-accelerator, some dcurl test case or the other part of the source code also uses the libtuv APIs and call the uv_queue_work() first, then there might have some problem.
The threadpool size would not be the same as you expected if you wish to use the new_function(int poolSize) to set it.

I create a new API uv_set_threadpool_size() to preset the threadpool size of libtuv.

The size presetting happens in dcurl_init(),
and the real threadpool initialization would happen in the first call of the dcurl_entry().

Since we assign the thread number to be used for PoW when calling the dcurl_entry(),
the preset size is set to (max acceptable thread number of the hardware - 1), which can satisfy any requested thread number of dcurl_entry().