-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
simulation improvements / discussion #2736
Comments
What are you referring to as optimizations at the expense of code clarity? |
Broadly, I agree with all the bulleted suggestions. I think we could also more clearly separate out the "Tendermint simulation" part from the "state machine fuzzer" part, clean up I do not agree that code clarity is worth sacrificing performance - more performance means more state space covered by the simulation (and more of the real state machine being tested). I also don't think code clarity and performance are necessarily at odds - are there particular instances where you think we could only gain clarity at the expense of performance? |
There must be a way to have best of both worlds. We just need to strike a balance 💯 |
Maybe I am incorrect in thinking that some of the structure which I saw is for optimization. Some of the operations I understood from a brief previous discussed with @cwgoes had to do with taking multiple pieces of logic and grouping them together with function variables to avoid having to allocate more memory. aka stuff like:
In certain circumstances it's possible that maybe there is a code structure which is less nested/spagetti which is less efficient but we should probably just be using for clarity purposes. HOWEVER I do agree with @alexanderbez that there probably is a way to get both efficiency and clarity - I just strongly feel that we should favour clarity over minor losses in performance, and then use that as a starting place to work towards greater performance. Here I would define a minor loss in performance as maybe doubling computational time (so maybe this is were opinions diverge @cwgoes). Again this is a simulation not a live network, so we can give ourselves a bit more leeway than would otherwise be acceptable CC @ValarDragon |
@fedekunze just completed a simulation refactor. Going to close this issue as addressed. Please reopen with actionable items if applicable. |
The only thing left is to split the core simulation into multiple pieces. Not high priority tho |
ideas of how to improve the simulation (living issue) code from a code clarity perspective (aka not feature dependant)
x/mock/simulation/simulation.go
) there is a "master" simulation functionSimulateFromSeed
- this function is ~200LOC and should probably be broken up into 3-5 functions for better code comprehension, I imagine the contents of that giant loop should be broken out for example.x/mock/simulation/event_stats.go
) - this could be further extended with an interfaceSide note, I know that currently there are many operations within the simulator which are heavily optimized, however at the expense of code-clarity. We need to strike a balance here between performance and comprehension - I think that as this is a simulation, we should focus of code clarity for overall structure, and focus on adding new features to improve performance (such as the ability to save the state and start running the simulation from a certain block)
CC @cwgoes
The text was updated successfully, but these errors were encountered: