This week I've done a few optimizations, fixed some bugs and also
changed how worker threads are terminated.
At the end of the week the current plugin_next branch is almost as fast
as current master (5% diff) while supporting a lot more features as well
as two different plugin api's.

# Thread exit

For signals indicating ordinary termination monkey no longer calls
exit() in the signal handler, but instead closes the scheduler epoll
instances.
This causes the epoll loop to terminate and the scheduler to exit in an
orderly manner.
It has long been very annoying to make valgrind shut up about thread
memory leaks and expose actual bad leeks.
This should no longer be a problem with each plugin and protocol having
both thread init and exit hooks, making it a lot easier to free all
resources.

Sometime in the future this may enable dynamic number of workers if
done right.

An added bonus of these changes is that threads are joined when monkey
is terminated, which helps the Linux `perf` tool record the correct
symbols.
It may also prevent monkey from leaving behind any half-dead threads,
but Linux is pretty good at this already.

# Optimizations

The optimizations with most impacts been related to searching in ordered
data.
Specifically searching for headers has been much improved by finding
delimiters and then do a full match.
The strcasecmp() function was the most heavily used libc function by
far.

Another optimization that yielded significant speedup was to store a
pointer to the `client_session` in the `void*` field inside
`sched_connection`.
This removed one rb-tree lookup per socket event.
The only remaining lookup per socket event is fetching of
`sched_connection`, and it will be removed sometime next week.

Increasing the initial number of entries in a `mk_queue` struct removed
about 25% of all calls to malloc for static files.
Previously the initial number was less than the entries needed for the
response headers, causing unnecessary overhead.

# SSL

I'm working on adding SSL support inside monkey as part of the HTTP
protocol implementation.
It is not yet finished, but when it is will allow both HTTP and HTTPS
connections in the same binary.
Some tests in ./configure will be added for easy enabling/disabling of
SSL.

[Blog](https://lotrax.org/gsoc/gsoc-2013-status-future-protocols-week-11.html)
[Code](https://github.com/ksonny/monkey/tree/plugin_next)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to