Skip to content

#1 Memory Optimization#5

Open
paderinandrey wants to merge 8 commits intospajic:masterfrom
paderinandrey:task-1
Open

#1 Memory Optimization#5
paderinandrey wants to merge 8 commits intospajic:masterfrom
paderinandrey:task-1

Conversation

@paderinandrey
Copy link

No description provided.

Copy link
Owner

@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.

Аппрув + несколько комментов

аллоцировала память 287 МБ

После оптимизации размер аллоцируемой памяти сократился до 293 кб
Программа стала вполняться за 4.11 сек общий размер памяти сократился до 494 МБ
Copy link
Owner

Choose a reason for hiding this comment

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

То есть время увеличилось?
С 3.75c до 4.11?

Copy link
Author

Choose a reason for hiding this comment

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

Да, после рефакторинга я его отыграл

### 2. Выборка из массива сессий пользователя методом select
Использовал memory_profiler
Операция выборки сессий пользователя занимала ~ 266 МБ
После оптимизации размер сократился до 1,5 кб
Copy link
Owner

Choose a reason for hiding this comment

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

Case-study бы лучше читался, если бы добавить сюда как именно оптимизировали.
И как именно нашли с помощью memory_profiler.
Относится ко всем пунктам.


### 4. Date.parse в сортировке
Использовал ruby-prof
'dates' => user.sessions.map { |s| s['date'] }.map { |d| Date.iso8601(d) }.sort.reverse
Copy link
Owner

Choose a reason for hiding this comment

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

👍

В результате проделанной оптимизации наконец удалось обработать файл с данными.
Удалось улучшить метрику системы с *587 МБ до 179 МБ*
Время выполнения программы с тестовыми данными составило 1,2 сек.
Время работы программы с реальными данными составило 69,6 сек
Copy link
Owner

Choose a reason for hiding this comment

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

👍

@@ -1,58 +1,74 @@
# Deoptimized version of homework task
# frozen_string_literal: true
Copy link
Owner

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