# Tuning performance

## Representation minimization

The Curve data structure is based on the UPP property which enables to represent a function $f(t)$ for non-negative rationals $Q^+$ by storing only a finite representation for $[0, T+d[$. However, it is not guaranteed that such representation is the most efficient, i.e. the same $f(t)$ may be represented with smaller $T$ and/or $d$. This is more so true for results of operators, since they are based on general proofs which are agnostic to the patterns and properties of operands and results, leading to a growth in the memory occupation and time complexity of subsequent operations.

To address this issue, Nancy implements an a posteriori optimization algorithm that will simplify the result of an operator to the minimal representation for the same $f(t)$. This algorithm is presented in detail in [ZS23].

## Parallelization

Nancy uses C#'s PLINQ feature which allows to easily parallelize independent computations over large sets, exploiting performance of multicore processors.

## Settings

Most operators will have as a last optional argument a ComputationSettings object, that is used to tune how the operator is computed.

The most relevant settings are AutoOptimize, which will apply representation minimization to all results (also intermediate ones) and UseParallelism, which will use parallelization when is (heuristically) deemed to be useful.
Both are set by default to `true`

.

Below, an example which runs the min-plus convolution in serial mode.

` var f = ...;`

var g = ...;

var h = Curve.Convolution(f, g, settings: ComputationSettings.Default() with { UseParallelism = false });