-
Notifications
You must be signed in to change notification settings - Fork 89
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
[QUESTION] prepare_done(State, Action) function #389
Comments
Hi Igor, You need to pass the current Is there a reason why would you changed the atom |
Hi Peter, I believe that a macro definition might do the job using a single bit ( for example Regarding the state itself, my idea was that splitting the functions into their separate actions would allow the process running the FSM module to perform direct calls to matching sections, without several And I was wondering if passing the full state only to the top level function, would not be more memory-efficient since it would allow passing only the necessary variables to matching functions called subsequently. My idea behind this would be to actually try to run an Antidote node on a GRiSP board, but at this time I have not yet deployed such a release so I cannot tell for sure and I am a bit unfamiliar with the Thanks for your reply ! Igor |
I think you cannot get smaller than an atom in Erlang. According to http://erlang.org/doc/efficiency_guide/advanced.html an Atom takes up 1 word, whereas a binary takes at least 3 words.
The state is not copied when it is passed as a parameter. Terms only have to be copied when they are sent to other processes. |
In fact you are completely right. After doing a bit of RTFM about binary constructions, I might go for a different approach but I am not yet 100%. I will probably do some tests using binary generators to construct the full state as in :
And I will see if anything interesting is noticeable 🙂 Thanks ! |
If you are looking for opportunities to save memory, there are some other things I would look at before going into micro optimizations like using binaries. For example:
It's probably a good idea to profile memory usage before doing any optimizations. |
Thank you very much for your insights ! 🙂 I will se if I can eventually contribute with something useful ! Best, Igor |
Hello 🙂
I have a quick question regarding the
prepare_done/2
function. More specifically, looking at this line, I was wondering if it would not be interesting to refactor the function such that :If I understand correctly, this could perhaps be a way to avoid passing the full state of the FSM across all helper functions and matching on multiple clauses in a single function with a
case
statement. I have not tested it but I was wondering if this might be a possible improvement ?Igor
The text was updated successfully, but these errors were encountered: