-
Notifications
You must be signed in to change notification settings - Fork 47
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
Stage 1, Андрей Чешев, Политех #16
Conversation
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.
В решении есть серьёзные недочёты, такие как отсутствие обработки исключений и некорректная остановка сервиса. И, похоже, профилировалось приложение с "холодной" jvm (прошу учесть в следующих этапах)
Тем не менее, судя по отчёту, по результатам профилирования первого решения были выполнены оптимизации, направленные на уменьшение генерации мусора. Хотя, флеймграфы неинтерактивные, проверить отдельные выводы нельзя (прошу учесть в следующих этапах, чтобы не терять баллы)
Поэтому 8 баллов
И перед мержем необходимо откатить лишние изменения
import java.util.NoSuchElementException; | ||
import java.util.PriorityQueue; | ||
import java.util.Queue; | ||
import java.util.*; |
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.
Необходимо откатить изменения в несвязанных с этапом файлах. Здесь и в еще одном классе reference/dao
private static final String ID = "id="; | ||
private final ReferenceDao dao; | ||
|
||
public ServerImpl(ServiceConfig config) throws IOException { |
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.
Думаю, не очень хорошо, что конфиг сервиса просочился на уровень сервера. Было бы лучше, если бы сервис разобрал данный конфиг, на его основе сформировал бы конфиги зависимостей и инстанцировал их с этими конфигами
return serverConfig; | ||
} | ||
|
||
public Response get(final Request request) { |
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.
Методы get,put,delete и createServerConfig являются публичными, хотя этого не требуется. Нужно ужесточить доступность/видимость
|
||
int method = request.getMethod(); | ||
|
||
Response response = switch (method) { |
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.
Для всех методов отсутствует обработка исключений от DAO
Что, кстати, будет при выбросе исключения?) Автоматом 500 ответ или, может, отсутствие ответа?)
dao.close(); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
super.stop(); |
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.
Сначала закрывается dao, затем сервер перестаёт слушать порт
Получается, что будет попытка обработать часть запросов уже с закрытым dao
Поэтому, нужно сначала прекратить принимать http запросы, а уже потом закрывать dao
* Результаты работы wrk2 при стабильной нагрузкe на протяжении 2х минут:  | ||
|
||
### Профилирование запросов типа PUT: | ||
* Профилирование CPU:  |
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.
Высокая доля сэмплов от работы JVM может свидетельствовать о том, что JVM не была "прогрета" перед началом профилирования. Начинать снимать профили имеет смысл, когда уже было выполнено какое-то количество вставок в базу, прошло, скажем, секунд 30. Тогда горячий код успеет скомпилироваться
* Убрана двойная аллокация через getPath() | ||
|
||
Попытка оптимизировать возвращение результата с кодом OK и body: | ||
* Было замечено, что в используемом конструкторе Response() происходит двойная аллокация строки "Content-Length: " + body.length (на FlameGraph видно вызов метода StringConcatHelper.newString()). |
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.
Зря профили были экспортированы в SVG. Потерялась интерактивность, у ревьюера нет возможности их внимательно изучить
в частности, хотелось полученный вывод о двойной аллокации проверить
|
||
public class ServiceImpl implements Service { | ||
private final ServiceConfig serviceConfig; | ||
private ServerImpl server; |
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.
Вероятно, здесь будет достаточно HttpServer/Server
acceptorConfig.port = config.selfPort(); | ||
acceptorConfig.reusePort = true; | ||
|
||
HttpServerConfig serverConfig = new HttpServerConfig(); |
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.
Rename "serverConfig" which hides the field declared at line 18.
Исправил замечания. |
public ServerImpl(HttpServerConfig config, Config daoConfig) throws IOException { | ||
super(config); | ||
|
||
this.dao = new PersistentReferenceDao(daoConfig); |
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.
Dao, в принципе, тоже можно было бы инстанцировать в сервисе и в сервер просто инжектить
* rename package * 8/14 tests * 12/14 tests * 14/14 tests * fixes * fixes * fixes * + report * codestyle fixes * codestyle fixes * add lua scripts * report fix * HTML to SVG * add THRESHOLD_BYTES const * code review fixes * code climate fixes * style fixes --------- Co-authored-by: Anton Lamtev <lamtev@users.noreply.github.com>
* rename package * 8/14 tests * 12/14 tests * 14/14 tests * fixes * fixes * fixes * + report * codestyle fixes * codestyle fixes * add lua scripts * report fix * HTML to SVG * add THRESHOLD_BYTES const * code review fixes * code climate fixes * style fixes --------- Co-authored-by: Anton Lamtev <lamtev@users.noreply.github.com>
No description provided.