-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 benchmarking to faker-ruby #2851
Comments
assign to @salochara |
|
Add benchmark rake task for evaluating time execution. Fixes Co-authored-by: Rubens Fernandes <rubens.fernandes97@gmail.com>
Add benchmark rake task for evaluating time execution. Fixes Co-authored-by: Rubens Fernandes <rubens.fernandes97@gmail.com>
Next steps is to try to use I18n |
* Add benchmark gem to Faker * Fix #2851 Add benchmark rake task for evaluating time execution. Fixes Co-authored-by: Rubens Fernandes <rubens.fernandes97@gmail.com> * Commit PR suggestions by Thiago. - Build all_methods outside the benchmark since we don't want to measure that. * Commit PR suggestions by Steffani. - Avoid calling the same object twice --------- Co-authored-by: Rubens Fernandes <rubens.fernandes97@gmail.com>
Hello @stefannibrasil 👋 I spent some time today looking at I read through the implementation and discussion in this PR ruby-i18n/i18n#612. What I'm not sure, is why they suggest this In any case, regarding Faker and using the The thing is that, whenever that's enabled, when running LazyLoadable is expecting a certain naming system for the locales, and in some cases, we don't have that in Faker.
So to move forward, I have mainly 2 issues/questions
What are your thoughts on this? All the best! |
Hello! @stefannibrasil Just a quick update. Bottom line... the lazy loading feature only makes sense in the testing environment. All the best! |
hey @salochara , thanks for the investigation! And yeah, what they said in here makes a lot of sense. You want translations to be available in memory so you can use them as fast as possible in production. But in your test environment, you're not going to use all the translations in your tests anyway. So adding lazy loading gives you faster boot times, which lets your tests run quickly. I think the way Faker is used puts us in a tricky situation: On one hand, when you're using Faker in your test environment, you want generators to be fast so your test runs quickly, and for that you do want all translations already loaded in memory. On the other hand, you also want your tests to boot fast, so running all your specs doesn't take too long. And in that case, you don't want to load all your translations, because it takes time to read and parse them. Also, it can be hard to know which translation file Faker will need at boot time, because this depends on the generator you're using, so lazy loading would certainly help here. In summary, we want it all. 😆 When running faker in production/staging for generating example data, this is not a problem, because you won't be rebooting the app very often, so lazy loading is not needed here. -- But I think there are a couple of ideas we could think about:
We might be doing this right now, but I'm not sure, would have to see how i18n behaves. But if not, maybe this could be a potential improvement. Assuming that we only load :en locales, for example, would that make any difference?
I think we could come up with a loader that could map a given generator to its required locale and load it when necessary.
IMO I think this is the more interesting question. Can we just make locales load very fast? Assuming that the user won't be adding their own custom translations/locales to Faker, we can say that all possible locales are fixed when we generate a new release of Faker. If that's true, then we could just transform all locales into something that can be loaded quickly. Then this becomes a problem of data serialization. One option that someone suggested was transforming our yaml locales into json, because json parsing is probably way faster. Another option would be to turn the locales into a binary format that is easy to load into memory via marshalling. This wold then be used as a backend for all generators. Our locales could still be yaml files, but we transform them into something that can be loaded faster and package that with the gem. I think option 3 is worth exploring more, but I'd be interested in your opinion @salochara @stefannibrasil |
[this issue will be assigned to participants of the RubyConf2023 Hack Day]
There are a couple of issues regarding performance:
As a first step to tackling these performance issues, we would like to start measuring the performance of faker-ruby as part of the test suite by adding a benchmarking tool.
This tool or script would run as part of the test suite and measure:
Resources:
Other gems do something similar, here are some examples:
The text was updated successfully, but these errors were encountered: