Skip to content
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

"libevent" migrate to "libev" or "libuv" engine #2047

Closed
denji opened this issue Mar 13, 2014 · 12 comments
Closed

"libevent" migrate to "libev" or "libuv" engine #2047

denji opened this issue Mar 13, 2014 · 12 comments

Comments

@denji
Copy link
Contributor

denji commented Mar 13, 2014

Boost network performance libev. libevent have overhead initialization start
http://software.schmorp.de/pkg/libev.html

Appendix: Benchmark graphs for libev 4.03, libevent 1.4.13, libevent 2.0.10

Libev (first released in 2007-11-12) is also a high-performance event loop, supporting eight event types (I/O, real time timers, wall clock timers, signals, child status changes, idle, check and prepare handlers).

It uses a priority queue to manage timers and uses arrays as fundamental data structure. It has no artificial limitations on the number of watchers waiting for the same event. It offers an emulation layer for libevent and optionally the same DNS, HTTP and buffer management (by reusing the corresponding libevent code through its emulation layer).

Download: http://dist.schmorp.de/libev/Attic/libev-4.15.tar.gz (archive download)

Design libev and libevent

@denji
Copy link
Contributor Author

denji commented Mar 30, 2014

@fredemmott @sgolemon @ptarjan

libuv in github is a multi-platform support library with a focus on asynchronous I/O. It was primarily developed for use by Node.js, but it's also used by Mozilla's Rust language, Luvit, Julia, pyuv, and others.

Documentation: http://nikhilm.github.io/uvbook/ [PDF] [ePub]

Demo: [1] [2]

Feature highlights

  • Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
  • Asynchronous TCP and UDP sockets
  • Asynchronous DNS resolution
  • Asynchronous file and file system operations
  • File system events
  • ANSI escape code controlled TTY
  • IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
  • Child processes
  • Thread pool
  • Signal handling
  • High resolution clock
  • Threading and synchronization primitives

libuv (​https://github.com/joyent/libuv) is a lightweight library which allows asynchronous IO across OpenBSD, Linux, Darwin, Windows etc by utilizing the fastest implementation on each system (epoll, kqueue, IOCP, event ports). These specialized IO polling methods are much faster on their respective platforms than just using select() like the RTS currently does.
Additionally, it also provides cross platform threads, mutex, condition vars, terminal input/output and term settings w/ cross platform ANSI escape code handling, thread pools, cross platform HRC's etc. It's currently significantly faster than libevent and slightly faster than libev (and no doubt faster than rolling our own stuff). Because it's maintained and utilized heavily by Node.js it's in extremely active and maintained development.

utilize libuv would have the following benefits

  • We could ditch basically all of our platform specific code. Everything under rts/win32 and rts/posix, except the SEH stuff, could be deleted.
  • libuv is tuned for speed on each platform. This would be an optimization to all our async IO stuff.

@denji denji changed the title libevent change to libev engine libevent change to (libev or libuv) engine Mar 30, 2014
@denji denji changed the title libevent change to (libev or libuv) engine libevent[unstable] change to (libev or libuv)[stable] engine Mar 30, 2014
@denji denji changed the title libevent[unstable] change to (libev or libuv)[stable] engine libevent migrate to (libev or libuv)[stable] engine Mar 30, 2014
@denji denji changed the title libevent migrate to (libev or libuv)[stable] engine libevent migrate to (libev or libuv) engine Mar 30, 2014
@denji denji changed the title libevent migrate to (libev or libuv) engine "libevent" migrate to "libev" or "libuv" engine Mar 30, 2014
@staabm
Copy link
Contributor

staabm commented Mar 30, 2014

The libevent impl is related to the builtin hhvm server, which has been dropped with 3.0, right?

@denji
Copy link
Contributor Author

denji commented Mar 30, 2014

@staabm current hhvm used libevent but code unstable. Yeah need change to other stable library.

@ptarjan
Copy link
Contributor

ptarjan commented Mar 31, 2014

We use libevent 2.0 now instead of the old hacked forked version (now that we removed the web server).

Would you be interested in trying to port us to this? I'll run the perf testing if you get something working.

@denji
Copy link
Contributor Author

denji commented Mar 31, 2014

@ptarjan The latest release libevent 2.x was at the end of 2012, the developers have not stabilized codebase couple of years. libevent2 and libevent are equally weak stability indicators

http://libev.schmorp.de/bench.html

dat t1

@denji
Copy link
Contributor Author

denji commented Apr 10, 2014

Mordor is a high performance I/O library. It is cross-platform, compiling
on Windows, Linux, and Mac (32-bit and 64-bit on all platforms). It includes
several main areas:

  • Cooperatively scheduled fiber engine, including synchronization primitives
  • Streams library, for dealing with streams of data and manipulating them.
  • HTTP library, building on top of Fibers and Streams, to provide a simple to
    use, yet extremely powerful HTTP client and server API.
  • Supporting infrastructure, including logging, configuration, statistics
    gathering, and exceptions.
  • A unit test framework that is lightweight, easy to use, but has several useful
    features.

https://github.com/mozy/mordor
http://code.mozy.com/projects/mordor

@denji
Copy link
Contributor Author

denji commented Jun 5, 2014

mozjpeg (Mozilla JPEG Encoder Project) - This project's goal is to reduce the size of JPEG files without reducing quality or compatibility with the vast majority of the world's deployed decoders.

The idea is to reduce transfer times for JPEGs on the Web, thus reducing page load times.

'mozjpeg' is not intended to be a general JPEG library replacement. It makes tradeoffs that are intended to benefit Web use cases and focuses solely on improving encoding. It is best used as part of a Web encoding workflow. For a general JPEG library (e.g. your system libjpeg), especially if you care about decoding, we recommend libjpeg-turbo.

For more information, see the project announcement

@steelbrain
Copy link
Contributor

Tara Rum Pum, Bump.

@steelbrain
Copy link
Contributor

Now that HHVM uses Proxygen instead of libevent, I think this issue should be closed, I would've loved to see libuv supported in HHVM though, the community extensions are out of date.

@Orvid
Copy link
Contributor

Orvid commented Jul 17, 2015

HHVM still uses libevent in a few places, I know this, because I've had to do some adjustments to a few libevent APIs in order to make it play nicer with they way I ported HHVM to windows.

@steelbrain
Copy link
Contributor

@Orvid are those places planned to be removed or they are gonna be around for some time?

@fredemmott
Copy link
Contributor

closing:

  • the libevent 1.x server is about to be completely removed (and is an optional build component anyway)
  • the performance argument here does not justify the effort to replace libevent 2.0 in other places given it has never shown up as a significant factor in real application profiles

If you have a non-performance reason for replacing the remaining libevent code with something else, please file another issue. If you want a new extension exposing it to userspace, that could be a separate feature request issue, however we're unlikely to implement it - it would be better addressed by a community extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants