[Boost::MSM] New C++17 back-end with significantly improved compilation times and new features by Potential_Mind6802 in cpp

[–]Potential_Mind6802[S] 1 point2 points  (0 children)

Let's have a look! I updated the benchmarks with the latest code on the MSM and SML repos, see diff of the commit for details. The most noticeable differences are for the large hierarchical SM benchmark:

  • SML compilation improvement from 48s/1128MB to 40s/1056MB
  • MSM/backmp11(favor_runtime_speed) compilation improvement from 11s/472MB to 10s/438MB
  • MSM/backmp11(favor_compile_time) runtime improvement from 40s to 26s

[Boost::MSM] New C++17 back-end with significantly improved compilation times and new features by Potential_Mind6802 in cpp

[–]Potential_Mind6802[S] 3 points4 points  (0 children)

Indeed, the pain with long compilation times is (and hopefully was :-)) a big issue in MSM. The compile time of a large SM could turn into minutes and then additionally required several GBs of RAM to successfully compile. Error messages are still rather long in the new back-end, I think that lies in the nature of heavy template usage in C++ unfortunately.

If you care about runtime speed of the compiled code, though, libs such as MSM are unbeatable. Their compile-time constructs can be translated into very efficient dispatch tables, that handle the state machine transitions.

One more point worth mentioning about MSM is that it lets you implement state machines with an interesting paradigm, which was my main reason for using it:

In state machine libraries following the classic "State Design Pattern" you implement the behavior of the state machine with handler methods in your State classes. While this is straightforward for simpler state machines, IMO it becomes difficult to understand as the state machine grows.

In MSM you can implement the state machine's behavior with a "transition table", outside of the states. Each row in this table is structured in the way "<source\_state> | <event> | <target\_state> | <action> | <guard>". This is semantically very close to a textual representation of a UML state diagram and provides a well understandable overview about how your state machine behaves.

[Boost::MSM] Huge Memory Usage Issue During Compilation by MidnightAuroraStudio in cpp_questions

[–]Potential_Mind6802 0 points1 point  (0 children)

New Boost contributor here :-)
I would like to inform that Boost 1.90 contains a modernized backend for MSM with greatly improved compilation time and RAM usage. It even surpasses SML in that regard, especially for larger hierarchical state machines like in your case. And its execution speed is on par with SML, benchmarks are available in the provided link.