Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 1 commit
  • 8 files changed
  • 0 comments
  • 1 contributor
Sep 04, 2013
Steve Vinoski add system_info(ets_limit)
Add system_info(ets_limit) to provide a way to retrieve the runtime's
maximum number of ETS tables. Add tests and documentation for it too.

Also repair the alphabetical order of system_info/1 argument descriptions
in the documentation and in the erlang.erl clauses. Add new preloaded
erlang.erl due to that change. Also ensure all system_info/1 clauses are
represented in the erlang.xml source documentation -- a couple had been
inadvertently dropped in previous commits when other clauses were added.
c7f5d38
2  erts/doc/src/erl.xml
@@ -524,7 +524,7 @@
524 524
 	<p>Calling <c>erlang:halt/1</c> with a string argument will still
525 525
 	produce a crash dump.</p>
526 526
       </item>
527  
-      <tag><c><![CDATA[+e Number]]></c></tag>
  527
+      <tag><marker id="+e"><c><![CDATA[+e Number]]></c></marker></tag>
528 528
       <item>
529 529
         <p>Set max number of ETS tables.</p>
530 530
       </item>
22  erts/doc/src/erlang.xml
@@ -5500,6 +5500,9 @@ ok
5500 5500
       <name name="system_info" arity="1" clause_i="49"/>
5501 5501
       <name name="system_info" arity="1" clause_i="50"/>
5502 5502
       <name name="system_info" arity="1" clause_i="51"/>
  5503
+      <name name="system_info" arity="1" clause_i="52"/>
  5504
+      <name name="system_info" arity="1" clause_i="53"/>
  5505
+      <name name="system_info" arity="1" clause_i="54"/>
5503 5506
       <fsummary>Information about the system</fsummary>
5504 5507
       <desc>
5505 5508
         <p>Returns various information about the current system
@@ -5576,6 +5579,13 @@ ok
5576 5579
               information see the <seealso marker="erts:crash_dump">"How to interpret the Erlang crash dumps"</seealso>
5577 5580
               chapter in the ERTS User's Guide.</p>
5578 5581
           </item>
  5582
+          <tag><marker id="system_info_dist_buf_busy_limit"><c>dist_buf_busy_limit</c></marker></tag>
  5583
+          <item>
  5584
+            <p>Returns the value of the distribution buffer busy limit
  5585
+	    in bytes. This limit can be set on startup by passing the
  5586
+	    <seealso marker="erts:erl#+zdbbl">+zdbbl</seealso> command line
  5587
+	    flag to <c>erl</c>.</p>
  5588
+          </item>
5579 5589
           <tag><c>dist_ctrl</c></tag>
5580 5590
           <item>
5581 5591
             <p>Returns a list of tuples
@@ -5622,12 +5632,14 @@ ok
5622 5632
 	      The return value will always be <c>false</c> since
5623 5633
 	      the elib_malloc allocator has been removed.</p>
5624 5634
           </item>
5625  
-          <tag><marker id="system_info_dist_buf_busy_limit"><c>dist_buf_busy_limit</c></marker></tag>
  5635
+          <tag><c>ets_limit</c></tag>
5626 5636
           <item>
5627  
-            <p>Returns the value of the distribution buffer busy limit
5628  
-	    in bytes. This limit can be set on startup by passing the
5629  
-	    <seealso marker="erts:erl#+zdbbl">+zdbbl</seealso> command line
5630  
-	    flag to <c>erl</c>.</p>
  5637
+            <p>Returns the maximum number of ETS tables allowed. This limit
  5638
+              can be increased on startup by passing the <seealso
  5639
+              marker="erts:erl#+e">+e</seealso> command line flag to
  5640
+              <c>erl</c> or by setting the environment variable
  5641
+              <c>ERL_MAX_ETS_TABLES</c> before starting the Erlang runtime
  5642
+              system.</p>
5631 5643
           </item>
5632 5644
           <tag><c>fullsweep_after</c></tag>
5633 5645
           <item>
3  erts/emulator/beam/erl_bif_info.c
@@ -2636,6 +2636,9 @@ BIF_RETTYPE system_info_1(BIF_ALIST_1)
2636 2636
 
2637 2637
 	BIF_RET(res);
2638 2638
     }
  2639
+    else if (ERTS_IS_ATOM_STR("ets_limit",BIF_ARG_1)) {
  2640
+        BIF_RET(make_small(erts_db_get_max_tabs()));
  2641
+    }
2639 2642
 
2640 2643
     BIF_ERROR(BIF_P, BADARG);
2641 2644
 }
7  erts/emulator/beam/erl_db.c
@@ -3811,6 +3811,13 @@ erts_db_foreach_offheap(DbTable *tb,
3811 3811
     tb->common.meth->db_foreach_offheap(tb, func, arg);
3812 3812
 }
3813 3813
 
  3814
+/* retrieve max number of ets tables */
  3815
+Uint
  3816
+erts_db_get_max_tabs()
  3817
+{
  3818
+    return db_max_tabs;
  3819
+}
  3820
+
3814 3821
 /*
3815 3822
  * For testing of meta tables only.
3816 3823
  *
2  erts/emulator/beam/erl_db.h
@@ -79,6 +79,8 @@ extern erts_smp_atomic_t erts_ets_misc_mem_size;
79 79
 
80 80
 Eterm erts_ets_colliding_names(Process*, Eterm name, Uint cnt);
81 81
 
  82
+Uint erts_db_get_max_tabs(void);
  83
+
82 84
 #endif
83 85
 
84 86
 #if defined(ERTS_WANT_DB_INTERNAL__) && !defined(ERTS_HAVE_DB_INTERNAL__)
54  erts/emulator/test/system_info_SUITE.erl
@@ -37,7 +37,8 @@
37 37
 	 init_per_group/2,end_per_group/2, 
38 38
 	 init_per_testcase/2, end_per_testcase/2]).
39 39
 
40  
--export([process_count/1, system_version/1, misc_smoke_tests/1, heap_size/1, wordsize/1, memory/1]).
  40
+-export([process_count/1, system_version/1, misc_smoke_tests/1, heap_size/1, wordsize/1, memory/1,
  41
+         ets_limit/1]).
41 42
 
42 43
 -define(DEFAULT_TIMEOUT, ?t:minutes(2)).
43 44
 
@@ -45,7 +46,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
45 46
 
46 47
 all() -> 
47 48
     [process_count, system_version, misc_smoke_tests,
48  
-     heap_size, wordsize, memory].
  49
+     heap_size, wordsize, memory, ets_limit].
49 50
 
50 51
 groups() -> 
51 52
     [].
@@ -496,3 +497,52 @@ mapn(_Fun, 0) ->
496 497
     [];
497 498
 mapn(Fun, N) ->
498 499
     [Fun(N) | mapn(Fun, N-1)].
  500
+
  501
+ets_limit(doc) ->
  502
+    "Verify system_info(ets_limit) reflects max ETS table settings.";
  503
+ets_limit(suite) -> [];
  504
+ets_limit(Config0) when is_list(Config0) ->
  505
+    Config = [{testcase,ets_limit}|Config0],
  506
+    true = is_integer(get_ets_limit(Config)),
  507
+    12345 = get_ets_limit(Config, 12345),
  508
+    ok.
  509
+
  510
+get_ets_limit(Config) ->
  511
+    get_ets_limit(Config, 0).
  512
+get_ets_limit(Config, EtsMax) ->
  513
+    Envs = case EtsMax of
  514
+               0 -> [];
  515
+               _ -> [{"ERL_MAX_ETS_TABLES", integer_to_list(EtsMax)}]
  516
+           end,
  517
+    {ok, Node} = start_node(Config, Envs),
  518
+    Me = self(),
  519
+    Ref = make_ref(),
  520
+    spawn_link(Node,
  521
+               fun() ->
  522
+                       Res = erlang:system_info(ets_limit),
  523
+                       unlink(Me),
  524
+                       Me ! {Ref, Res}
  525
+               end),
  526
+    receive
  527
+        {Ref, Res} ->
  528
+            Res
  529
+    end,
  530
+    stop_node(Node),
  531
+    Res.
  532
+
  533
+start_node(Config, Envs) when is_list(Config) ->
  534
+    Pa = filename:dirname(code:which(?MODULE)),
  535
+    {A, B, C} = now(),
  536
+    Name = list_to_atom(atom_to_list(?MODULE)
  537
+                        ++ "-"
  538
+                        ++ atom_to_list(?config(testcase, Config))
  539
+                        ++ "-"
  540
+                        ++ integer_to_list(A)
  541
+                        ++ "-"
  542
+                        ++ integer_to_list(B)
  543
+                        ++ "-"
  544
+                        ++ integer_to_list(C)),
  545
+    ?t:start_node(Name, peer, [{args, "-pa "++Pa}, {env, Envs}]).
  546
+
  547
+stop_node(Node) ->
  548
+    ?t:stop_node(Node).
BIN  erts/preloaded/ebin/erlang.beam
Binary file not shown
3  erts/preloaded/src/erlang.erl
@@ -2099,13 +2099,14 @@ tuple_to_list(_Tuple) ->
2099 2099
          (creation) -> integer();
2100 2100
          (debug_compiled) -> boolean();
2101 2101
          (dist) -> binary();
  2102
+         (dist_buf_busy_limit) -> non_neg_integer();
2102 2103
          (dist_ctrl) -> {Node :: node(),
2103 2104
                          ControllingEntity :: port() | pid()};
2104 2105
          (driver_version) -> string();
2105 2106
 	 (dynamic_trace) -> none | dtrace | systemtap;
2106 2107
          (dynamic_trace_probes) -> boolean();
2107 2108
          (elib_malloc) -> false;
2108  
-         (dist_buf_busy_limit) -> non_neg_integer();
  2109
+         (ets_limit) -> pos_integer();
2109 2110
          (fullsweep_after) -> {fullsweep_after, non_neg_integer()};
2110 2111
          (garbage_collection) -> [{atom(), integer()}];
2111 2112
          (heap_sizes) -> [non_neg_integer()];

No commit comments for this range

Something went wrong with that request. Please try again.