-
Notifications
You must be signed in to change notification settings - Fork 50
hw7 #37
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
Open
stashevgenij
wants to merge
2
commits into
hardcode-dev:master
Choose a base branch
from
stashevgenij:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
hw7 #37
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# HW7 | ||
## InfluxDB | ||
Репозиторий TICK недоступен, ошибка 404. Походил немного по репозиториям InfluxDB, самое подходящее было sandbox, думаю это то же самое. | ||
|
||
Установил, открылся хронограф и документация. Добавил influxer и все необходимые настройки, пробую запустить rake task с отправкой метрики. Данные пришли. | ||
|
||
**Первый прогон тестов занял 1760 сек (~29 минут).** | ||
|
||
## Профилирование | ||
|
||
*Не получилось подключить `stackprof`, при запуске тестов возникает длинная ошибка, начинается всё с `[BUG] Segmentation fault at 0x0000000000000008` и далее огромный лог с бэктрейсами из Ruby, C и т.д. Так и не получилось исправить, поэтому пользуюсь пока только `ruby-prof`* | ||
|
||
## Оптимизация №1 | ||
|
||
Отключил логирование `config.logger = Logger.new(nil)`, тесты стали проходить за **1455 сек**. | ||
|
||
## Оптимизация №2 | ||
|
||
Выпилил `database_cleaner`, включил `config.use_transactional_fixtures = true`. Тесты прошли за **1308 сек**. | ||
|
||
## Оптимизация №3 | ||
|
||
Далее я воспользовался профилировщиком `rspec --profile`, увидел топ-10 самых медленных экзамплов и групп. | ||
|
||
Сделал профилирование самой медленной экзампл группы, первая точка роста - `Ethon/Curl::easy_perform^`. По callers понял, что это запросы `elasticsearch`. | ||
|
||
Также по отчету `rspec dissect` понял, что `before` занимает 44 секунды из общих 58. | ||
|
||
Решил попробовать воспользоваться хелперами `before_all` и `let_it_be`. | ||
|
||
Возникли небольшие ошибки, пришлось переписать в некоторых экзамплах `let` на обновление записи внутри `before`, но зато теперь группа тестов проходит **в 3 раза быстрее, 19 сек!** | ||
|
||
## Оптимизация №4 | ||
|
||
Далее прошелся по этой же экзамп группе с `FPROF`. `Total: 65` и я решил, что некоторые записи тут не нужны и можно как-нибудь исключить их создание. | ||
|
||
С помощью transient я передал в factory уже созданные до этого связи и тем самым внутри factory получилось избежать создания лишних записей, при этом не сломались тесты по всему проекту. **Общее количество factories стало 56, а тесты прошли за 18 сек**. | ||
|
||
Также в before хуке выполнялось 3 `create_list` по 5 записей, что мне показалось излишним и вполне достаточно создавать по 3 записи. **Теперь всего создаётся 46 factories, а группа тестов проходит за 15 сек**. | ||
|
||
Также нашел похожую группу тестов и сделал для них общий `shared_context`. **В ней количество factories изменилось `80 -> 21`, а время выполнения `10 сек -> 4 сек`**. | ||
|
||
## Итог | ||
|
||
**Полный набор тестов прошёл за 1220 сек.** | ||
|
||
Я ускорил прохождение тестов на 31%, настроил отправку данных в InfluxDB и создал график, потестировал несколько профилировщиков и полезных инструментов для работы с тестами. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У нас кстати в 3commas давно сделана сборка времени прогона спеков в CI по такой схеме Было занятно посмотреть график за полтора года |
||
|
||
Получилось оптимизировать пока не так много, как хотелось бы, так как test suite большой, но хорошо прошелся по самой медленной example group и есть понимание что оптимизировать в моём проекте и как. Разработал уже неплохой фидбэк луп, с помощью которого в будущем буду двигаться по всем остальным медленным тестам. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Я недавно тоже пытался воспользоваться stackprof, столкнулся с такой же проблемой и тоже пришлось свичнуться на ruby-prof