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

Optimization of speed work #68

Merged
merged 3 commits into from
Nov 5, 2021
Merged

Optimization of speed work #68

merged 3 commits into from
Nov 5, 2021

Conversation

vkatsuba
Copy link
Collaborator

@vkatsuba vkatsuba commented Nov 4, 2021

Description

  • Start persistent_term instead of ets
  • Optimize function calls for use on accumulator

NEW

1> timer:tc(sheldon, check, [base64:encode(crypto:strong_rand_bytes(45))]).
{8693825,
 #{bazinga =>
       <<"I know the real reason you never made progress with that idea. You thought of it September 22nd 2007. Tw"...>>,
   misspelled_words =>
       [#{candidates => [],line_number => 1,
          word =>
              "AA9VaG90nSWUwdEQYs+lqTBZRU1vBaxjK7iU/1D3MIgm6FZjOHgF7OEgmlbq"}]}}

OLD

1> timer:tc(sheldon, check, [base64:encode(crypto:strong_rand_bytes(45))]).
=ERROR REPORT==== 4-Nov-2021::14:07:38.607430 ===
sheldon_suggestions_server:24 >> Error: badrpc
        Stack: [{rpc,check,2,[{file,"rpc.erl"},{line,1262}]},
                {sheldon_suggestions_server,suggestions,2,
                    ....
{15072132,
 #{bazinga =>
       <<"The correct animal for inter-species super soldier is the koala. You would wind up with an army so cute,"...>>,
   misspelled_words =>
       [#{candidates => [],line_number => 1,
          word =>
              "T91YJNeOhQ6ctDktj5UhGhQQ8IDDobdqHzhfinVaMxOllvxgfDel/xAH5unw"}]}}

NEW multi calls

1> LongWord = base64:encode(crypto:strong_rand_bytes(45)).
<<"sQ6ZvIjmxBrXhAod0CT3kXMPaKEjSg1KKnlh/gGddfnaeMteM1TRxYdFvpov">>
2> [begin {T, _} = timer:tc(sheldon, check, [LongWord]), T end || _ <- lists:seq(1, 10)].
[8506246,8419900,8042167,8373228,7911508,7964150,7685334,
 8231833,8165089,8113452]

OLD multi calls

1> LongWord = base64:encode(crypto:strong_rand_bytes(45)).
2> [begin {T, _} = timer:tc(sheldon, check, [LongWord]), T end || _ <- lists:seq(1, 10)].
=ERROR REPORT==== 4-Nov-2021::14:14:00.234306 ===
sheldon_suggestions_server:24 >> Error: badrpc
        Stack: [{rpc,check,2,[{file,"rpc.erl"},{line,1262}]},
                {sheldon_suggestions_server,suggestions,2,
                   ...

[13609231,12357943,15000723,15018383,12796271,14544979,
 12315257,14631879,13806544,12979898]

* Removed mapsets
* Start use ets:lookup/1 for speed up work
Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

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

Excellent work, @vkatsuba !!! 🤯
Just a tiny rename, but that's all… I ❤️ this PR!

src/sheldon_dictionary.erl Outdated Show resolved Hide resolved
@elbrujohalcon elbrujohalcon merged commit a4a3719 into main Nov 5, 2021
@elbrujohalcon elbrujohalcon deleted the speed-up branch November 5, 2021 09:19
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.

2 participants