swirec_optimization

Optimization level for the grammar.

Value

Integer: 0–12 (but not 10).

Default

6 (for dynamic compilations)

How to set

In a grammar using a <meta> tag. See the text on compilation-time parameters in Parameters set in grammar files.

Usage

Tunes performance of each grammar depending on the grammar’s size and coverage, and whether the grammar is precompiled or compiled at run-time.

Performance

Each level has advantages or disadvantages regarding compilation time, recognition time, and recognition accuracy.

You can optimize frequently-used grammars to minimize computation required for recognition. To avoid unnecessary optimization processing, do not optimize grammars that are only used once.

Here is a summary of optimization levels. Use it as a general guideline for the trade-off between compilation time and runtime recognition time. In situations where the trade-off is important, verify the costs for specific grammars:

Level

General behavior

0-3

Compilation is faster. Runtime recognition is slower.

4-6

Compilation is slower. Runtime recognition is faster.

Level 6 is the default for dynamic compilations.

7-9

Compilation is slower. Runtime recognition is possibly faster.

Level 9 is the default for manual compilation unless a different level appears in the command line. This default assumes that fast runtime recognition is the highest priority for most situations, and conversely that a longer compilation time is not a problem. If you prefer another default, set swirec_optimization in the grammar.

10

Reserved. Do no use.

11

Compilation is faster. Runtime recognition is slower.

Restrictions: do not mix optimization level 11 with other levels when importing grammars. That is, a grammar optimized at 11 cannot import a grammar optimized at another level, and a grammar optimized at another level cannot import a level 11.

12

Compilation is faster and output file is compressed.

Level 12 is for very large grammars (for example, SLMs) where the compilation speed and output size are considerations. Grammars will compile faster, and will use less memory during compilation than levels 9 and below. The output file is compressed to about 50% of a file optimized with level 9.

Restrictions: do not use level 12 on smaller grammars. This level tends to degrade their accuracy and increase their runtime CPU usage. (These degradations do not occur for large grammars.)

Sample definition in a grammar file:

<meta name="swirec_optimization" content="8"/>

Related parameter