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

Implement ECR.process_string as a macro #14735

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Jun 20, 2024

This is a proof of concept to show that we don't need the macro run here at all. Whether this macro is indeed faster than the existing src/ecr/process.cr for all use cases is up for investigation, but these are the results of doing make clean clean_cache && time make && rm .build/crystal && time make, rebuilding the compiler with a cold and hot cache respectively, with this PR:

real    0m17.873s
user    0m31.251s
sys     0m2.823s

real    0m14.343s
user    0m14.761s
sys     0m1.097s

and without this PR:

real    0m22.057s
user    0m34.573s
sys     0m3.136s

real    0m15.532s
user    0m16.533s
sys     0m1.388s

I couldn't notice any significant differences when running the files under scripts/ that also use ECR.

The looper* variables are a workaround for not having while in the macro language.

This PR consumes about 120 MB more memory in the compiler itself, but note that there are no more subprocesses doing macro runs. It seems string.chars and those looper elements each contribute roughly 10 MB of memory.

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

Successfully merging this pull request may close these issues.

1 participant