Skip to content

stored: buffer fd messages#1539

Merged
BareosBot merged 10 commits intobareos:masterfrom
sebsura:dev/ssura/master/parallel-receive
Nov 7, 2023
Merged

stored: buffer fd messages#1539
BareosBot merged 10 commits intobareos:masterfrom
sebsura:dev/ssura/master/parallel-receive

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Aug 29, 2023

Thank you for contributing to the Bareos Project!

This pr adds an asynchronous message buffer to the sd. This should reduce the time the file daemon has to wait when sending data to the storage daemon.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@sebsura sebsura added the draft label Aug 29, 2023
@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from 8efafcb to 9c22b8d Compare August 31, 2023 13:55
@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from 9c22b8d to e8c375f Compare September 14, 2023 07:57
@sebsura sebsura removed the draft label Sep 14, 2023
@pstorz pstorz requested a review from arogge September 14, 2023 10:20
@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from e8c375f to d127493 Compare September 22, 2023 10:36
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Looks pretty solid. Nevertheless, I have a few remarks.

Comment on lines +526 to +535
// base is filled with a list of "base job expressions",
// which are just normal strings, with
// Base = <text>
// inside the option block. While they are parsed
// both by the director and the file daemon, they are
// as far as I can see not used at all.
// We should think about removing all references to them.
// Maybe this was a predecessor of JobResource->base ?
// - Sebastian Sura, 12.05.2023
alist<const char*> base; /**< List of base names (unused) */
Copy link
Member

Choose a reason for hiding this comment

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

if it compiles without this, feel free to remove it.

fo->base.destroy();
fo->fstype.destroy();
fo->Drivetype.destroy();
fo->~findFOPTS();
Copy link
Member

Choose a reason for hiding this comment

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

I would strongly favour std::destroy_at() here.

Comment on lines +297 to +299
for (auto& regex : fo->regex) { regfree(&regex); }
for (auto& regex : fo->regexdir) { regfree(&regex); }
for (auto& regex : fo->regexfile) { regfree(&regex); }
Copy link
Member

Choose a reason for hiding this comment

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

what exactly stops us from moving this (and the following free(fo->size_match);) into the dtor?

Comment on lines +194 to +202
if (type == ' ') {
vec = &current_opts->regex;
} else if (type == 'D') {
vec = &current_opts->regexdir;
} else if (type == 'F') {
vec = &current_opts->regexfile;
} else {
return state_error;
}
Copy link
Member

Choose a reason for hiding this comment

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

that looke like it should have been a switch().


fnm_flags = BitIsSet(FO_IGNORECASE, ff->flags) ? FNM_CASEFOLD : 0;
fnm_flags |= BitIsSet(FO_ENHANCEDWILD, ff->flags) ? FNM_PATHNAME : 0;
bool do_exclude = BitIsSet(FO_EXCLUDE, ff->flags);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool do_exclude = BitIsSet(FO_EXCLUDE, ff->flags);
const bool do_exclude = BitIsSet(FO_EXCLUDE, ff->flags);

/* If there is any Drivetype selection set the default
* selection to false. */
if (fo->Drivetype.size()) { wanted = false; }
if (fo->Drivetype.size() > 0) { wanted = false; }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (fo->Drivetype.size() > 0) { wanted = false; }
if (!fo->Drivetype.empty()) { wanted = false; }

@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from d127493 to 402bfac Compare October 9, 2023 07:11
@sebsura sebsura requested a review from arogge October 24, 2023 04:53
@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from fd0ab2c to 07b7de2 Compare October 24, 2023 04:57
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Looks good. I have two minor remarks that you can address if (and only if) you need to touch the commits again for some reason.

Comment on lines +182 to +184
static inline constexpr int DataAvailable = 1;
static inline constexpr int Timeout = 0;
static inline constexpr int Error = -1;
Copy link
Member

Choose a reason for hiding this comment

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

if I'm not mistaken that inline is redundant, but of course not wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ill have to check again, but at least there is a difference between static and static inline. Not sure if constexpr makes those the same again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://stackoverflow.com/a/54467409 global variables should be inline constexpr to fix odr related issues that might arise. static here is just because they are defined inside the class scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like constexpr member variables are always inline. Thanks for the hint!

jcr->sd_impl->dcr->rec->data = rec_data;

if (bs->IsError()) {
if (auto* error = handler.error()) {
Copy link
Member

Choose a reason for hiding this comment

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

as error is passed to Jmsg2() which isn't type-checked at all, I would feel safer with a const char* instead of an auto*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from 07b7de2 to 05d7580 Compare November 6, 2023 06:53
This class reads data from the given socket asynchroniously and makes
them available in a preparsed manner on the main thread.  It is
important that the given socket is only used by one thread at a time,
as such, if you create a MessageHandler for a certain socket, you need
to take care to not use that socket at all while the message handler
is alive.
@sebsura sebsura force-pushed the dev/ssura/master/parallel-receive branch from 05d7580 to ad4fc2b Compare November 7, 2023 06:43
@BareosBot BareosBot merged commit 461c984 into bareos:master Nov 7, 2023
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.

3 participants