Optimize tid lock table

By making the ets table mnesia_tid_locks an ordered set instead of a
bag, the time for inserting locks for a transaction with large number
of locks is reduced significantly.
The line is not needed, but it is an optimization.

The '$1' is just the first element of the key, not the whole key. It will
probably be sorted, but it will not be unique. In the earlier code '$1'
referred to the whole key, which then was the tid, but still was not unique
since it was a bag table.

The code obviously handles duplicates, but there is no reason to keep them.
Quite the opposite.
On Aug 31, 2014 9:55 PM, "Fabio Ticconi" <notifications@github.com> wrote:

> In lib/mnesia/src/mnesia_locker.erl:
>
> > @@ -509,7 +509,8 @@ release_remote_non_pending(Node, Pending) ->
> >      %% running at the failed node and also simply remove all
> >      %% queue'd requests back to the failed node
> >
> > -    AllTids = ?ets_match(mnesia_tid_locks, {'$1', '_', '_'}),
> > +    AllTids0 = ?ets_match(mnesia_tid_locks, {{'$1', '_', '_'}}),
> > +    AllTids  = lists:usort(AllTids0),
>
> Is this line needed? Being the table an ordered set, it would already be
> sorted and without duplicates.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/erlang/otp/pull/382/files#r16936609>.
>