-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imp: try to fix too many files open error #797
Conversation
This comment has been minimized.
This comment has been minimized.
@gaoxinge ,Thank you for your careful review。 Why you use cas + busy waiting instead of a lock to protect the enque of a SPMC queue? I just want to use atomic instead lock, maybe there is no big difference in their performance with sleep. Why you choose the SPMC queue instead of MPMC queue? I'am not familiar with MPMC queue, i will read the code you provided in the comments. Why you use channel + queue instead of only one channel to implement connection pool? This is a good question. In my opinion, use signal channel it is ok, but there is such a scene,for example, maxSize is three, When the three tasks come, will create three new conns. Then task1 and task2 failed, task3 success. Now the value in chan should be nil, nil, conn. when new task come, it will create new connections although there have available conn.In other words, if we only use channel, the conn will not be reused before the channel is filled with conn . So in my code ,the queue used for store available conn, channel used to control the number of concurrent tasks. |
@wenxuwan Thank you for your answers. You have designd and implemented the connetion pool carefully and throughly, so I have no other questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about now? If no more questions, i will merge it to 1.4 and release it.
7232064
to
36f92db
Compare
Codecov Report
@@ Coverage Diff @@
## 1.4 #797 +/- ##
==========================================
- Coverage 67.10% 64.87% -2.24%
==========================================
Files 175 176 +1
Lines 9355 8054 -1301
==========================================
- Hits 6278 5225 -1053
+ Misses 2465 2235 -230
+ Partials 612 594 -18
Continue to review full report at Codecov.
|
Imp: try to fix too many files open error
When the amount of concurrency is high, a large number of tcp links will be created, resulting in a large number of time_awaits, resulting in too many files error, as shown in the figure below.
A maximum of 1024 files are allowed to open