Comments (7)
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.
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.
@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.
Maybe I should rename the title of this issue? :)
from libuv.
Having separate thread pools is already proposed:
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.
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.
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)
- Mixed allocator usage with `realpath` HOT 2
- Test failure with 1.48.0 on OSX x86 HOT 10
- Bug in TCP keep-alive with unix socket
- MSVC compiler bug broke env_vars test in ASAN (x64 windows 2022+asan) HOT 4
- Additional Libuv Metrics HOT 2
- test: flaky fs_event_close_with_pending_event HOT 2
- _alloca Requested memory may have edge problems causing exceptions HOT 3
- multicast: The Android server(apk) doesn't always receive multicast messages from ubuntu.
- test,ci: flaky fs_event_error_reporting
- android: enable fdsan?
- Send udp broadcast to 255.255.255.255 cause permission denied error HOT 2
- macos: use absolute timeouts for condition variables HOT 1
- fs_event_watch_dir test fails on alpine 3.19 HOT 5
- System freeze after suspending two instances of Neovim HOT 5
- test: test-thread-priority.c fails on Linux HOT 5
- windows uv_poll_init
- doc: improve example docs/code/progress/main.c
- win: use WinDNS family of functions for DNS resolving HOT 4
- Improper Validation of Certificate Trust in certifi and dependent packages HOT 4
- 测试在Windows XP系统上运行时遇到RegGetValueW无法定位于ADVAPI32.dll的问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libuv.