You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/07/06 19:12:20 UTC

[couchdb] branch optimize-ddoc-cache updated (85b5385 -> 7c376bd)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from 85b5385  FIXUP: Reuse fabric lookup results
     new 9151fb5  FIXUP: Make the refresh timeout configurable
     new 7c376bd  FIXUP: Remember to clear out the waiters list

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 rel/overlay/etc/default.ini             |  8 ++++++++
 src/ddoc_cache/src/ddoc_cache_entry.erl | 14 +++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 02/02: FIXUP: Remember to clear out the waiters list

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7c376bd6efc372cd7f107989fd14e40e8ab7a7e6
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Jul 6 14:12:01 2017 -0500

    FIXUP: Remember to clear out the waiters list
---
 src/ddoc_cache/src/ddoc_cache_entry.erl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/ddoc_cache/src/ddoc_cache_entry.erl b/src/ddoc_cache/src/ddoc_cache_entry.erl
index db5e0b1..2660293 100644
--- a/src/ddoc_cache/src/ddoc_cache_entry.erl
+++ b/src/ddoc_cache/src/ddoc_cache_entry.erl
@@ -231,7 +231,8 @@ handle_info({'DOWN', _, _, Pid, Resp}, #st{key = Key, opener = Pid} = St) ->
             update_cache(St, Val),
             NewSt1 = St#st{
                 val = {open_ok, {ok, Val}},
-                opener = start_timer()
+                opener = start_timer(),
+                waiters = undefined
             },
             NewSt2 = update_lru(NewSt1),
             if not is_list(St#st.waiters) -> ok; true ->

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.

[couchdb] 01/02: FIXUP: Make the refresh timeout configurable

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9151fb59a8f8553a95af23fa58ef67a76f069b80
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Jul 6 14:11:13 2017 -0500

    FIXUP: Make the refresh timeout configurable
---
 rel/overlay/etc/default.ini             |  8 ++++++++
 src/ddoc_cache/src/ddoc_cache_entry.erl | 13 ++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 163b90e..9930a3b 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -188,6 +188,14 @@ credentials = false
 ; List of accepted methods
 ; methods =
 
+; Configuration for the design document cache
+;[ddoc_cache]
+; The maximum number of entries to keep in the cache
+;max_size = 1000
+; The period each cache entry should wait before
+; automatically refreshing in milliseconds
+;refresh_timeout = 67000
+
 [x_frame_options]
 ; Settings same-origin will return X-Frame-Options: SAMEORIGIN.
 ; If same origin is set, it will ignore the hosts setting
diff --git a/src/ddoc_cache/src/ddoc_cache_entry.erl b/src/ddoc_cache/src/ddoc_cache_entry.erl
index 79c3dcf..db5e0b1 100644
--- a/src/ddoc_cache/src/ddoc_cache_entry.erl
+++ b/src/ddoc_cache/src/ddoc_cache_entry.erl
@@ -123,11 +123,10 @@ init({Key, Default}) ->
     NewTs = os:timestamp(),
     true = ets:update_element(?CACHE, Key, Updates),
     true = ets:insert(?LRU, {{NewTs, Key, self()}}),
-    Msg = {'$gen_cast', refresh},
     St = #st{
         key = Key,
         val = {open_ok, {ok, Default}},
-        opener = erlang:send_after(?REFRESH_TIMEOUT, self(), Msg),
+        opener = start_timer(),
         waiters = undefined,
         ts = NewTs,
         accessed = 1
@@ -230,11 +229,9 @@ handle_info({'DOWN', _, _, Pid, Resp}, #st{key = Key, opener = Pid} = St) ->
     case Resp of
         {open_ok, Key, {ok, Val}} ->
             update_cache(St, Val),
-            Msg = {'$gen_cast', refresh},
-            Timer = erlang:send_after(?REFRESH_TIMEOUT, self(), Msg),
             NewSt1 = St#st{
                 val = {open_ok, {ok, Val}},
-                opener = Timer
+                opener = start_timer()
             },
             NewSt2 = update_lru(NewSt1),
             if not is_list(St#st.waiters) -> ok; true ->
@@ -267,6 +264,12 @@ spawn_opener(Key) ->
     Pid.
 
 
+start_timer() ->
+    TimeOut = config:get_integer(
+            "ddoc_cache", "refresh_timeout", ?REFRESH_TIMEOUT),
+    erlang:send_after(TimeOut, self(), {'$gen_cast', refresh}).
+
+
 do_open(Key) ->
     try recover(Key) of
         Resp ->

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.