Skip to content

Improving performance #198

Closed
Closed
@hukkin

Description

@hukkin

Describe the problem/need and solution

Problem / Idea
According to updated benchmark results (#196) mistletoe beat us. This is embarrassing. Haha, no, hats off to mistletoe authors!

Solution
The profiler (#197) reveals that we spend a significant portion of execution time, around one third, converting string characters to ints here.

As we've researched before, this is a performance hack in upstream JavaScript, but for us it hurts performance in a major way. It also makes the code slightly less readable. We've already resorted to caching these int sequences (diverging from JS upstream), which is basically a performance hack on top of a failed performance hack, where as a result performance still suffers. I'd be interested to move to using the str type only.

The naive way to implement this will break basically all parser extensions I believe (mdit-py-plugins). What we could do is a deprecation period for srcCharCode, where:

  • the core library moves to using src for increased performance
  • accessing srcCharCode emits DeprecationWarnings
  • srcCharCode is generated lazily, only when accessed. This means that the performance loss only occurs when using deprecated extension, not when using core markdown-it

Benefit
Increased performance.

Guide for implementation

No response

Tasks and updates

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions