nickva commented on a change in pull request #2662: Use `couch_rate` 
application for `couch_view`
URL: https://github.com/apache/couchdb/pull/2662#discussion_r395895450
 
 

 ##########
 File path: src/couch_rate/src/couch_rate_ets.erl
 ##########
 @@ -0,0 +1,147 @@
+% 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(couch_rate_ets).
+
+-include("couch_rate.hrl").
+
+-export([
+    create_tables/0,
+    new/3,
+    from_map/3,
+    budget/1,
+    delay/1,
+    wait/1,
+    in/2,
+    success/2,
+    failure/1,
+    is_congestion/1,
+    min_latency/1,
+    format/1,
+    to_map/1,
+    module/1,
+    state/1,
+    table_name/1,
+    table_names/0
+]).
+
+
+-define(SHARDS_N, 16).
+
+-compile({parse_transform, lookup_pt}).
+
+%% The following directive would generate following code
 
 Review comment:
   Depending how often this code will be called. 1 microsecond difference every 
few seconds doesn't seem worth adding a parse transform or look up table for? 
If it is going to be called a 10000 times in a loop per single doc request, it 
would add a 10 millisecond to each request, then we would want to optimize it 
for sure.
   
   So depending on that start with a simple one-line `list_to_atom()` to keep 
the code base smaller then later on, if we see a performance issue, add the 
parse transform? And we can also re-use it for other sharded tables once we 
added it. (We'd put in `couch` or `fabric` util function).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to