Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::string parameters for debug::indent() and debug::dedent() in generated code #1591

Closed
awelzel opened this issue Nov 10, 2023 · 1 comment · Fixed by #1590
Closed

std::string parameters for debug::indent() and debug::dedent() in generated code #1591

awelzel opened this issue Nov 10, 2023 · 1 comment · Fixed by #1590
Assignees

Comments

@awelzel
Copy link
Contributor

awelzel commented Nov 10, 2023

Separate follow up to #1589 . Looking at the generate code for the following grammar:

type K = unit {
  x: skip bytes &size=1;
};

type L = unit {
  k: K;
};

type M = unit {
  l: L;
};

public type N = unit {
  : M[] &eod;
};

There's a number of indent() and dedent() calls generated involving std::string instances being constructed at runtime. These are pretty short strings so they shouldn't involve an allocation and might be optimized well, but might still be sensible to not even construct them.

    try {
        ::hilti::rt::debug::indent(std::string("spicy"));
        std::optional<::hilti::rt::stream::SafeConstIterator> __begin = std::make_optional(__cur.begin());


    ::hilti::rt::debug::dedent(std::string("spicy"));

A flamegraph indicates ~3.3% samples falling into basic_string functions.

flame

Screenshot-20231110-120557

Unfortunately I don't have the means to provide before-after here.

@awelzel
Copy link
Contributor Author

awelzel commented Nov 10, 2023

Unfortunately I don't have the means to provide before-after here.

I used the approach from #1593 and #1592 simply commenting out the debug::dedent and debug::indent calls in the generated code and then re-building. Removes ~10% of runtime for that particular reproducer.

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

Successfully merging a pull request may close this issue.

2 participants