-
Notifications
You must be signed in to change notification settings - Fork 24
Ruby script optimization (by Daniil Yurkanskiy) #13
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
base: master
Are you sure you want to change the base?
Conversation
spajic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аппрув + несколько комментов.
Респект за assert_performance_linear!
| RSS для целевого файла колеблется в пределах 2.6-2.9 Gb. | ||
|
|
||
| ## Защита от регресса производительности | ||
| Для защиты от потери достигнутого прогресса при дальнейших изменениях программы были добавлены тесты Minitest::Benchmark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| Следующие проблемы удалось найти и решить: | ||
|
|
||
| №1 | ||
| Использование bang методов вместо обычных для сокращения аллоцированной памяти и числа объектов. Другие небольшие поправки в виде frozen objects, изменения существующих строк, а не создание новых, убрал парсинг дат и т.д. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Этому описанию не хватает конкретных цифр, значений метрики до и после оптимизации.
С цифрами было бы более информативно, и понятно, какой эффект имела та или иная оптимизация.
Группировка нескольких правок в один пункт ещё сильнее смешивает оптимизации и не даёт понять эффект каждой отдельной.
| Использование bang методов вместо обычных для сокращения аллоцированной памяти и числа объектов. Другие небольшие поправки в виде frozen objects, изменения существующих строк, а не создание новых, убрал парсинг дат и т.д. | ||
|
|
||
| №2 | ||
| Обновление версии Ruby до 2.6.1 для использования метода split без инициализации дополнительного массива в памяти при парсинге пользователей и сессий. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Насколько помогло обновление версии Ruby?
| @@ -0,0 +1,29 @@ | |||
| class Parser | |||
| USER_PREFIX = 'user,'.freeze | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ещё как вариант можно было бы использовать # frozen_string_literal: true
| end | ||
|
|
||
| def bench_report | ||
| assert_performance_linear 0.99 do |file| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
No description provided.