Why Monitor Computational Cost?
A MICE run can be statistically appropriate and still be impractical to execute, store, or repeat. A configuration that completes quickly on a small test data set may exceed a job’s time limit, compete for memory with other processes, or create output too large to retain and transfer. Monitoring computational cost makes these constraints visible before a full analysis depends on a run.
The objective is not to find one universal runtime formula. Cost depends on data dimensions, predictor structure, imputation methods, the number of imputations and iterations, software implementation, hardware, and concurrent workload. Instead, measure the actual workflow under controlled conditions, compare relevant configurations, and treat any extrapolation as an estimate to be checked.
Designing a Useful Benchmark
A benchmark is informative only if the runs being compared differ in the intended configuration rather than in uncontrolled conditions. Use the same input data, preprocessing, code path, output-retention rules, computing environment, and measurement method wherever possible. Record the configuration being tested, including the number of imputations \(m\), iteration count, number of rows and variables, and any parallel-processing settings. Record enough run identity and environment information to reproduce the comparison; a measured number without its conditions is difficult to interpret.
Measure elapsed wall-clock time when the practical question is how long a job takes to finish. CPU time is useful for understanding processor use but can exceed elapsed time for parallel work. For memory, record a process-level peak or a clearly defined alternative, such as the maximum resident set size. A final memory reading is not a peak: a run may allocate much more memory temporarily and release it before completion. Measure the saved output on disk after the same serialization and compression steps for every configuration.
Repeat each benchmark when feasible. Timing varies because of operating-system scheduling, competing jobs, cache state, and other transient conditions. Report the individual observations and a summary such as the median, rather than presenting one unusually fast run as the expected runtime. If repeated timings vary substantially, investigate the environment or increase the number of repetitions before using them to set a tight limit.
A useful benchmark also reflects the workflow that will actually be run. A test that omits saving results cannot estimate the time or storage required for saving. Conversely, including unrelated setup or data transfer in only some configurations makes their runtimes incomparable. Decide what the measurement includes, then apply that definition consistently.
Worked Example: Comparing Two Run Configurations
Suppose a hypothetical benchmark compares two MICE configurations on the same data and machine. Configuration A uses \(m=10\) imputations and 20 iterations; its three elapsed times are 42, 45, and 43 seconds. Configuration B uses \(m=20\) and 20 iterations; its times are 84, 86, and 91 seconds. Assume the runs used the same input and output procedure and that no benchmark experienced an obvious interruption.
For A, the ordered times are 42, 43, and 45 seconds, so the median is 43 seconds. For B, they are 84, 86, and 91 seconds, so the median is 86 seconds. The ratio of median times is
Thus B took twice as long as A in these benchmark conditions. A rough descriptive rate per imputation-iteration is \(43/(10\times20)=0.215\) seconds for A and \(86/(20\times20)=0.215\) seconds for B. This agreement is consistent with runtime roughly doubling when \(m\) doubles in this comparison; it does not prove that runtime will always be exactly proportional to \(m\). The conclusion is limited to the tested data, settings, and environment.
Interpreting Memory and Output Measurements
Memory use is especially important because a run can fail abruptly when the process or host reaches a memory limit. Distinguish the memory attributed to the MICE process from total system memory, and distinguish peak use from memory remaining after the run. If several jobs run concurrently, each job’s peak alone does not describe whether the combined workload fits on the machine.
A rough raw-storage calculation can help explain why saved results grow, but it is not a substitute for measurement. If \(n\) rows each have \(p\) numeric values in each of \(m\) completed data sets, and each value is stored as an 8-byte number, the values alone require approximately \(8npm\) bytes. This omits the original data, object metadata, other stored run components, temporary copies, and compression effects. Actual memory and serialized file size can therefore differ substantially from the raw-value calculation.
Worked Example: Checking a Raw Storage Estimate
Consider a hypothetical run with \(n=4{,}000\) rows, \(p=25\) numeric variables, and \(m=20\) completed data sets. The stored numeric values alone have a raw size of
Here, \(1\text{ MiB}=1{,}048{,}576\) bytes, so \(16{,}000{,}000/1{,}048{,}576\approx15.3\). Suppose the measured process peak is 310 MiB and the saved run object is 38 MiB. These observations are not inconsistent with the raw estimate: the peak includes more than the final completed numeric values, while the serialized output may use a different representation and compression. For planning, use the measured 310 MiB peak and 38 MiB file size under the specified conditions, not 15.3 MiB as if it were the full resource requirement.
Using Pilot Runs to Plan Resource Limits
A pilot run can estimate the cost of a larger configuration, but the estimate requires a scaling assumption. For example, when the data structure and methods are held constant, computational work may increase with \(n\), \(m\), and the number of iterations. This does not imply exact linear scaling: model-fitting costs, predictor counts, convergence behaviour, object creation, parallel overhead, and memory allocation can all change the relationship.
One simple approach is to fit a local linear approximation to measurements from two pilot sizes. Let \(T\) denote elapsed seconds and use \(n m I\) as a rough workload index, where \(I\) is the iteration count. With measurements \(T_1,T_2\) at indices \(W_1,W_2\), the fitted slope is \((T_2-T_1)/(W_2-W_1)\), and the intercept is \(T_1-\text{slope}\times W_1\). This is a planning device, not a general MICE complexity result. The estimate is most defensible near the measured range and when other settings are fixed.
Worked Example: Checking a Proposed Resource Budget
In a hypothetical pilot with the same predictor structure and methods, a run with \(n=1{,}000\), \(m=10\), and \(I=20\) takes 12 seconds. A second run with \(n=2{,}000\), \(m=10\), and \(I=20\) takes 21 seconds. Their workload indices are \(W_1=1{,}000\times10\times20=200{,}000\) and \(W_2=2{,}000\times10\times20=400{,}000\). The local time slope is
The fitted intercept is \(12-(0.000045\times200{,}000)=3\) seconds. For a proposed run with \(n=6{,}000\), \(m=20\), and \(I=30\), the index is \(3{,}600{,}000\). The estimated time is \(3+(0.000045\times3{,}600{,}000)=165\) seconds, or 2.75 minutes. The proposal is an 18-fold increase in this workload index over the first pilot, so the estimate is a substantial extrapolation and should be treated cautiously.
Suppose measured peak memory for the two pilots is 1.2 GiB and 1.7 GiB. A separate local model using \(n m\) gives a slope of \((1.7-1.2)/(20{,}000-10{,}000)=0.00005\) GiB per row-imputation unit and an intercept of \(1.2-(0.00005\times10{,}000)=0.7\) GiB. For the proposed \(n m=120{,}000\), this model estimates \(0.7+(0.00005\times120{,}000)=6.7\) GiB. If the saved output was 24 MiB at the first pilot and output size is provisionally assumed to scale with \(n m\), its rough estimate is \(24\times(120{,}000/10{,}000)=288\) MiB.
Now suppose the job has a 10-minute time limit, the machine has 12 GiB available for this work, and the workflow reserves 25% of that memory for other processes and uncertainty. The planned memory allowance is \(12\times0.75=9\) GiB. The pilot-based estimates of 165 seconds, 6.7 GiB, and 288 MiB fall below the 600-second time limit, 9-GiB allowance, and a hypothetical 1-GiB output limit. This does not guarantee success: the time estimate extrapolates well beyond the pilots, and the memory and output models are approximate. An intermediate-size pilot would provide a useful check before committing to the full run.
Diagnostics, Alternatives, and Failure Modes
Treat a benchmark as suspect if repeated measurements vary greatly, if a run is interrupted or shares the machine with unrecorded workloads, or if the observed memory peak is implausibly lower than the memory required by the known data objects. Check that the measurement covers the same stages in every run. A file-size comparison is not fair if one configuration saves completed data sets while another saves a larger run object, or if compression differs.
For a practical workflow, set explicit limits before the full run: a maximum elapsed time, a memory allowance below the host or scheduler limit, and a storage allowance for outputs and temporary files. Keep headroom rather than planning to use every available byte or second. Use a smaller pilot to discover obvious failures, then a more representative pilot to check scaling. If a run approaches a limit, reduce workload only through a deliberate configuration decision and preserve the configuration and results needed to understand what was run.
Different assessment approaches answer different questions. A one-off timed run is quick but vulnerable to random variation. Repeated benchmarks with medians better describe typical performance but still may not reflect production contention. Analytic raw-size calculations are transparent and useful as lower-level checks, but omit implementation overhead. Pilot-based extrapolation reflects the actual software and data more closely, but is unreliable far outside the measured range. Profiling can identify where time or memory is spent, but can add overhead and may not be necessary for routine resource planning.
The main limitation is that cost is configuration- and environment-specific. Changes in predictor structure or imputation methods can alter computation even when \(n\), \(m\), and iteration count are unchanged. Parallel execution may reduce elapsed time while increasing total CPU use or memory pressure. Compression and saved-object contents affect output size. Therefore, report estimates as estimates, retain the measurements and conditions behind them, and re-benchmark when material parts of the workflow change.
Specify whether time includes setup and saving, how peak memory is measured, and which outputs are included in file size.
Hold the data, environment, workflow stages, and measurement process constant; vary the configuration of interest and repeat runs where feasible.
Use pilot measurements to estimate larger-run costs, state the assumptions, and validate substantial extrapolations with an intermediate run.
Compare estimates with time, memory, and storage allowances, then preserve the benchmark details and observed outcomes.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A run has elapsed times of 31, 35, and 32 seconds. What is the median, and why is it preferable to selecting the fastest time as the planning value?
- A raw-value estimate is \(8\times20\times5{,}000\times30\) bytes. Compute the size in bytes and explain why it is not necessarily the process’s peak memory.
- Two pilots have workload indices 100,000 and 200,000, with runtimes 8 and 13 seconds. Using a linear model with an intercept, estimate runtime at workload index 300,000.
- A projected peak is 7 GiB, while a machine has 10 GiB available and the plan reserves 20% for other processes and uncertainty. Does the projected peak fit the planned allowance?
Solutions. (1) The ordered times are 31, 32, and 35 seconds, so the median is 32 seconds. It is less affected than the fastest observation by a particularly favourable scheduling or system condition. (2) \(8\times20\times5{,}000\times30=24{,}000{,}000\) bytes, or about 22.9 MiB. This counts only the specified raw values; other objects, metadata, and temporary copies can raise peak memory. (3) The slope is \((13-8)/(200{,}000-100{,}000)=0.00005\) seconds per index unit. The intercept is \(8-(0.00005\times100{,}000)=3\) seconds, so the estimate is \(3+(0.00005\times300{,}000)=18\) seconds. (4) The planned allowance is \(10\times0.80=8\) GiB. A 7-GiB estimate fits, leaving 1 GiB of planned allowance, though the estimate remains uncertain and should not be treated as a guarantee.