Skip to content

feat: remove to_sentence usage#534

Merged
bkeepers merged 1 commit intobkeepers:mainfrom
ThomasCrambert:remove-to-sentence-usage
Jul 9, 2025
Merged

feat: remove to_sentence usage#534
bkeepers merged 1 commit intobkeepers:mainfrom
ThomasCrambert:remove-to-sentence-usage

Conversation

@ThomasCrambert
Copy link
Copy Markdown
Contributor

@ThomasCrambert ThomasCrambert commented Jul 9, 2025

Hello 👋,

While introducing this gem within our codebase, we studied the boot time impact as it increased by 400ms. We tracked down an increase of 200ms from this gem at

debug "Set #{changed.to_sentence}" if diff.any?
, trying to load I18n. We found out it's because of a call to #to_sentence that under the hood calls I18n.translate (cf https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/array/conversions.rb#L69).

Since these are simple debug logs, I changed them to simple .join(' ). Is that fine for you

image

@ThomasCrambert ThomasCrambert marked this pull request as ready for review July 9, 2025 09:18
@bkeepers bkeepers force-pushed the remove-to-sentence-usage branch from 9e5b2ab to dbcfc52 Compare July 9, 2025 11:07
@bkeepers bkeepers merged commit 96e97f9 into bkeepers:main Jul 9, 2025
11 checks passed
@bkeepers
Copy link
Copy Markdown
Owner

bkeepers commented Jul 9, 2025

Thanks @ThomasCrambert, I'll get a release out soon.

@fatkodima
Copy link
Copy Markdown

@bkeepers Please make a new release with this change.

@ThomasCrambert
Copy link
Copy Markdown
Contributor Author

Hello @bkeepers 👋, could you make a new release that would contain this change? It's been quite a while since the last one 🙏

@bkeepers
Copy link
Copy Markdown
Owner

bkeepers commented Dec 3, 2025

@ThomasCrambert v3.2.0 is out with this change. Sorry for the delay.

diff = event.payload[:diff]
changed = diff.env.keys.map { |key| color_var(key) }
debug "Set #{changed.to_sentence}" if diff.any?
debug "Set #{changed.join(", ")}" if diff.any?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
debug "Set #{changed.join(", ")}" if diff.any?
debug { "Set #{changed.join(", ")}" } if diff.any?

This could be another improvement when the log level is to something less verbose, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think these are usually called only once (on boot) and does not matter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Alright, the PR made me think it's called multiple times. But apparently the slowdown came just from booting i18n. 😬

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But apparently the slowdown came just from booting i18n.

Yes that's the reason why I proposed this change. Dotenv shouldn't have any impact post-boot 👍

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.

4 participants