aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-09-02 20:04:47 +0200
committerSverker Eriksson <[email protected]>2016-09-19 15:50:15 +0200
commitfdc2f2b4a6f6314ae7c183dc4e39e19d05ac89e4 (patch)
tree623690761c72151fc0ce8977b573880dbd614bb2
parent25eb3fe353cb0f5c381107e43a865d3a312c8c25 (diff)
downloadotp-fdc2f2b4a6f6314ae7c183dc4e39e19d05ac89e4.tar.gz
otp-fdc2f2b4a6f6314ae7c183dc4e39e19d05ac89e4.tar.bz2
otp-fdc2f2b4a6f6314ae7c183dc4e39e19d05ac89e4.zip
erts: Fix ets_SUITE:memory
by simply asking for the size of struct ext_segtab
-rw-r--r--erts/emulator/beam/erl_bif_info.c4
-rw-r--r--erts/emulator/beam/erl_db_hash.c5
-rw-r--r--erts/emulator/beam/erl_db_hash.h1
-rw-r--r--lib/stdlib/test/ets_SUITE.erl22
4 files changed, 12 insertions, 20 deletions
diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c
index abf20a90e4..13391b7c67 100644
--- a/erts/emulator/beam/erl_bif_info.c
+++ b/erts/emulator/beam/erl_bif_info.c
@@ -3545,7 +3545,9 @@ BIF_RETTYPE erts_debug_get_internal_state_1(BIF_ALIST_1)
else if (ERTS_IS_ATOM_STR("DbTable_words", BIF_ARG_1)) {
/* Used by ets_SUITE (stdlib) */
size_t words = (sizeof(DbTable) + sizeof(Uint) - 1)/sizeof(Uint);
- BIF_RET(make_small((Uint) words));
+ Eterm* hp = HAlloc(BIF_P ,3);
+ BIF_RET(TUPLE2(hp, make_small((Uint) words),
+ erts_ets_hash_sizeof_ext_segtab()));
}
else if (ERTS_IS_ATOM_STR("DbTable_meta", BIF_ARG_1)) {
/* Used by ets_SUITE (stdlib) */
diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index 581b135233..3f7e14d15d 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -2978,6 +2978,11 @@ void db_calc_stats_hash(DbTableHash* tb, DbHashStats* stats)
}
/* For testing only */
+Eterm erts_ets_hash_sizeof_ext_segtab(void)
+{
+ return make_small(((SIZEOF_EXT_SEGTAB(0)-1) / sizeof(UWord)) + 1);
+}
+/* For testing only */
Eterm erts_ets_hash_get_memstate(Process* p, DbTableHash* tb)
{
Eterm seg_cnt;
diff --git a/erts/emulator/beam/erl_db_hash.h b/erts/emulator/beam/erl_db_hash.h
index e209037878..11bd6aa32a 100644
--- a/erts/emulator/beam/erl_db_hash.h
+++ b/erts/emulator/beam/erl_db_hash.h
@@ -107,6 +107,7 @@ typedef struct {
}DbHashStats;
void db_calc_stats_hash(DbTableHash* tb, DbHashStats*);
+Eterm erts_ets_hash_sizeof_ext_segtab(void);
Eterm erts_ets_hash_get_memstate(Process*, DbTableHash* tb);
Eterm erts_ets_hash_restore_memstate(DbTableHash* tb, Eterm memstate);
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl
index ea555f9c39..ecdac0deff 100644
--- a/lib/stdlib/test/ets_SUITE.erl
+++ b/lib/stdlib/test/ets_SUITE.erl
@@ -591,12 +591,6 @@ select_fail_do(Opts) ->
-define(S(T),ets:info(T,memory)).
--define(TAB_STRUCT_SZ, erts_debug:get_internal_state('DbTable_words')).
-%%-define(NORMAL_TAB_STRUCT_SZ, 26). %% SunOS5.8, 32-bit, non smp, private heap
-%%
-%% The hardcoded expected memory sizes (in words) are the ones we expect on:
-%% SunOS5.8, 32-bit, non smp, private heap
-%%
%% Whitebox test of ets:info(X, memory).
memory(Config) when is_list(Config) ->
@@ -698,25 +692,15 @@ chk_normal_tab_struct_size() ->
erlang:system_info(smp_support),
erlang:system_info(heap_type)},
io:format("System = ~p~n", [System]),
- io:format("?TAB_STRUCT_SZ=~p~n", [?TAB_STRUCT_SZ]),
ok.
-sizeof_ext_segtab() ->
- case {erlang:system_info(wordsize),
- erlang:system_info(smp_support)} of
- {4,true} -> 5 + 3;
- {4,false} -> 3 + 3;
- {8,true} -> 4 + 2;
- {8,false} -> 3 + 2
- end.
-
adjust_xmem([_T1,_T2,_T3,_T4], {A0,B0,C0,D0} = _Mem0, EstCnt) ->
%% Adjust for 64-bit, smp, and os:
%% Table struct size may differ.
- TabDiff = ?TAB_STRUCT_SZ,
- HTabDiff = TabDiff + EstCnt*sizeof_ext_segtab(),
- {A0+TabDiff, B0+HTabDiff, C0+HTabDiff, D0+HTabDiff}.
+ {TabSz, EstSz} = erts_debug:get_internal_state('DbTable_words'),
+ HTabSz = TabSz + EstCnt*EstSz,
+ {A0+TabSz, B0+HTabSz, C0+HTabSz, D0+HTabSz}.
%% Misc. whitebox tests
t_whitebox(Config) when is_list(Config) ->