Skip to content

Conversation

saper
Copy link

@saper saper commented Apr 16, 2015

This is a very quick'n'dirty
attempt to introduce more
explicit threadpools, as discussed
in libuv/leps#4
and #267

If more customization of the threadpool
is required (struct uv_threadpool_s)
can be expanded to include pointers
to functions doing the real work.

Names are ugly right now; C99 struct initialization
required.

@saper saper mentioned this pull request Apr 16, 2015
@saghul
Copy link
Member

saghul commented Apr 16, 2015

This is a very quick'n'dirty
attempt to introduce more
explicit threadpools, as discussed
in libuv/leps#4
and #267

Thanks for taking the time to write this! This is not exactly what I had in mind, because it's not a handle, but it did give an idea.

We could add the threadpool handle / customexecutor (to accomodate @bnoordhuis's use case with V8 workers) as a new handle, but keep using the current global threadpool for fs and dns operations in the v1.x branch. This new threadpool handle's implementation is very similar to the current one, but contained in a handle, and thus, not thread-safe. (right now there is a global lock because any loop can queue work in the one and only thread pool).

As a result, we'd "deprecate" uv_queue_work and encourage people to create their own pools and queue work there, in order to avoid starving the default one.

There would be some code "duplication" (not really duplication, but it would be very similar), but it would pave the work for explicitly requiring the pool for fd and dns requests in the future.

If more customization of the threadpool
is required (struct uv_threadpool_s)
can be expanded to include pointers
to functions doing the real work.

This needs to be thought out before the implementation, since v1.x is ABI stable.

Names are ugly right now; C99 struct initialization
required.

No can do, libuv is C89.

@saghul
Copy link
Member

saghul commented Apr 16, 2015

I'll sleep over it and amend the LEP with the new idea.

@saghul
Copy link
Member

saghul commented Sep 19, 2016

We had a "summit" where we planned out features for v2. This was discussed, and we decided to go with the approach roughly described in #267. @bnoordhuis will be writing a LEP on the matter.

Sorry this was kept open so long, and thanks for your willingness to help out.

@saghul saghul closed this Sep 19, 2016
@saper
Copy link
Author

saper commented Sep 21, 2016

@saghul thank you, this was just a sketch. I actually think now that introducing coroutines instead of thread pools will be much more powerful. I'll try to describe what I mean soon.

@davisjam davisjam mentioned this pull request Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants