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

Cosmetics changes to improve readability, types, and upgrades #185

Merged
merged 9 commits into from
Jun 17, 2024

Conversation

NelsonVides
Copy link
Collaborator

No description provided.

@NelsonVides NelsonVides marked this pull request as ready for review June 14, 2024 08:10
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 41.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 74.87%. Comparing base (887e312) to head (7d9299b).

Files Patch % Lines
src/dist/amoc_dist.erl 0.00% 6 Missing ⚠️
src/users/amoc_users_worker_sup.erl 57.14% 6 Missing ⚠️
src/throttle/amoc_throttle_process.erl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #185      +/-   ##
==========================================
- Coverage   75.19%   74.87%   -0.33%     
==========================================
  Files          31       31              
  Lines        1165     1170       +5     
==========================================
  Hits          876      876              
- Misses        289      294       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

If the test has some deviation on the behaviour of clients according to
their IDs, for example if every N clients the Nth will do extra work,
then the distribution of clients across supervisors might not be
uniform. For this, prefer hashing them.
@@ -73,7 +73,7 @@ terminate(Scenario, State) ->
%% if scenario module exports both functions, `Scenario:start/2' is used.
%%
%% Runs on the user process and spans a `[amoc, scenario, user, _]' telemetry event.
-spec start(amoc:scenario(), user_id(), state()) -> any().
-spec start(amoc:scenario(), user_id(), state()) -> term().
Copy link
Collaborator

Choose a reason for hiding this comment

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

any() highlights that returned value is ignored.

-define(WORKER(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
-define(SUP(I, Type), {I, {I, start_link, []}, permanent, infinity, Type, [I]}).
-define(WORKER(I), {I, {I, start_link, []}, permanent, 5000, worker, [I]}).
-define(SUP(I), {I, {I, start_link, []}, permanent, infinity, supervisor, [I]}).
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, this was a bit stupid :)

@@ -139,14 +139,14 @@ terminate_all_children() ->
-spec get_sup_for_user_id(amoc_scenario:user_id()) -> pid().
get_sup_for_user_id(Id) ->
#storage{sups = Supervisors, sups_count = SupCount} = persistent_term:get(?MODULE),
Index = Id rem SupCount + 1,
Index = erlang:phash2(Id, SupCount) + 1,
Copy link
Collaborator

@DenysGonchar DenysGonchar Jun 17, 2024

Choose a reason for hiding this comment

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

I'm not sure if phash makes a better distribution than a simple rem.

Copy link
Collaborator

@DenysGonchar DenysGonchar left a comment

Choose a reason for hiding this comment

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

looks good

@DenysGonchar DenysGonchar merged commit 360c3a3 into master Jun 17, 2024
6 checks passed
@DenysGonchar DenysGonchar deleted the cosmetics branch June 17, 2024 11:45
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.

3 participants