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

ets-backed mongoose_router #3505

Merged
merged 5 commits into from
Jan 19, 2022
Merged

ets-backed mongoose_router #3505

merged 5 commits into from
Jan 19, 2022

Conversation

NelsonVides
Copy link
Collaborator

The beginning of the idea comes from https://www.erlang.org/doc/efficiency_guide/tablesdatabases:

For non-persistent database storage, prefer Ets tables over Mnesia local_content tables. Even the Mnesia dirty_write operations carry a fixed overhead compared to Ets writes. Mnesia must check if the table is replicated or has indices, this involves at least one Ets lookup for each dirty_write. Thus, Ets writes is always faster than Mnesia writes.

With that text in mind, I realised that the routing table in MIM is currently implemented as a mnesia local_content table. So I decided to make it an ets table. Which was a good opportunity to turn it into mongooseim code. Now we have our own nicely optimised router backend for the most common local routing. Components and s2s remain unchanged, to be optimised some other time.

@codecov
Copy link

codecov bot commented Jan 17, 2022

Codecov Report

Merging #3505 (4e9d66f) into master (a5e9d8e) will increase coverage by 0.01%.
The diff coverage is 84.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3505      +/-   ##
==========================================
+ Coverage   80.96%   80.97%   +0.01%     
==========================================
  Files         418      419       +1     
  Lines       32329    32309      -20     
==========================================
- Hits        26174    26163      -11     
+ Misses       6155     6146       -9     
Impacted Files Coverage Δ
src/config/mongoose_config_spec.erl 99.20% <ø> (ø)
src/ejabberd_s2s_in.erl 76.56% <50.00%> (-0.55%) ⬇️
src/ejabberd_router.erl 76.00% <80.00%> (+4.48%) ⬆️
src/mongoose_router.erl 87.50% <87.50%> (ø)
src/domain/mongoose_lazy_routing.erl 84.84% <100.00%> (ø)
src/ejabberd_app.erl 94.73% <100.00%> (+0.07%) ⬆️
src/ejabberd_local.erl 77.34% <100.00%> (ø)
src/mongoose_router_localdomain.erl 100.00% <100.00%> (ø)
...stem_metrics/mongoose_system_metrics_collector.erl 93.81% <100.00%> (ø)
src/logger/mongoose_log_filter.erl 78.08% <0.00%> (-1.37%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5e9d8e...4e9d66f. Read the comment docs.

@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

small comments

src/ejabberd_s2s_in.erl Outdated Show resolved Hide resolved
src/mongoose_router.erl Outdated Show resolved Hide resolved
@mongoose-im

This comment has been minimized.

@NelsonVides NelsonVides marked this pull request as ready for review January 17, 2022 18:05
Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

added comments

src/ejabberd_router.erl Outdated Show resolved Hide resolved
src/mongoose_router.erl Outdated Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jan 18, 2022

small_tests_24 / small_tests / 4e9d66f
Reports root / small


small_tests_23 / small_tests / 4e9d66f
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 4e9d66f
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 4e9d66f
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 4e9d66f
Reports root/ big
OK: 2674 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 4e9d66f
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 4e9d66f
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 4e9d66f
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 4e9d66f
Reports root/ big
OK: 1541 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 4e9d66f
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 4e9d66f
Reports root/ big
OK: 1834 / Failed: 0 / User-skipped: 363 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 4e9d66f
Reports root/ big
OK: 3073 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 4e9d66f
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 4e9d66f
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 4e9d66f
Reports root/ big
OK: 1680 / Failed: 0 / User-skipped: 363 / Auto-skipped: 0

@arcusfelis arcusfelis merged commit 8ef7d9a into master Jan 19, 2022
@arcusfelis arcusfelis deleted the mim_router branch January 19, 2022 14:32
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
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.

None yet

4 participants