[erlang-questions] ETS delete_trap

Lukas Larsson garazdawi@REDACTED
Tue Apr 26 09:37:58 CEST 2016


On Tue, Apr 26, 2016 at 1:30 AM, James Aimonetti <james@REDACTED> wrote:

>
> The curious bit that I can't really figure out is the
> {current_function, {ets,delete_trap,1}} bit from the process_info/1
> call (output below). As far as I can tell, that is buried in the VM's
> C code.
>
>
The delete_trap function is used when you are calling either
ets:select_delete/2 or ets:delete/1 on a table with many many elements.

When working with ets tables that have many elements, erts takes smaller
chunks of the table at a time and reschedules the process doing the
processing.

So for ets:delete it would first delete the first X elements (calling
delete), then reschedule, then delete the next X (calling delete_trap), and
so on deleting X records per iteration. Most ets functions work this way in
order to not hog the schedulers for too a long time when working with large
tables.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160426/2a6f9de4/attachment.htm>


More information about the erlang-questions mailing list