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

Perf improvement and refactor for the non-reliable disk buffer #3756

Merged
merged 16 commits into from
Aug 14, 2021

Conversation

MrAnno
Copy link
Collaborator

@MrAnno MrAnno commented Aug 12, 2021

This PR refactors the non-reliable disk buffer and simplifies how messages are moved among queue segments.
(The trigger behind this refactor was to avoid unnecessarily (de)serialization and disk I/O operations in the move logic, but I had to drop those changes because they would have had unpleasant side effects.)

The last 2 commits improve the performance of the non-reliable disk buffer by using the entire qout when moving messages, and by eliminating a lock during qbacklog operations.

According to my measurements, this could increase the performance up to 20%.

No news file is needed, we'll add a news entry separately about the overall performance improvement we achieved.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@MrAnno
Copy link
Collaborator Author

MrAnno commented Aug 12, 2021

@kira-syslogng do stresstest

@MrAnno
Copy link
Collaborator Author

MrAnno commented Aug 12, 2021

@kira-syslogng test this please test branch=benedek-add-disk-buffer-tests;

@kira-syslogng
Copy link
Contributor

Kira-stress-test: Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@MrAnno MrAnno marked this pull request as ready for review August 12, 2021 12:30
OverOrion
OverOrion previously approved these changes Aug 13, 2021
Copy link
Collaborator

@OverOrion OverOrion left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for your work!

alltilla
alltilla previously approved these changes Aug 13, 2021
Copy link
Collaborator

@alltilla alltilla left a comment

Choose a reason for hiding this comment

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

Nice one, thanks!

modules/diskq/logqueue-disk-non-reliable.c Show resolved Hide resolved
MrAnno added 16 commits August 13, 2021 16:34
This method can be removed from the LogQueue interface in the future
in favor of the backlog and its rewind mechanism.

Signed-off-by: László Várady <[email protected]>
push_head() is dead code, it is not used by syslog-ng.

This method can be removed from the LogQueue interface in the future
in favor of the backlog and its rewind mechanism.

Subsequent commits are going to change the internals of the non-reliable
disk-buffer's push() and pop() operations, this was the trigger for this
cleanup.

Signed-off-by: László Várady <[email protected]>
This is a refactor, the commit contains equivalent transformations based
on the following considerations:

This commit splits push_tail() into 3 push parts: qout, disk, and qoverflow

- if qout has space in it and the disk is empty, we push into qout
- we try to push into the disk buffer otherwise
- when the disk push fails (full or write error), we push
  into qoverflow
- once we reached the qoverflow area, we continue pushing message there
  instead of disk

The above steps retain FIFO order if messages are moved from qoverflow to
disk, and from disk to qout after each pop(). This is done by _move_disk().

Notes:
Settings local_options.ack_needed to FALSE converts the subsequent
log_msg_ack() call to a NOOP. It is cleaner not to call the ack method.
The same is true for log_msg_ref() and log_msg_unref().

Signed-off-by: László Várady <[email protected]>
This is a refactor commit.

Signed-off-by: László Várady <[email protected]>
unref() might free the message object, so ack() should be called first.

Signed-off-by: László Várady <[email protected]>
This is a preparation step for simplifying the move logic of non-reliable
queue segments.

This commit does not change functionality, as _move_messages_from_overflow
is already there to move messages from the overflow queue.

Signed-off-by: László Várady <[email protected]>
The name of _get_next_message() can be misleading in this context, as it
only reads from disk. Also, log_msg_ack() has no effect when adding a
message from the disk to the qout queue.

Signed-off-by: László Várady <[email protected]>
qbacklog is accessed only from an output thread, so locking is not necessary.

Signed-off-by: László Várady <[email protected]>
@MrAnno MrAnno dismissed stale reviews from alltilla and OverOrion via 557f2db August 13, 2021 14:39
@MrAnno MrAnno force-pushed the diskq-perf-qbacklog-and-refact branch from 8a1936f to 557f2db Compare August 13, 2021 14:39
@alltilla
Copy link
Collaborator

@kira-syslogng test this please test branch=benedek-add-disk-buffer-tests;

@alltilla
Copy link
Collaborator

@kira-syslogng do stresstest

@MrAnno
Copy link
Collaborator Author

MrAnno commented Aug 13, 2021

FYI benedek-add-disk-buffer-tests has been merged.

@alltilla
Copy link
Collaborator

FYI benedek-add-disk-buffer-tests has been merged.

Whoops, my bad :(

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Kira-stress-test: Build FAILURE

@MrAnno
Copy link
Collaborator Author

MrAnno commented Aug 13, 2021

@kira-syslogng do stresstest

@kira-syslogng
Copy link
Contributor

Kira-stress-test: Build SUCCESS

@alltilla alltilla merged commit 5d1266a into syslog-ng:master Aug 14, 2021
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