chewbranca commented on a change in pull request #610: Optimize ddoc cache
URL: https://github.com/apache/couchdb/pull/610#discussion_r123591611
 
 

 ##########
 File path: src/ddoc_cache/src/ddoc_cache_tables.erl
 ##########
 @@ -0,0 +1,69 @@
+% 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_tables).
+-behaviour(gen_server).
+-vsn(1).
+
+
+-export([
+    start_link/0
+]).
+
+-export([
+    init/1,
+    terminate/2,
+    handle_call/3,
+    handle_cast/2,
+    handle_info/2,
+    code_change/3
+]).
+
+
+-include("ddoc_cache.hrl").
+
+
+start_link() ->
+    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+
+init(_) ->
+    BaseOpts = [public, named_table],
 
 Review comment:
   If all the tables are public, would it make sense to have callers perform 
more of the ETS updates rather than funneling it through a gen_server? 
Obviously not all of that would be appropriate, but it seems like you could 
potentially do something here with the `?LRU` table and using `os:timestamp()`. 
For instance:
   
   ```
   %% Make duplicate_bag ets table to store an index of all LRU entries per 
ddoc_cache Key
   ets:new(lru_keys, [duplicate_bag]).
   
   accessed(Key) ->
       T = os:timestamp(),
       [ets:delete(?LRU, Old) || Old <- ets:lookup(lru_keys, Key)],
       true = ets:insert(?LRU, {T, Key}),
       true = ets:insert(lru_keys, {Key, T}).
   ```
   
   This would bypass funneling the lru access messages through ddoc_cache_lru 
and instead use ETS for the concurrent access.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to