Skip to content

ДЗ №3#48

Open
dmi3-bu wants to merge 6 commits intohardcode-dev:masterfrom
dmi3-bu:solution
Open

ДЗ №3#48
dmi3-bu wants to merge 6 commits intohardcode-dev:masterfrom
dmi3-bu:solution

Conversation

@dmi3-bu
Copy link
Copy Markdown

@dmi3-bu dmi3-bu commented May 4, 2021

No description provided.

Copy link
Copy Markdown
Collaborator

@spajic spajic left a comment

Choose a reason for hiding this comment

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

Да, всё чётко, отличная работа ✅

</h1>
<h2>
<%= "В расписании #{@trips.count} рейсов" %>
<%= "В расписании #{@trips.load.size} рейсов" %>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

<% @trips.each do |trip| %>
<ul>
<%= render "trip", trip: trip %>
<li><%= "Отправление: #{trip.start_time}" %></li>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

С инлайном работает быстрее, но с partial может быть более читаемо
См рендеринг коллекций: https://guides.rubyonrails.org/layouts_and_rendering.html#rendering-collections

<% end %>
</ul>
<%= render "delimiter" %>
====================================================
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread case-study.md

## Feedback-Loop
Для того, чтобы иметь возможность быстро проверять гипотезы я выстроил эффективный `feedback-loop`,
который позволил мне получать обратную связь по эффективности сделанных изменений за ~15 секунд
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

Comment thread case-study.md
который позволил мне получать обратную связь по эффективности сделанных изменений за ~15 секунд

Вот как я построил `feedback_loop`:
- написал тесты для проверки корректности работы рейк таски/контроллера
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

Comment thread case-study.md
- измерил метрику: время выполнения рейк таски с example.json (10 записей) - 200 мс,
время ответа для контроллера с записями из large.json (1000 рейсов) - `25548ms (Views: 23577.9ms | ActiveRecord: 1962.8ms)`
- написал performance тесты для защиты от деградации производительности
- далее использовал эти же входные данные для дальнейшего профилирования и сравнения метрик
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Всё чётко

Comment thread case-study.md
- Rails panel показал,что на рендеринг уходит около 20 секунд
- Перенес все паршиалы в одну вьюху
- Время ответа сервера уменьшилось до `1445ms (Views: 1245.1ms | ActiveRecord: 188.4ms)`
- Время рендера вьюхи сократилось до 1,2 с
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Радикально помогает

Comment thread case-study.md
Ваша находка №4
- PGHero предлагает построить индексы для 3 самых долгих запросов
- Построил эти индексы
- Время ответа сервера почти не изменилось: `1524ms (Views: 1473.3ms | ActiveRecord: 36.5ms)`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Часть с БД ускорилась в 5-6 раз, но в общей сумме не особо заметно на фоне рендеринга
Но всё равно ценно с точки зрения разгрузки БД

disable_ddl_transaction!

def change
add_index :trips, %i[from_id to_id], algorithm: :concurrently
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Плюсик за concurrently

Comment thread db/schema.rb
t.integer "duration_minutes"
t.integer "price_cents"
t.integer "bus_id"
t.index ["from_id", "to_id"], name: "index_trips_on_from_id_and_to_id"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Плюсик за составной индекс

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.

2 participants