Skip to content
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

Merged
merged 7 commits into from
Mar 3, 2024

Conversation

IlyaAbramovv
Copy link
Contributor

No description provided.

import java.lang.foreign.MemorySegment;
import java.util.concurrent.CompletableFuture;

public class Service implements ru.vk.itmo.Service {
Copy link

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());
Copy link

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 {
Copy link

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 {
Copy link

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;
Copy link

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.*;
Copy link

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.*;
Copy link

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.*;
Copy link

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;
Copy link

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) {
Copy link

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 {
Copy link

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) {
Copy link

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'

Copy link
Contributor

@AlexeyShik AlexeyShik left a 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 {
Copy link
Contributor

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) \
Copy link
Contributor

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) \
_Видно, что аллокации распределены более-менее равномерно; вероятно, тут ничего оптимизировать не надо_
Copy link
Contributor

Choose a reason for hiding this comment

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

"более-менее равномерно" не значит, что оптимально.
Например, можно посмотреть на аллокации, связанные с парсингом запроса и выбором сгенерированного хендлера. В крупных приложениях даже оптимизация на пару процентов может дать существенных прирост производительности.

@AlexeyShik AlexeyShik merged commit 21f0306 into polis-vk:main Mar 3, 2024
2 checks passed
osokindm pushed a commit to osokindm/2024-highload-dht that referenced this pull request Mar 6, 2024
* Stage 1

* Refactor code

* Codeclimate

* Codeclimate

---------

Co-authored-by: Alexey Shik <58121508+AlexeyShik@users.noreply.github.com>
axothy pushed a commit to axothy/2024-highload-dht that referenced this pull request Mar 13, 2024
* Stage 1

* Refactor code

* Codeclimate

* Codeclimate

---------

Co-authored-by: Alexey Shik <58121508+AlexeyShik@users.noreply.github.com>
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