couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [14/21] couch commit: updated refs/heads/windsor-merge-119 to 9138d07
Date Tue, 05 Aug 2014 11:06:15 GMT
Add config for couch_server LRU updates on read

This commit adds the ability for couch_server to ignore update_lru
messages. This should reduce load on couch_server when few entries are
being expired.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/f2b3162c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/f2b3162c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/f2b3162c

Branch: refs/heads/windsor-merge-119
Commit: f2b3162cd99a17d4d57fce035c3d326140124ae1
Parents: 1d6c18e
Author: Benjamin Bastian <benjamin.bastian@gmail.com>
Authored: Fri May 31 13:18:32 2013 -0700
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Aug 4 16:41:04 2014 +0100

----------------------------------------------------------------------
 src/couch_server.erl | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f2b3162c/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index a10fcd0..441290f 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -34,6 +34,7 @@
     max_dbs_open=?MAX_DBS_OPEN,
     dbs_open=0,
     start_time="",
+    update_lru_on_read=true,
     lru = couch_lru:new()
     }).
 
@@ -213,6 +214,10 @@ terminate(_Reason, _Srv) ->
 handle_config_change("couchdb", "database_dir", _, _, _) ->
     exit(whereis(couch_server), config_change),
     remove_handler;
+handle_config_change("couchdb", "update_lru_on_read", "true", _, _) ->
+    {ok, gen_server:call(couch_server,{set_update_lru_on_read,true})};
+handle_config_change("couchdb", "update_lru_on_read", _, _, _) ->
+    {ok, gen_server:call(couch_server,{set_update_lru_on_read,false})};
 handle_config_change("couchdb", "max_dbs_open", Max, _, _) when is_list(Max) ->
     {ok, gen_server:call(couch_server,{set_max_dbs_open,list_to_integer(Max)})};
 handle_config_change("couchdb", "max_dbs_open", _, _, _) ->
@@ -324,6 +329,8 @@ handle_call(close_lru, _From, #server{lru=Lru} = Server) ->
     end;
 handle_call(open_dbs_count, _From, Server) ->
     {reply, Server#server.dbs_open, Server};
+handle_call({set_update_lru_on_read, UpdateOnRead}, _From, Server) ->
+    {reply, ok, Server#server{update_lru_on_read=UpdateOnRead}};
 handle_call({set_max_dbs_open, Max}, _From, Server) ->
     {reply, ok, Server#server{max_dbs_open=Max}};
 handle_call(get_server, _From, Server) ->
@@ -481,8 +488,10 @@ handle_call({db_updated, #db{name = DbName} = Db}, _From, Server) ->
     end,
     {reply, ok, Server#server{lru = Lru}}.
 
-handle_cast({update_lru, DbName}, #server{lru = Lru} = Server) ->
+handle_cast({update_lru, DbName}, #server{lru = Lru, update_lru_on_read=true} = Server) ->
     {noreply, Server#server{lru = couch_lru:update(DbName, Lru)}};
+handle_cast({update_lru, _DbName}, Server) ->
+    {noreply, Server};
 handle_cast(Msg, Server) ->
     {stop, {unknown_cast_message, Msg}, Server}.
 
@@ -494,8 +503,7 @@ handle_info({'EXIT', _Pid, config_change}, Server) ->
 handle_info({'EXIT', Pid, Reason}, Server) ->
     case ets:lookup(couch_dbs_pid_to_name, Pid) of
     [DbName] ->
-        [#db{compactor_pid=Froms}=Db] =
-            ets:match_object(couch_dbs, #db{name=DbName, _='_'}),
+        [#db{compactor_pid=Froms}=Db] = ets:lookup(couch_dbs, DbName),
         if Reason /= snappy_nif_not_loaded -> ok; true ->
             Msg = io_lib:format("To open the database `~s`, Apache CouchDB "
                 "must be built with Erlang OTP R13B04 or higher.", [DbName]),


Mime
View raw message