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

Tveritin Alexandr - DWS (Step-1) #30

Merged
merged 8 commits into from
Feb 27, 2024
Merged

Tveritin Alexandr - DWS (Step-1) #30

merged 8 commits into from
Feb 27, 2024

Conversation

ALTV2
Copy link
Contributor

@ALTV2 ALTV2 commented Feb 21, 2024

No description provided.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6339 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6350 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6354 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6364 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6364 lines exceeds the maximum allowed for the inline comments feature.

Copy link
Member

@incubos incubos left a comment

Choose a reason for hiding this comment

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

Не разобрались с багом под нагрузкой. Нет анализа профилирования. Есть замечания к коду.
Тем не менее, 5 баллов.

function request()
local headers = {}
headers["Host"] = "localhost"
local id = math.random(1, 2000)
Copy link
Member

Choose a reason for hiding this comment

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

Всего 2К ключей? Насколько результатам тестирования можно будет доверять?

request = function()
local headers = {}
headers["Host"] = "localhost"
local id = math.random(1, 2000)
Copy link
Member

Choose a reason for hiding this comment

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

Не слишком мало ключей?

local random_string = ""
local charset_length = string.len(charset)

math.randomseed(os.time())
Copy link
Member

Choose a reason for hiding this comment

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

Зачем выставлять seed на каждый вызов?

#[Buckets = 27, SubBuckets = 2048]
----------------------------------------------------------
299980 requests in 30.00s, 19.74MB read
Non-2xx or 3xx responses: 160
Copy link
Member

Choose a reason for hiding this comment

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

Чем объяснить эти необычные ответы?

----------------------------------------------------------
299980 requests in 30.00s, 19.74MB read
Non-2xx or 3xx responses: 160
Requests/sec: 9999.35
Copy link
Member

Choose a reason for hiding this comment

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

Почему в отчёте 20К rps?

./wrk -d 30 -t 1 -c 1 -R 20000 -L -s

Comment on lines +27 to +31
private static final Response RESPONSE_NOT_FOUND = new Response(Response.NOT_FOUND, Response.EMPTY);
private static final Response RESPONSE_BAD_REQUEST = new Response(Response.BAD_REQUEST, Response.EMPTY);
private static final Response RESPONSE_CREATED = new Response(Response.CREATED, Response.EMPTY);
private static final Response RESPONSE_ACCEPTED = new Response(Response.ACCEPTED, Response.EMPTY);
private static final Response RESPONSE_NOT_ALLOWED = new Response(Response.METHOD_NOT_ALLOWED, Response.EMPTY);
Copy link
Member

Choose a reason for hiding this comment

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

Причина проблем с большой нагрузкой может быть в этих закешированных объектах Response -- обсуждали на втором занятии.

if (id.isEmpty()) return RESPONSE_BAD_REQUEST;
MemorySegment key = MemorySegment.ofArray(id.getBytes(StandardCharsets.UTF_8));

Entry<MemorySegment> resultEntry = dao.get(key);
Copy link
Member

Choose a reason for hiding this comment

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

Здесь и ниже не обрабатываются возможные исключения DAO.

private static final Response RESPONSE_ACCEPTED = new Response(Response.ACCEPTED, Response.EMPTY);
private static final Response RESPONSE_NOT_ALLOWED = new Response(Response.METHOD_NOT_ALLOWED, Response.EMPTY);

private final DaoImpl dao;
Copy link
Member

Choose a reason for hiding this comment

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

Почему конкретный класс, а не интерфейс Dao?

public Response upsert(@Param(value = "id", required = true) String id, Request request) {
if (id.isEmpty()) return RESPONSE_BAD_REQUEST;
MemorySegment key = MemorySegment.ofArray(id.getBytes(StandardCharsets.UTF_8));
MemorySegment value = MemorySegment.ofArray(request.getBody());
Copy link
Member

Choose a reason for hiding this comment

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

Если тела не будет, то PUTом выполним DELETE? Выглядит не совсем корректно.

public synchronized void stop() {
super.stop();
try {
dao.close();
Copy link
Member

Choose a reason for hiding this comment

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

Освобождать ресурсы желательно там же, где их выделили, т.е. в ServiceImpl -- иначе сложно рассуждать об их жизненном цикле.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

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

The PR diff size of 6364 lines exceeds the maximum allowed for the inline comments feature.

@incubos incubos merged commit b16dc02 into polis-vk:main Feb 27, 2024
2 checks passed
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.

4 participants