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

Add frozen_string_literal: true #1100

Merged
merged 2 commits into from
Aug 29, 2022

Conversation

pocke
Copy link
Member

@pocke pocke commented Aug 29, 2022

RBS allocates many objects. It makes steep check slow.

So this PR reduces String allocations with frozen_string_literal: true magic comment.

Benchmarking

I benchmarked bin/steep -j1.

before: 
[13.82, 13.87, 13.73].sum / 3 # => 13.806666666666667

after:
[13.43, 13.27, 13.21].sum / 3 # => 13.303333333333333

(1 - 13.303333333333333 / 13.806666666666667) * 100 # => 3.645581844519563

3.6% faster 🚀

I've confirmed the effect with memory_profiler gem. It reduces 163918 strings (from 3711262 to 3547344).

@pocke pocke force-pushed the Add_frozen_string_literal__true branch from 0bacb56 to d03ab77 Compare August 29, 2022 09:11
Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

🧊 🙏

@soutaro soutaro merged commit f0d0eb9 into ruby:master Aug 29, 2022
@pocke pocke deleted the Add_frozen_string_literal__true branch August 29, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants