Newsletter

What happens when a STEM model runs

31 July 2013

Although not an essential system requirement, an SSD will be included in our ideal system specification in future.

In a recent support interaction involving delays running a huge model, we were asked exactly what happens behind the scenes when you press <F5> to update the results charts according to the latest changes in the Editor. The client was keen to understand which processes, memory and disk accesses were involved to determine why the very same model ran dramatically faster on one of our machines at Implied Logic.

What follows is a more or less verbatim copy of our response, edited only for context and to remove any personal or client-identifiable data. However, the recommendation about the potentially significant advantages of SSD over HDD is entirely universal and a strong factor in our decision to circulate this more widely.

The detailed modelling context

The model in question explores cost dynamics in a national transmission network and utilises multiple templates and scenarios. Detailed cost reporting is enabled at the service–resource level by setting Cost Allocation = Transparent in the global Other Details dialog and this significantly increases the size of the results file to well over 0.5 GB per scenario.

A simulation of this size is always going to take some time to process, but the alarm bells rang when we reported a round trip of eight minutes against the client’s experience of four hours! Our hardware was known to be both newer and more powerful than the client machine, but not to such an extent as to explain a thirty-fold difference! In order to explain the discrepancy, we felt it was both necessary and insightful to explain more specifically what STEM does at run time. We were thus able to make a very specific recommendation to improve the model-run experience for our client.

Step by step, a model run with STEM

In order to shed light on the apparent memory and CPU usage, here is a slightly idealised explanation of what happens when you run a model from the Editor:

  1. the Editor, ed.exe, first checks and then saves the model (.dtl, .dtm and .icp files)
  2. it then asks the core STEM process, stem.dll, to orchestrate the model run, which involves a sequence of intentionally-separate processes, all of which for mostly cosmetic reasons remain hidden and report their status via the Editor window if it is present (which is why the Editor will never look very busy or memory hungry in Task Manager)
  3. if scenarios are required, then:
    1. the standalone model compiler, dtlcompw.exe, loads the working model, applies the requested scenarios in memory and then saves the separate per-scenario .dtm files in turn in the <model name>.scn folder
    2. the standalone checker, chkmodlw.exe, checks each of the requested scenario files
  4. if replication is required, then:
    1. the standalone model compiler, dtlcompw.exe, loads the working model and each scenario in turn, processes the templates, and then saves the corresponding per-scenario .exp.* files
    2. the standalone checker, chkmodlw.exe, checks each of the generated .exp files
  5. the working model and each scenario are run in turn:
    1. the model engine, model.exe, does all of the calculations, proceeding one period at a time, saving all of the results for each successive period sequentially in a .rmr (raw model results) file
    2. the results sorter, smrsortw.exe, reads the successive values in time for each element and result by random access from the .rmr file and then writes each corresponding element–result vector as a contiguous block in the .smr (sorted model results) file to provide acceptable on-demand access to the results
  6. the results program, results.exe, loads the updated results:
    1. for the working model and each scenario:
      1. the updated inputs are loaded from the .dtm and matched against any previous existing record of the set of element names of each type, either from a .smw file on first load, or from the previous results in memory
      2. the lists for each type of element are augmented with items corresponding to each homogeneous collection of elements of the same type
      3. when cost allocation is enabled, the list of service/transformation–resource pairs is augmented with items corresponding to the relevant element–collection and collection–collection pairs
    2. results are accessed on demand from the .smr, and from derived results calculated in memory, as required, to update pre-existing charts and when drawing graphs interactively.

Note: part of the complexity of this approach comes down to a trade-off between memory and disk usage, the need to serialise the processing of scenarios when handling very large datasets, and a general principle of using operating-system enforced process isolation to reliably modularise the system into a small number of individually verifiable tasks.

The consequent advice

The first observation is that merely updating results charts in situ can take a significant time if the number of ‘elements’ has been radically increased by enabling service–resource cost reporting. Step 6.a.i above is significantly faster if there is no .smw file to match against (i.e., you temporarily hide the results workspace), and will be faster also if you are prepared to close the results before each subsequent model run. This does not mean ‘never save a workspace again’, it simply provides a shortcut when debugging.

Our second observation is that you can see why step 5.b will become a performance bottleneck if the .rmr file exceeds the size of the disk cache as it most certainly would in this example. So our recommendation was that, if you do not have an SSD now, then you should request a suitably-equipped replacement machine urgently. Implied Logic has used SSD-based laptops for all modelling and software work from January 2011 and it makes a huge impact on every aspect of computer performance from boot time onwards.

Free subscription when we review your business model

How well do you understand your business? It may be profitable now, but how prepared are you for this to change? We have a track record of analysing individual services or entire businesses in an interactive workshop style that engages and informs. Our visual software enables multi-disciplinary dialogue about the business you thought you knew and the more uncertain future ahead.

Read the article

STEM User Group Meeting 2017 proceedings

Our most recent customer event was held on 27–28 September 2017 at King’s College, Cambridge. The modelling track explored three growth models for a start-up business, from unconstrained to measured to driven. The remainder of the event covered the forthcoming STEM version 8.0, the revised business model for Implied Logic, and two guest presentations.

Read the article

A freshly baked model of a start-up

We examine Michaela’s Best Bread Direct service, from her first unconstrained vision, through a more realistic measured phase and finally to a more ambitious, customer-driven approach. We demonstrate how STEM can be applied to almost any business topic and always delivers a systematic and reliable treatment of time and money.

Read the article

Business-case design and training at your service

Ever wondered what we do at Implied Logic? We have recently posted a comprehensive update to our services portfolio online which is effectively a self-service proposal for everything from online training on-demand through to on-site business-modelling consulting and hosting services for business models on the web.

Read the article

Connecting elements to graphs and publishing online

In what is likely to be the final preview article for the forthcoming STEM version 8.0, we explore visual connections between individual icons and a related graph, as well as intuitive, interactive options for adding an element to an existing graph. We also explore new layout options for pushing a presentation of results in STEM to the web.

Read the article

Our latest help and training materials

Documentation is never regarded as a very exciting activity, but our comprehensive help and training materials are a vital element of the self-serve experience with STEM. In the last quarter we have posted two significant updates to our online help site which enhance both of these aspects.

Read the article

A radical re-think on STEM pricing

We announce a new freemium strategy for accessing the STEM software, including a free and fully-functional demo system for small projects and study as a taster for an innovative minimal-support subscription to the Conventional STEM (C-STEM) desktop solution at just GBP 330 p.a..

Read the article

Vision for the forthcoming STEM 8.0

As part of our vision for a more intuitive way of working that bridges previous mental leaps wherever possible, we preview another two features of the forthcoming STEM version 8.0 – direct-draw connect mode and more flexible user data – that form part of a joined-up approach to fulfilling this dream.

Read the article

       Buy SSL

© Implied Logic Limited