You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<text:ptext:style-name="TOC_Item"><text:axlink:type="simple"xlink:href="#tableofcontents"text:style-name="Index_20_Link"text:visited-style-name="Index_20_Link">Table of Contents <text:tab/>1</text:a></text:p>
<text:ptext:style-name="Standard">To improve performance, MMD has the option to allocate the memory for the
916
+
tokens used in parsing in large chunks (“object pools”). Allocating a single
917
+
large chunk of memory is more efficient than allocating many smaller chunks.
918
+
However, this does complicate memory management.</text:p>
919
+
920
+
<text:ptext:style-name="Standard">By default <text:spantext:style-name="Source_20_Text">token.h</text:span> defines <text:spantext:style-name="Source_20_Text">kUseObjectPool</text:span> which enables this performance
921
+
improvement. This does require more caution with the way that memory is
922
+
managed. (See <text:spantext:style-name="Source_20_Text">main.c</text:span> for an example of how the object pool is allocated and
923
+
drained.) I recommend disabling object pools unless you really understand C
924
+
memory management, and understand MultiMarkdown’s program flow. Failure to
925
+
properly manage the object pool can lead to massive memory leaks, freeing
926
+
memory before that is still in use, or other potential problems.</text:p>
<text:ptext:style-name="Standard">Most HTML attributes are of the key-value type (e.g. <text:spantext:style-name="Source_20_Text">key="value"</text:span>). But some
931
+
less frequently used attributes are boolean attributes (e.g. <text:spantext:style-name="Source_20_Text"><video<text:line-break/>controls></text:span>). Properly distinguishing HTML from other uses of the <text:spantext:style-name="Source_20_Text"><</text:span>
932
+
character requires matching both types under certain circumstances.</text:p>
933
+
934
+
<text:ptext:style-name="Standard">There are some trade-offs to be made:</text:p>
935
+
936
+
<text:listtext:style-name="L1">
937
+
<text:list-item>
938
+
<text:ptext:style-name="Standard">Performance when compiling MultiMarkdown</text:p></text:list-item>
939
+
940
+
<text:list-item>
941
+
<text:ptext:style-name="Standard">Performance when processing parts of documents that are <text:spantext:style-name="MMD-Italic">not</text:span> HTML</text:p></text:list-item>
942
+
943
+
<text:list-item>
944
+
<text:ptext:style-name="Standard">Accuracy when matching HTML</text:p></text:list-item>
945
+
946
+
</text:list>
947
+
948
+
<text:ptext:style-name="Standard">So far, there seem to be four main approaches:</text:p>
949
+
950
+
<text:listtext:style-name="L1">
951
+
<text:list-item>
952
+
<text:ptext:style-name="Standard">Ignore boolean attributes – this is how MMD-6 started. This is fast, but
953
+
not accurate for some users. Several users found issues with the <text:spantext:style-name="Source_20_Text"><video></text:span> tag
954
+
when MMD was used in HTML heavy documents.</text:p></text:list-item>
955
+
956
+
<text:list-item>
957
+
<text:ptext:style-name="Standard">Use regexp to match all boolean attributes. This is fast to compile, but
958
+
adds roughly 5–8% processing time (probably due to false positive HTML
959
+
matches). This <text:spantext:style-name="MMD-Italic">may</text:span> cause some text to be classified as HTML when it
960
+
shouldn’t.</text:p></text:list-item>
961
+
962
+
<text:list-item>
963
+
<text:ptext:style-name="Standard">Explicitly match all possible boolean attributes – This would presumably be
964
+
relatively fast when processing (due to the nature of re2c lexers), but it may
965
+
be prohibitively slow to compile for some users. As someone who compiles MMD
966
+
frequently, it is too slow to compile be useful for me during development.</text:p></text:list-item>
967
+
968
+
<text:list-item>
969
+
<text:ptext:style-name="Standard">Use a hand-curated list of boolean attributes that are most commonly used –
970
+
this does not incur much of a performance hit when parsing, and compiles
971
+
faster than the complete list of all boolean attributes. For now, this is the
972
+
option I have chosen as default for MMD – it seems to be a reasonable trade-
973
+
off. I will continue to research additional options.</text:p></text:list-item>
0 commit comments