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/10 19:59:33 UTC

[couchdb] branch optimize-ddoc-cache updated (62bfbf4 -> a0ae3d6)

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 62bfbf4  FIXUP: Remove unnecessary catch
     new c4e80de  FIXUP: Add vsn attribute
     new a0ae3d6  FIXUP: Don't send possibly large messages

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:
 src/ddoc_cache/src/ddoc_cache_entry.erl                  |  6 ++++--
 src/ddoc_cache/src/ddoc_cache_lru.erl                    |  3 ++-
 src/ddoc_cache/src/ddoc_cache_opener.erl                 |  1 +
 .../src/ddoc_cache_value.erl}                            | 16 ++++++++--------
 4 files changed, 15 insertions(+), 11 deletions(-)
 copy src/{couch_event/src/couch_event_app.erl => ddoc_cache/src/ddoc_cache_value.erl} (76%)

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

[couchdb] 01/02: FIXUP: Add vsn attribute

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 c4e80de910f5830ba21a4f3807e7d8eb902c63f6
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jul 10 14:39:15 2017 -0500

    FIXUP: Add vsn attribute
---
 src/ddoc_cache/src/ddoc_cache_entry.erl  | 1 +
 src/ddoc_cache/src/ddoc_cache_opener.erl | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/ddoc_cache/src/ddoc_cache_entry.erl b/src/ddoc_cache/src/ddoc_cache_entry.erl
index 2660293..38bc961 100644
--- a/src/ddoc_cache/src/ddoc_cache_entry.erl
+++ b/src/ddoc_cache/src/ddoc_cache_entry.erl
@@ -12,6 +12,7 @@
 
 -module(ddoc_cache_entry).
 -behaviour(gen_server).
+-vsn(1).
 
 
 -export([
diff --git a/src/ddoc_cache/src/ddoc_cache_opener.erl b/src/ddoc_cache/src/ddoc_cache_opener.erl
index 7839bcb..52de542 100644
--- a/src/ddoc_cache/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache/src/ddoc_cache_opener.erl
@@ -14,6 +14,7 @@
 -behaviour(gen_server).
 -vsn(1).
 
+
 -export([
     start_link/0
 ]).

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

[couchdb] 02/02: FIXUP: Don't send possibly large messages

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 a0ae3d67ecabba066697215e932869a9a0b8f520
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jul 10 14:56:59 2017 -0500

    FIXUP: Don't send possibly large messages
    
    User design documents can be fairly large which could end up crushing
    the ddoc_cache_lru mailbox. This just converts the possibly large values
    to binaries before sending them.
---
 src/ddoc_cache/src/ddoc_cache_entry.erl |  5 +++--
 src/ddoc_cache/src/ddoc_cache_lru.erl   |  3 ++-
 src/ddoc_cache/src/ddoc_cache_value.erl | 27 +++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/ddoc_cache/src/ddoc_cache_entry.erl b/src/ddoc_cache/src/ddoc_cache_entry.erl
index 38bc961..f40ac40 100644
--- a/src/ddoc_cache/src/ddoc_cache_entry.erl
+++ b/src/ddoc_cache/src/ddoc_cache_entry.erl
@@ -116,7 +116,8 @@ init({Key, undefined}) ->
     ?EVENT(started, Key),
     gen_server:enter_loop(?MODULE, [], St);
 
-init({Key, Default}) ->
+init({Key, Wrapped}) ->
+    Default = ddoc_cache_value:unwrap(Wrapped),
     Updates = [
         {#entry.val, Default},
         {#entry.pid, self()}
@@ -133,7 +134,7 @@ init({Key, Default}) ->
         accessed = 1
     },
     ?EVENT(default_started, Key),
-    gen_server:enter_loop(?MODULE, [], St).
+    gen_server:enter_loop(?MODULE, [], St, hibernate).
 
 
 terminate(_Reason, St) ->
diff --git a/src/ddoc_cache/src/ddoc_cache_lru.erl b/src/ddoc_cache/src/ddoc_cache_lru.erl
index 49aa62d..12f5d10 100644
--- a/src/ddoc_cache/src/ddoc_cache_lru.erl
+++ b/src/ddoc_cache/src/ddoc_cache_lru.erl
@@ -72,7 +72,8 @@ open(Key) ->
 insert(Key, Value) ->
     case ets:lookup(?CACHE, Key) of
         [] ->
-            gen_server:call(?MODULE, {start, Key, Value}, infinity);
+            Wrapped = ddoc_cache_value:wrap(Value),
+            gen_server:call(?MODULE, {start, Key, Wrapped}, infinity);
         [#entry{}] ->
             ok
     end.
diff --git a/src/ddoc_cache/src/ddoc_cache_value.erl b/src/ddoc_cache/src/ddoc_cache_value.erl
new file mode 100644
index 0000000..21a5bb5
--- /dev/null
+++ b/src/ddoc_cache/src/ddoc_cache_value.erl
@@ -0,0 +1,27 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(ddoc_cache_value).
+
+
+-export([
+    wrap/1,
+    unwrap/1
+]).
+
+
+wrap(Value) ->
+    {?MODULE, term_to_binary(Value)}.
+
+
+unwrap({?MODULE, Bin}) when is_binary(Bin) ->
+    binary_to_term(Bin).

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