Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize tid lock table #382

Merged
merged 1 commit into from
Jun 25, 2014
Merged

Optimize tid lock table #382

merged 1 commit into from
Jun 25, 2014

Conversation

gorillainduction
Copy link
Contributor

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.

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.
@OTP-Maintainer
Copy link

Patch has passed first testings and has been assigned to be reviewed

@marcusarendt marcusarendt merged commit d9a1f78 into erlang:maint Jun 25, 2014
@@ -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),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line (513) needed? Being the table an ordered set, it would already be sorted and without duplicates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are quite right. Thanks!

@gorillainduction gorillainduction deleted the improve_mnesia_locker_complexity branch March 10, 2020 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants