Skip to content

Conversation

@sebastienros
Copy link
Contributor

@sebastienros sebastienros commented Aug 22, 2025

image

This is the flamegraph before the fix. I could see that all the time was spent in creating parse nodes and initializing their structures (ToDictionary, CharMap, ...). This is not normal, this should be done once. This meant that the parsers were begin constructed too often. The parser should be a singleton, unless some grammars vary in terms of syntax, but not behavior.

The solution is to incorporate the ParseContext which is specific to each invocation. And the parser lambdas can use it. This way the parser can be static. I used a local Instance field but I usually create my own static parser instance that I reuse. Totally fine how I did it here. Makes it more obvious for the future.

@sebastienros
Copy link
Contributor Author

I also changed the benchmarks slightly to move the initialization code out of the hot path so the results only focus on what matters. And returned the resulting expression such that the compiler would not optimize the method as the result is not used (it is not but it's a best practice for BDN usage).

@sebastienros
Copy link
Contributor Author

Are the tests flaky? I don't even get the same failing ones locally. I can already see a problem due to timezones, but I don't get why the others are different.

@lukemurray
Copy link
Collaborator

Thank you very much for this!

Yes that 1 test fails sometimes. I need to track down why - it includes all the fields just a different order, which typing this out actually might make sense depending on how tests run and I should check it with regardless of order.

@lukemurray lukemurray merged commit c9dc615 into EntityGraphQL:master Aug 23, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants