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

Feature/concurrent node containers #271

Merged
merged 30 commits into from
Aug 25, 2024

Conversation

joaquintides
Copy link
Member

Adds boost::concurrent_node_(map|set). The following is not part of this PR and will be done later:

  • Upadate concurrent benchmarks to include the new node-based containers.
  • Include (insert|emplace)_and_visit operations. This is still under discussion (conversation on the #boost-unordered Slack group).

@joaquintides joaquintides requested review from pdimov and cmazakas August 5, 2024 11:21
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

1 similar comment
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@@ -1458,6 +1458,11 @@ table_core:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,2>
using stats=table_core_stats;
#endif

#if defined(BOOST_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
Copy link
Member

Choose a reason for hiding this comment

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

A maybe-uninitialized warning? What did the warning say, out of curiosity?

Historically, this might mean we need a launder() call somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is with this type of constructor:

  table_core(
    std::size_t n=default_bucket_count,const Hash& h_=Hash(),
    const Pred& pred_=Pred(),const Allocator& al_=Allocator()):
    hash_base{empty_init,h_},pred_base{empty_init,pred_},
    allocator_base{empty_init,al_},arrays(new_arrays(n)),
    size_ctrl{initial_max_load(),0}
    {}

As it happens, arrays (in arrays(new_arrays(n))) is a non-static member function that uses the internal allocator, but not other data members that have not been initialized yet (namely size_ctrl), but the compiler's analysis is not as fine-grained as that, seemingly. The situation would be similar to this example:

struct X
{
  // calculate_b() called before X is fully initialized, but it's OK as b and c do not
  // form part of the calculation.
  
  X(int a_): a(a_), b(calculate_b()), c(0){}

  int calculate_b() { return 2*a; }
  
  int a;
  int b;
  int c;
};

What I find surprising is that this warning didn't trigger before, maybe it only happens for complex, non-inlined scenarios.

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 97.42268% with 20 lines in your changes missing coverage. Please review.

Project coverage is 98.02%. Comparing base (1d1f0d3) to head (c191c78).
Report is 1 commits behind head on develop.

Files Patch % Lines
include/boost/unordered/detail/foa/node_handle.hpp 58.33% 10 Missing ⚠️
include/boost/unordered/concurrent_node_map.hpp 98.08% 5 Missing ⚠️
include/boost/unordered/concurrent_node_set.hpp 97.88% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #271      +/-   ##
===========================================
- Coverage    98.07%   98.02%   -0.05%     
===========================================
  Files          152      157       +5     
  Lines        20636    21369     +733     
===========================================
+ Hits         20238    20948     +710     
- Misses         398      421      +23     
Files Coverage Δ
...de/boost/unordered/detail/foa/concurrent_table.hpp 99.43% <100.00%> (-0.12%) ⬇️
include/boost/unordered/detail/foa/core.hpp 99.54% <ø> (+<0.01%) ⬆️
...ude/boost/unordered/detail/foa/node_map_handle.hpp 100.00% <100.00%> (ø)
...ude/boost/unordered/detail/foa/node_set_handle.hpp 100.00% <100.00%> (ø)
include/boost/unordered/unordered_node_map.hpp 99.23% <100.00%> (-0.01%) ⬇️
include/boost/unordered/unordered_node_set.hpp 99.01% <100.00%> (+<0.01%) ⬆️
test/cfoa/assign_tests.cpp 100.00% <100.00%> (ø)
test/cfoa/clear_tests.cpp 98.27% <ø> (ø)
test/cfoa/common_helpers.hpp 100.00% <ø> (ø)
test/cfoa/constructor_tests.cpp 99.43% <100.00%> (+<0.01%) ⬆️
... and 25 more

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d1f0d3...c191c78. Read the comment docs.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

/* GCC lifetime analysis incorrectly warns about uninitialized
* allocator object under some circumstances.
*/
if(empty())__builtin_unreachable();
Copy link
Member

Choose a reason for hiding this comment

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

This seems fishy to me. Is calling get_allocator undefined behavior when empty()? Is the removal of the noexcept on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • get_allocator on an empty node handle is UB, see here.
  • I removed noexcept on purpose cause the standard does not have it (presumably because of the Lakos rule on narrow-contract functions). This removal is not materially connected to the __builtin_unreachable addition, really.
  • The __builtin_unreachable addition is due to GCC incorrectly, and not systematically, warning about potentially uninitialized node handles here and here: adding __builtin_unreachable helped but not always, so I was forced to also add this. I don't see any problem with foolproofing node_handle_base::get_allocator as I've done, but if it looks smelly/ugly I can just remove it, of course --the GCC pragma in node_handle_allocator_tests.cpp has us covered.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@k3DW
Copy link
Collaborator

k3DW commented Aug 24, 2024

I caused the merge conflict with my other PR, so @joaquintides gave me permission to resolve it here.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://271.unordered.prtest2.cppalliance.org/libs/unordered/doc/html/unordered.html

@joaquintides joaquintides merged commit f734e39 into develop Aug 25, 2024
89 of 94 checks passed
@joaquintides joaquintides deleted the feature/concurrent-node-containers branch August 25, 2024 16:35
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.

5 participants