Skip to content

perf: dedupe the 2-3x per-module frontmatter YAML parse #383

Description

@dean0x

Context

Surfaced by #162 (bound frontmatter YAML parsing). The same frontmatter block is
parsed 2-3 times per compile of a module: build_scope_from_frontmatter,
parse_frontmatter_mapping (feeds @extends), and the lint facts pass
(collect_frontmatter_vars). Each parse now flows through the bounded
parse_frontmatter_yaml choke point, so each pays the full bounded parse
(size cap + node-budget deserialize + pre-parse flow-depth scan).

Not a correctness or security issue

The bounds from #162 are enforced identically on every parse — this is purely a
redundant-work perf refactor, not a safety gap.

Proposal

Parse the frontmatter once and thread the already-parsed
serde_yaml_ng::Value through the callers, e.g. have
resolver.rs::build_scope_from_frontmatter accept a parsed Value instead of
re-parsing the raw string, and reuse it for the @extends mapping and the lint
facts pass. Cost/benefit scales with MAX_MODULE_COUNT.

References

Refs #162

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions