Skip to content

Implement concurrent data structures for Issue #2235#6897

Merged
hkaiser merged 21 commits intoTheHPXProject:masterfrom
guptapratykshh:concurrent-data-structures
Feb 20, 2026
Merged

Implement concurrent data structures for Issue #2235#6897
hkaiser merged 21 commits intoTheHPXProject:masterfrom
guptapratykshh:concurrent-data-structures

Conversation

@guptapratykshh
Copy link
Copy Markdown
Contributor

Fixes #2235

Proposed Changes

  • implemented concurrent_vector, concurrent_unordered_map, and concurrent_unordered_setusing hpx::shared_mutex for thread safe access(reader-writer lock)
  • added concurrent_queue as an alias to hpx::lockfree::queue to provide TBB-compatible interface
  • added tbb_hash and tbb_hasher aliases in hash.hpp for compatibility

Any background context you want to provide?

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch from 21b5c5e to 0e8bded Compare February 11, 2026 14:47
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

However, I believe the data structures you added are not thread-safe in the sense that they expose non-safe iterators and allow direct access to the stored data elements through unsafe access functions (like operator[]()).

@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch from 0e8bded to 9bed640 Compare February 11, 2026 15:07
Comment thread libs/core/concurrency/include/hpx/concurrency/hash.hpp Outdated
@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch 6 times, most recently from 06c91ef to ce0e874 Compare February 12, 2026 08:14
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Similar comments apply to the other data structures you proposed.

Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch from 9b60756 to 355df91 Compare February 12, 2026 18:41
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp Outdated
Comment thread libs/core/concurrency/tests/unit/concurrent_data_structures.cpp Outdated
Comment thread libs/core/concurrency/tests/unit/concurrent_data_structures.cpp Outdated
Comment thread libs/core/concurrency/tests/unit/concurrent_data_structures.cpp
@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch 4 times, most recently from 4c4a452 to cf3f1e1 Compare February 13, 2026 17:08
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/deque.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp Outdated
Comment thread libs/core/concurrency/include/hpx/concurrency/deque.hpp Outdated
@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch 2 times, most recently from b7d3b5a to 5218e5a Compare February 14, 2026 15:23
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

@guptapratykshh This pr starts to get in shape. There is still the issue fo the iterator interface exposed by the new concurrent_vector. Also we need to make a decision on whether to (conditionally) support the transparent key functionality introduced in C++26. I'd love to hear your oppinion on the latter.

@guptapratykshh
Copy link
Copy Markdown
Contributor Author

guptapratykshh commented Feb 14, 2026

thanks for the feedback,on the iterators, you are right. the current std::vector wrapper is definitely a bottleneck. i will redo internal storage using a segmented design to ensure iterators stay stable even when the vector grows

i did also support transparent keys. avoiding temporary allocations on lookups is a clear performance win that fits HPX perfectly

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Feb 14, 2026

thanks for the feedback,on the iterators, you are right. the current std::vector wrapper is definitely a bottleneck. i will redo internal storage using a segmented design to ensure iterators stay stable even when the vector grows

I don't think we need iterators to be exposed from the concurrent_vector. You don't have them exposed from the associative data structures either.

i did also support transparent keys. avoiding temporary allocations on lookups is a clear performance win that fits HPX perfectly

If you want to add those, you will need to add a feature test that ensures transparent keys are supported by the underlying standard containers.

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Feb 14, 2026

inspect is unhappy still as well:

/libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_map.hpp: *I* missing #include (cstddef) for symbol std::size_t on line 38
/libs/core/concurrency/include/hpx/concurrency/concurrent_unordered_set.hpp: *I* missing #include (cstddef) for symbol std::size_t on line 36
/libs/core/concurrency/include/hpx/concurrency/concurrent_vector.hpp: *I* missing #include (cstddef) for symbol std::size_t on line 35, *I* missing #include (hpx/modules/errors.hpp) for symbol HPX_THROW_EXCEPTION on line 62
/libs/core/concurrency/tests/performance/concurrent_structure_performance.cpp: *I* missing #include (utility) for symbol std::pair on line 58, *Lic*

@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch from 177fe5e to 0588fe6 Compare February 18, 2026 04:48
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Feb 18, 2026

There are still open comments, please have a look. Also, please rebase this onto current master to resolve potential compilation problems.

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…ents

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…n signature

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
- Removed non-thread-safe random access iterators from concurrent_vector.
- Added thread-safe for_each iteration API (consistent with Map/Set).
- Modified grow_by to return the index (size_type) instead of an iterator.
- Added unit tests for new for_each and grow_by behavior in vector.

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…e exports

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…ke-format

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…plication

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
@guptapratykshh guptapratykshh force-pushed the concurrent-data-structures branch from 0588fe6 to 0adb5f4 Compare February 18, 2026 16:59
@hkaiser hkaiser changed the title [WIP] Implement concurrent data structures for Issue #2235 Implement concurrent data structures for Issue #2235 Feb 18, 2026
@guptapratykshh
Copy link
Copy Markdown
Contributor Author

@hkaiser i think this is ready to be shipped, if any reviews will look into that

Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@hkaiser hkaiser merged commit 48702be into TheHPXProject:master Feb 20, 2026
108 of 111 checks passed
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Feb 20, 2026

@guptapratykshh Thank you for your patience with this! Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concurrent data structures support

3 participants