This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch update-ets-lru-to-use-refs in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 40a4df651a0ae9487f6fd77d74ed8d04af60d38c Author: Nick Vatamaniuc <vatam...@gmail.com> AuthorDate: Fri Nov 10 01:42:45 2023 -0500 Replace unique_integer with a ref in ets_lru We don't really need a strictly monotonic integer, just a unique key for each atime and ctime entry. `unique_integer([monotonic])` is also a concurrency bottleneck as indicated the warning in [1]. Even in a sequential context, it's slower: ``` > timer:tc(fun() -> [erlang:unique_integer([monotonic]) || _ <- lists:seq(1,1000000)], ok end). {434637,ok} > timer:tc(fun() -> [make_ref() || _ <- lists:seq(1,1000000)], ok end). {322988,ok} ``` [1] https://www.erlang.org/doc/man/erlang.html#unique_integer-1 --- src/ets_lru/src/ets_lru.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ets_lru/src/ets_lru.erl b/src/ets_lru/src/ets_lru.erl index 66bf24612..d77b36d4a 100644 --- a/src/ets_lru/src/ets_lru.erl +++ b/src/ets_lru/src/ets_lru.erl @@ -366,4 +366,4 @@ table_name(Name, Ext) -> -spec strict_monotonic_time(atom()) -> strict_monotonic_time(). strict_monotonic_time(TimeUnit) -> - {erlang:monotonic_time(TimeUnit), erlang:unique_integer([monotonic])}. + {erlang:monotonic_time(TimeUnit), make_ref()}.