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

Decoder: optimize decoding of optional and variant for scalar types #89

Conversation

CuriousGeorgiy
Copy link
Member

@CuriousGeorgiy CuriousGeorgiy commented Jan 15, 2024

This patch optimizes the decoding of optional and variant values for scalar types.

Closes #84

@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-85-optimize-optional-variant-decode branch 2 times, most recently from 24e3d5e to 7420d5f Compare January 15, 2024 10:38
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
@drewdzzz drewdzzz assigned CuriousGeorgiy and unassigned drewdzzz Jan 23, 2024
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-85-optimize-optional-variant-decode branch 11 times, most recently from e67b648 to e123c94 Compare January 24, 2024 11:17
@CuriousGeorgiy
Copy link
Member Author

Linter error is fixed in @drewdzzz's patch.

.clang-format Outdated
AlwaysBreakAfterReturnType: TopLevel
ContinuationIndentWidth: 8
SpaceAfterTemplateKeyword: false
Copy link
Collaborator

@drewdzzz drewdzzz Jan 24, 2024

Choose a reason for hiding this comment

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

I'm not sure about this option.
In Dec.hpp and Traits.hpp, we have a space after template.
Also, as I noticed, project's author @alyapunov always puts this space.

Copy link
Member Author

@CuriousGeorgiy CuriousGeorgiy Jan 26, 2024

Choose a reason for hiding this comment

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

Dropped this change, didn't notice it, sorry.

src/mpp/Dec.hpp Outdated Show resolved Hide resolved
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
src/mpp/Dec.hpp Outdated Show resolved Hide resolved
@drewdzzz drewdzzz assigned CuriousGeorgiy and unassigned drewdzzz Jan 24, 2024
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-85-optimize-optional-variant-decode branch 2 times, most recently from 8121598 to 9438157 Compare January 26, 2024 15:40
@CuriousGeorgiy CuriousGeorgiy removed their assignment Jan 26, 2024
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-85-optimize-optional-variant-decode branch from 9438157 to f8849de Compare January 26, 2024 15:42
@CuriousGeorgiy
Copy link
Member Author

CuriousGeorgiy commented Jan 26, 2024

@drewdzzz Interestingly, what the linter reports looks like a clang frontend bug, as if it assumes that the && is an rvalue reference declaration. What do you think?

Copy link
Collaborator

@drewdzzz drewdzzz left a comment

Choose a reason for hiding this comment

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

LGTM, please address my comments.
What's about linter, let's ignore it.
TBH, it would be nice to remove it from CI of make it non-failing: #92.

@@ -7,5 +7,6 @@ UseTab: Always

AccessModifierOffset: -8
AlwaysBreakAfterReturnType: TopLevel
ContinuationIndentWidth: 8
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is already in master.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rebased on master.

src/mpp/Dec.hpp Outdated
@@ -1172,6 +1172,9 @@ bool jump_read_key(BUF& buf, T... t)
return jump_find_key<PAIRS, FAMILY, PATH>(val, IS, buf, t...);
}

template <compact::Family FAMILY, size_t SUBRULE, class DST, class BUF>
constexpr bool is_object_readable_by_value_v = rule_by_family_t<FAMILY>::is_readable_by_value && std::is_assignable_v<DST, decltype(read_value<FAMILY, SUBRULE>(std::declval<BUF &>()))>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: it would be nice to move std::is_assignable_v to the next line - this one is too large.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the ColumnLimit option (120) to our .clang-format.

@drewdzzz drewdzzz assigned CuriousGeorgiy and unassigned drewdzzz Jan 31, 2024
The commit makes clang-format config more suitable to our codebase.
Currently, we always emplace an optional or variant in order to pass the
value they contain forward, as a reference. This is required for complex
nested types. However, if we are dealing with a scalar type, we can read
its value into the optional or variant in-place.

Closes tarantool#84
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-85-optimize-optional-variant-decode branch from f8849de to 3f65332 Compare February 1, 2024 08:02
@CuriousGeorgiy
Copy link
Member Author

CuriousGeorgiy commented Feb 1, 2024

Unit testing / default (macos-12, RelWithDebInfo) / testing and Unit testing / sanitizers (macos-12, Debug, clang) fails because of #75.

@alyapunov alyapunov merged commit 941ce12 into tarantool:master Feb 12, 2024
35 of 37 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.

Optimize optional and variant decoding
3 participants