Debugging Constraint Modeling Language (CML)

For optimal performance with CML, follow the performance guidelines and use debug logging to debug constraint models.

Follow these performance guidelines to prevent performance issues.

MetricOptimalmarginalcritical
Total Execution Time<100 ms100 ms–1 s>1 s (10 s = hard timeout)
Backtracks<1,0001,000–10,000>10,000
Constraint Violations01–100>100
  • Asset count impact: Configurations with 2,500 or more assets can experience noticeable evaluation delays. Keep asset counts below this threshold, or expect longer execution times as the count grows.
  • OR-chain overload: Long chains of OR conditions force the engine to explore many alternative paths, which drives up backtracks and execution time. Refactor these rules using boolean intermediary variables that consolidate the conditions, so the engine evaluates a single flag instead of rechecking every branch.
  • Domain range reduction: Narrow the range of values a variable can take to give the engine fewer possibilities to test, cut backtracks, and speed up constraint solving. Apply tighter bounds, remove unreachable values, and split broad domains into smaller sets so the solver converges faster.

To debug constraint models and troubleshoot performance issues, turn on debug logging in Apex and set the debug log level to FINE. For more information on debug logging in Salesforce, see these topics in Salesforce Help:

Use the Apex log to get information about constraint rules engine performance when running a constraint model, including performance degradation or unexpected behavior. To improve performance, modify the constraint model based on information in the log.

For tips on writing trouble-free CML, see Constraint Modeling Language (CML) Best Practices.

  • About the Apex Debugging Log File

    The Apex debugging log file contains three sections: RLM_CONFIGURATOR_BEGIN, RLM_CONFIGURATOR_STATS, and RLM_CONFIGURATOR_END.

  • Use the Apex Debugging Log File

    To find possible reasons for the performance problems and identify solutions, look at the RLM_CONFIGURATOR_STATS section of the log file.