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

Workaround for GC issues in interpreter specs #11634

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Dec 21, 2021

This patch prevents the GC issues in interpeter specs (#11580) as suggested as second option in #11602

The implementation hooks into Specs option parser in order to add an alternative operation mode for the spec executable which works as an interpreter implementation that meets the specific needs of spec execution. This is a bit dirty, but I think it's acceptable as a temporary solution. It's definitely the fastest solution because it doesn't require an extra compiler build (neither explicitly nor implicitly). Everything necessary is already available in the spec executable, it just needs a way to expose that so it can be called externally.

Now the interpreter specs execute in 2:22 minutes (on my machine) and takes about 3.3 GB of memory. Previously, it took forever and claimed all the memory 😈

With this change (and #11624merged by now), the test_interpreter job in CI should succeed again. I'm merging that and enabling CI in this branch to verify that. But it doesn't need to be merged with it. #11624 should obviously be merged on its own. I don't see a reason to delay enabling CI, but we might want to merge an explicit revert of #11623.

Resolves #11602
Reverts #11623

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs topic:compiler:interpreter labels Dec 21, 2021
@straight-shoota straight-shoota force-pushed the feature/i-integration-specs branch from 84a76f3 to 137e692 Compare December 22, 2021 16:10
@straight-shoota straight-shoota marked this pull request as ready for review December 22, 2021 17:00
Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two really minor comments.

end

def interpret_with_context(code, *, prelude = "primitives")
def interpret_with_context(code, prelude = "primitives")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to make this one private to avoid shooting ourselves in the foot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't make this helper private, because it's used in specs when it needs access to the context, instead of just the value.
But I suppose we can remove the prelude parameter to fix it to "primitives".

spec/compiler/interpreter/spec_helper.cr Show resolved Hide resolved
@beta-ziliani
Copy link
Member

I think we should merge this re-enabling CI, explicitly stating that it reverses #11623. I think a specific revert to it adds some bureaucracy without any real gain.

@beta-ziliani
Copy link
Member

Nice, thanks!

@beta-ziliani beta-ziliani added this to the 1.3.0 milestone Dec 30, 2021
@straight-shoota straight-shoota merged commit 7f7e4bf into crystal-lang:master Jan 3, 2022
@straight-shoota straight-shoota deleted the feature/i-integration-specs branch January 3, 2022 23:10
rdp pushed a commit to rdp/crystal that referenced this pull request Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs topic:compiler:interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interpreter integration tests
2 participants