<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 10/12/2017 01:15 PM, Benoit Chesneau
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:23A4A74C-6394-4749-8F94-FA05C1C32E1F@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Thanks for the answer :)<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 12 Oct 2017, at 10:17, Chandru <<a
href="mailto:chandrashekhar.mullaparthi@gmail.com"
class="" moz-do-not-send="true">chandrashekhar.mullaparthi@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">On 12 October 2017 at 09:01, Benoit
Chesneau <span dir="ltr" class=""><<a
href="mailto:bchesneau@gmail.com" target="_blank"
class="" moz-do-not-send="true">bchesneau@gmail.com</a>></span>
wrote:<br class="">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
all,<br class="">
<br class="">
I’m looking on the best way (in term of concurrency
and response speed) to provide a equivalent of
compare-and-swap semantic on differs Erlang version
with ETS. </blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="">
For now what I do is using `select_replace/2` on OTP
20 and for other versions I’m using a pen_server to
serialise the writes on this values, making this
gen_server a bottle neck. Which is fine for a small
list of keys to update. I didn’t find any other
solution to do it right now. But maybe someone has
an idea?<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class="">The only thing I can think of is to
partition the key space and use multiple ETS tables
(with a dedicated process for each).</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>True. I can do that indeed … That may be the easiest thing
to do in the long term. </div>
<div><br class="">
</div>
<div>For now I I did this simple lib: <a
href="https://gitlab.com/barrel-db/lab/ets_cas" class=""
moz-do-not-send="true">https://gitlab.com/barrel-db/lab/ets_cas</a> with
limited test coverage. </div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class=""><br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Also
something I’m currently missing is the possibility
do the dame for delete. `select_delete` isn’t atomic
right?<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class="">Not sure what you mean by 'atomic' here.
I expect ETS will delete whatever entries have
matched this specified pattern at that point in
time. In the context of ETS operations, the
consideration of whether it is 'atomic' or not makes
sense in the 'insert', 'replace' or 'update'
scenario.</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div><br class="">
</div>
</div>
I’m not sure what’s the difference between a delete and a replace
there with the current ETS librarie 20.1 . By atomic I mean atomic
at the key level, ie 2 concurrent delete will be serialisable
which seems to be the case for `select_replace` .
<div class=""><br class="">
</div>
<br>
</blockquote>
<br>
All ets:select* functions are atomic per table object.<br>
That is, each match-and-* operation is atomic. The iteration is not.<br>
<br>
<br>
/Sverker<br>
</body>
</html>