perf: http layer - speedup couchdb version lookup
It turned out that we spend a lot of our time for every request in the
function couch_server:get_version which simply gets the current CouchDB
version.
Instead of fetching a list of all loaded applications an filtering it
we are directly getting the current VSN of CouchDB.
Patched version is 10% faster for a simple /get on a document.
(Almost?) All our of request-handlers are accessing this function so it
should be beneficial for large areas of the http layer.
diff --git a/src/couch_server.erl b/src/couch_server.erl
index 228edc3..77105ed 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -45,12 +45,9 @@
couch:start().
get_version() ->
- Apps = application:loaded_applications(),
- case lists:keysearch(couch, 1, Apps) of
- {value, {_, _, Vsn}} ->
- Vsn;
- false ->
- "0.0.0"
+ case application:get_key(couch, vsn) of
+ {ok, Version} -> Version;
+ undefined -> "0.0.0"
end.
get_version(short) ->
%% strip git hash from version string