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

Performance changes #138

Closed
wants to merge 12 commits into from
Closed

Conversation

thedarkone
Copy link
Contributor

I18n started showing up in perf profiles for my app again. I'm no longer that much familiar with the I18n's codebase as I used to be, so some code review is really welcome.

thedarkone referenced this pull request in tenderlove/i18n Jun 30, 2014
This cleans up our code, and makes it faster.  Every call to `translate`
required an `is_a` check to make sure that the return value wasn't a
translation error.  This behavior punished method calls when the lookup
was successful.  Successful lookup should *hopefully* be the majority of
cases, so we should make that code path as fast as possible.

Benchmark:

```ruby
require 'i18n'
require 'benchmark/ips'
require 'set'

I18n.backend = I18n::Backend::Simple.new
I18n.backend.store_translations('en', :foo => 'bar')
I18n.config.enforce_available_locales = true

Benchmark.ips do |x|
  options = { :locale => 'en' }
  x.report 'tr' do
    I18n.translate(:foo, options)
  end
end
```

Before:

```
[aaron@higgins i18n (rm_throw)]$ ruby -I lib test.rb
Calculating -------------------------------------
                  tr      7661 i/100ms
-------------------------------------------------
                  tr    89120.2 (±5.0%) i/s -     451999 in   5.085290s
```

After:

```
[aaron@higgins i18n (rm_throw)]$ ruby -I lib test.rb
Calculating -------------------------------------
                  tr      8207 i/100ms
-------------------------------------------------
                  tr    93770.9 (±5.1%) i/s -     467799 in   5.002582s
```
@thedarkone
Copy link
Contributor Author

@carlosantoniodasilva 😞 I'm sorry for pinging you about this, but :bowtie: there is now some unnecessary tenderlove@acf0546 duplicate work by @tenderlove going on. Please have a look at this when you have the time ❤️.

@carlosantoniodasilva
Copy link
Member

@thedarkone no problem :), I'm aware that @tenderlove did some work on i18n yesterday, but I want to talk to him first to understand what are his plans. I have another branch with tons of changes and removals due to old Ruby/Rails compatibilities that I also want to get in, but I haven't had time to work on OSS these days due to personal stuff, which is something that should be solved by next week. I'll do my best then to get all this in, and I'll talk to @tenderlove meanwhile. Thanks ❤️.

@tenderlove
Copy link
Contributor

My plan is to basically do what this PR does, so we should merge this (after we can make the build green).

@carlosantoniodasilva
Copy link
Member

@tenderlove you mean the build on this branch? Because master is supposed to be green now.

@tenderlove
Copy link
Contributor

@carlosantoniodasilva I mean this branch. :-)

But, there are some tests that fail randomly on master, so I sent pull requests to deal with them. I'll pull down @thedarkone's changes and see if I can get all the tests to pass.

@carlosantoniodasilva
Copy link
Member

👍 I'll merge them later ❤️

carlosantoniodasilva added a commit that referenced this pull request Jan 10, 2015
Performance changes

Conflicts:
	lib/i18n.rb
	lib/i18n/backend/chain.rb
@radar
Copy link
Collaborator

radar commented Nov 3, 2016

@thedarkone / @tenderlove any interest in getting this PR across the line for i18n 0.8.0?

@radar radar added this to the 0.8.0 milestone Nov 3, 2016
@thedarkone
Copy link
Contributor Author

@radar what is the timetable? Would it be acceptable if I would need maybe up to 3-4 weeks time to look at it?

@radar
Copy link
Collaborator

radar commented Nov 6, 2016

@thedarkone I don't have any particular timetable in mind yet. The i18n gem hasn't received a version bump since Dec '14. It can wait a little while longer. If you need 3-4 weeks to complete it, then that's OK with me. 👍

@radar radar added the waiting label Nov 17, 2016
@radar radar added this to the 0.9.0 milestone Nov 20, 2016
@radar radar removed this from the 0.8.0 milestone Nov 20, 2016
@radar
Copy link
Collaborator

radar commented Nov 20, 2016

Bumping this to 0.9.0. Looking to prep a 0.8.0 beta release for December, with a 0.9.0 next quarter.

@radar radar modified the milestones: 0.9.0, 0.10.0 Oct 1, 2017
@radar radar closed this Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants