-
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
Абрамов Илья ИТМО ФИТиП HW1 #24
Conversation
import java.lang.foreign.MemorySegment; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class Service implements ru.vk.itmo.Service { |
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 this class.
flushThresholdBytes = config.flushThresholdBytes(); | ||
this.storage = new Storage(config); | ||
|
||
System.out.println(config.basePath()); |
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.
Replace this use of System.out or System.err by a logger.
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class MainServer { |
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.
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
public class Server extends HttpServer { | ||
public static final String ENTITY_PATH = "/v0/entity"; | ||
private final Dao<MemorySegment, Entry<MemorySegment>> dao; | ||
public Server(ServiceConfig config, Dao<MemorySegment, Entry<MemorySegment>> dao) 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.
'CTOR_DEF' should be separated from previous statement.
import ru.vk.itmo.test.abramovilya.dao.table.TableEntry; | ||
|
||
|
||
import java.lang.foreign.MemorySegment; |
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.
'import' has more than 1 empty lines before.
@@ -0,0 +1,82 @@ | |||
package ru.vk.itmo.test.abramovilya; | |||
|
|||
import one.nio.http.*; |
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.
Using the '.' form of import should be avoided - one.nio.http..
@@ -0,0 +1,82 @@ | |||
package ru.vk.itmo.test.abramovilya; | |||
|
|||
import one.nio.http.*; |
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.
Avoid unused imports such as 'one.nio.http'
@@ -0,0 +1,82 @@ | |||
package ru.vk.itmo.test.abramovilya; | |||
|
|||
import one.nio.http.*; |
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.
Avoid unused imports such as 'one.nio.http'
@@ -0,0 +1,82 @@ | |||
package ru.vk.itmo.test.abramovilya; |
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.
File does not end with a newline.
private Server server; | ||
private final ServiceConfig serviceConfig; | ||
private Dao<MemorySegment, Entry<MemorySegment>> dao; | ||
public Service(ServiceConfig serviceConfig) { |
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.
'CTOR_DEF' should be separated from previous statement.
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class MainServer { |
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.
A class which only has private constructors should be final
@ServiceFactory(stage = 1) | ||
public static class Factory implements ServiceFactory.Factory { | ||
@Override | ||
public ru.vk.itmo.Service create(ServiceConfig config) { |
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.
Unnecessary use of fully qualified name 'ru.vk.itmo.Service' due to existing import 'ru.vk.itmo.Service'
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.
15 баллов, хороший анализ профиля.
На будущие дз, будет здорово еще результаты wrk для точки разладки прикреплять, чтобы было наглядно.
} | ||
|
||
@Override | ||
public void handleDefault(Request request, HttpSession session) 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.
Еще нужно добавить обработку исключений на случай непредвиденных серверных ошибок, чтобы это были 5хх.
_Тут аллокации тоже почти равномерные, однако выделяется ```byte[]``` внутри one.nio read \ | ||
Я не думаю, что могу как-то уменьшить там число аллокаций_ | ||
|
||
[put_cpu.png](asprof%2Fput_cpu.png) \ |
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.
В put профиле видно работу jit-а, в следующих дз предлагаю следить за прогревом jvm, чтобы поиск точки разладки и профилирование происходили на максимально соптимизированном приложении, каким оно и будет в проде.
|
||
#### Результаты работы async-profiler: | ||
[get_alloc.png](asprof%2Fget_alloc.png) \ | ||
_Видно, что аллокации распределены более-менее равномерно; вероятно, тут ничего оптимизировать не надо_ |
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.
"более-менее равномерно" не значит, что оптимально.
Например, можно посмотреть на аллокации, связанные с парсингом запроса и выбором сгенерированного хендлера. В крупных приложениях даже оптимизация на пару процентов может дать существенных прирост производительности.
* Stage 1 * Refactor code * Codeclimate * Codeclimate --------- Co-authored-by: Alexey Shik <58121508+AlexeyShik@users.noreply.github.com>
* Stage 1 * Refactor code * Codeclimate * Codeclimate --------- Co-authored-by: Alexey Shik <58121508+AlexeyShik@users.noreply.github.com>
No description provided.