Replacing select() with epoll() in Mongoose?

324 views
Skip to first unread message

Jacky

unread,
Oct 6, 2010, 1:40:47 PM10/6/10
to mongoose-users, val...@gmail.com
Hi Mongoose Developers,

Thanks for bringing the C/C++ world such a great embed-able web
server!

I've encountered a performance review about Mongoose:
The blog post: http://hi.baidu.com/higkoo/blog/item/f2583266392e5329ab184c8f.html
more specific, the graph: http://hiphotos.baidu.com/higkoo/pic/item/e9cbbdc4f1291ff538db49b3.jpg

+------------------+---------------------+
| CPU performance | Memory performance |
|------------------+---------------------+
| Network flows | System avg-load |
+------------------+---------------------+

And it concludes that major back-side of Mongoose is using select
rather than epoll in the code, as the Line 3908 shows.

Therefore I'm very interested in that whether Mongoose has a plan to
replace select() with epoll() in the near future? It may have a
noticeable performance boost.

Best,
Jacky (jacky.chao.wang#gmail)

Sergey Lyubka

unread,
Oct 6, 2010, 3:35:21 PM10/6/10
to Jacky, mongoose-users
On Wed, Oct 6, 2010 at 6:40 PM, Jacky <jacky.c...@gmail.com> wrote:
Hi Mongoose Developers,

Thanks for bringing the C/C++ world such a great embed-able web
server!

I've encountered a performance review about Mongoose:
The blog post: http://hi.baidu.com/higkoo/blog/item/f2583266392e5329ab184c8f.html
more specific, the graph: http://hiphotos.baidu.com/higkoo/pic/item/e9cbbdc4f1291ff538db49b3.jpg

+------------------+---------------------+
| CPU performance  |  Memory performance |
|------------------+---------------------+
| Network flows    |  System avg-load    |
+------------------+---------------------+

And it concludes that major back-side of Mongoose is using select
rather than epoll in the code, as the Line 3908 shows.

I am not really convinced that using select() is the problem.
select() is slow when many file descriptors are checked for data. Usually listening sockets and all connected sockets are passed to select/epoll, and it could be many of those, if many clients are connected. Mongoose however is using select() for checking listening sockets only. Usually, there are few of them, and most of the time, only one (this is  set by -listening_ports parameter). If there are thousands listening sockets made, then yes, switching to epoll() would make sense, but I don't think anybody is doing this.
To make real performance boost on static content, Mongoose should use sendfile(2).

Sergey Lyubka

unread,
Oct 6, 2010, 4:41:10 PM10/6/10
to Jacky, mongoose-users
On Wed, Oct 6, 2010 at 8:35 PM, Sergey Lyubka <val...@gmail.com> wrote:


On Wed, Oct 6, 2010 at 6:40 PM, Jacky <jacky.c...@gmail.com> wrote:
Hi Mongoose Developers,

Thanks for bringing the C/C++ world such a great embed-able web
server!

I've encountered a performance review about Mongoose:
The blog post: http://hi.baidu.com/higkoo/blog/item/f2583266392e5329ab184c8f.html
more specific, the graph: http://hiphotos.baidu.com/higkoo/pic/item/e9cbbdc4f1291ff538db49b3.jpg

Unfortunately I can't read Chinese (and can't use automatic translation either).
It'd be nice to know the benchmark details.

Jacky

unread,
Oct 7, 2010, 12:31:13 AM10/7/10
to mongoose-users, val...@gmail.com
Hi Sergey,

Thanks for your prompt reply!

That's true. Most of the HTTP connections are short one so select may
not be the performance bottleneck. We have good reason to push back
the epoll implementation until mongoose is used to handle C10K
problems.

I've posted your response back to the user's blog with the link to
this thread. In that reply I'm very curious to see how he implements
the "mg_callback_t" function to handle static content.

I'll keep you posted.

Thanks,
Jacky

On Oct 7, 4:41 am, Sergey Lyubka <vale...@gmail.com> wrote:
> On Wed, Oct 6, 2010 at 8:35 PM, Sergey Lyubka <vale...@gmail.com> wrote:

Jacky

unread,
Oct 7, 2010, 10:00:37 PM10/7/10
to mongoose-users
According to line 2422: http://code.google.com/p/mongoose/source/browse/mongoose.c#2422

It seems like this function can use "sendfile" call to boost the
performance?

Sergey Lyubka

unread,
Oct 8, 2010, 5:54:43 AM10/8/10
to mongoos...@googlegroups.com
On Fri, Oct 8, 2010 at 3:00 AM, Jacky <jacky.c...@gmail.com> wrote:
According to line 2422: http://code.google.com/p/mongoose/source/browse/mongoose.c#2422

It seems like this function can use "sendfile" call to boost the
performance?

Correct.
 
--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To post to this group, send email to mongoos...@googlegroups.com.
To unsubscribe from this group, send email to mongoose-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongoose-users?hl=en.


Reply all
Reply to author
Forward
0 new messages