Git Product home page Git Product logo

Comments (7)

txdv avatar txdv commented on May 22, 2024 1

DNS lookups can be implemented on top of the udp implementation of libuv and it will be completely scalable. If you rely on a lot of dns lookups, you should consider just using a C lib which implements a reasonable API for libuv to consume. An example is here http://25thandClement.com/~william/projects/libdns.git

However, when it comes to file IO, we need an OS mechanism to deal with it or we are left to use a thread pool with blocking calls. We are currently using a threadpool for linux and unix, because the default implementation is not sufficient enough. If we look at linux AIO, there is still some concern that deep down the operations are blocking, as in the current implementation is not yet non blocking, because nobody implemented it in the right way.

from libuv.

bminer avatar bminer commented on May 22, 2024

Alternatively, maybe file I/O and DNS lookups should be on separate thread pools? Or, DNS lookups should only use max. 3 of the 4 threads, leaving at least 1 for someone else?

As this guy aptly points out, using non-blocking file I/O over blocking file I/O doesn't really affect responsiveness. If the disk is running slow, your app is going to feel unresponsive. The problem here is mixing other I/O on the same thread pool.

Does that make sense? Thoughts?

from libuv.

bminer avatar bminer commented on May 22, 2024

@txdv - Node.js, for example, utilizes both C-Ares and getaddrinfo for DNS lookups. I (and the Node team) prefer the getaddrinfo route because it utilizes the OS resolver (and considers things like /etc/resolv.conf in Linux world). Deciding how to implement DNS is not the point here.

My point is that getaddrinfo is a blocking system call. So are file I/O operations. Therefore, we have the thread pool with blocking calls.

This brings me to my last comment... why not have separate thread pools? DNS/network and filesystem resources are two separate resources. Why not have their blocking I/O calls in separate thread pools? Or, perhaps, some hacky-hybrid solution of limiting the number of threads that a given resource-specific I/O request can use (i.e. getaddrinfo calls can only use up 2 of the 4 threads in the pool)?

I also agree that the alternatives (i.e. Linux AIO) are still concerning... and would require some significant work. What I propose about using separate thread pools should be relatively simple, right?

from libuv.

bminer avatar bminer commented on May 22, 2024

Maybe I should rename the title of this issue? :)

from libuv.

txdv avatar txdv commented on May 22, 2024

Having separate thread pools is already proposed:

#7

https://github.com/saghul/leps/blob/768747269f445f519ff75fd72f49f5661f29d5fb/XXX-threadpool-handle.md

Even lets you select in which thread pool you want to your specific request.

Furthermore, reading resolv.conf is not a hard part - glibc implements it simply ... by just reading it. There is no kernel level magic behind it.

But yeah, what you propose has already been thought through by @saghul

from libuv.

bminer avatar bminer commented on May 22, 2024

Glad to hear that it's already in the works... or at least that a proposal to fix the problem is in the works.

When will it land downstream in Node.js? (just kidding... sort of...)

from libuv.

saghul avatar saghul commented on May 22, 2024

Hi @bminer the threadpool has always been a bit of a problem. Your reasoning is sound, it's small and used for too many things. Some solutions were attempted in the past, but now I took a different approach in libuv/leps#4.

It's not yet final, but I hope we can land something following the model proposed there: have a handle which can do the work and push the responsibility to the user. I believe it's just not possible for us to cover all possible cases by trying to be smar in libuv, so we pass the burden to the user :-) You want a huge threadpool for file ops, fine! you want a different one for getaddrinfo / getnameinfo, cool too! So, I think everyone wins if we it right.

I'm going to close this, please join the discussion libuv/leps#4 if you have feedback on the proposal.

PS: Hopefully we also have a good story for serial devices sooner than later: #19

from libuv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.