Skip to content

Comments

Distributed size for concurrent ordered containers#1803

Merged
kboyarinov merged 20 commits intomasterfrom
dev/kboyarinov/distributed_size_combined
Feb 24, 2026
Merged

Distributed size for concurrent ordered containers#1803
kboyarinov merged 20 commits intomasterfrom
dev/kboyarinov/distributed_size_combined

Conversation

@kboyarinov
Copy link
Contributor

@kboyarinov kboyarinov commented Aug 4, 2025

Description

Add a comprehensive description of proposed changes

Fixes # - issue number(s) if exists

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

key_compare my_compare;
random_level_generator_type my_rng;
atomic_node_ptr my_head_ptr;
std::atomic<size_type> my_size;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is also an option to keep my_size, reserve a flag bit in it and use it for optimizing consecutive calls to size() by saving the result of combine into my_size and marking it as "changed" in the insertion.
I did not investigate potential performance effects from CAS operations on my_size, just wanted to save the idea.

@kboyarinov kboyarinov added this to the 2022.3.0 milestone Aug 27, 2025
@kboyarinov kboyarinov modified the milestones: 2022.3.0, 2022.4.0 Sep 5, 2025

void set_size(size_type size) { my_local_size.store(size, std::memory_order_relaxed); }
void increment_size() {
my_local_size.store(local_size() + 1, std::memory_order_relaxed);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use atomic std::atomic<>::fetch_add instead of load and store pair?

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that is done to avoid locking the cache line, since only one thread writes to this atomic anyway. I think that it would be good to leave a small comment that explains the motivation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely, the comment will be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the comment

Comment on lines 2 to 3
Copyright (c) 2019-2025 Intel Corporation
Copyright (c) 2025 UXL Foundation Contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the copyright is outdated hier and in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

atomic_node_ptr my_head_ptr;
std::atomic<size_type> my_size;
std::atomic<size_type> my_max_height;
mutable ets_type my_ets;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is mutable needed here because of ets::combine method being non-const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added the comment


using random_level_generator_type = typename container_traits::random_level_generator_type;
using thread_data_type = skip_list_thread_data<random_level_generator_type, size_type>;
using ets_type = tbb::enumerable_thread_specific<thread_data_type>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should not this be the ETS with ets_suspend_aware?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I agree that it will be more flexible from the user standpoint.
Applied to check performance effects.

Copy link
Contributor

@aleksei-fedotov aleksei-fedotov left a comment

Choose a reason for hiding this comment

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

I think it is good enough in general.

Found just a small oversight in the comment.

Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
@kboyarinov
Copy link
Contributor Author

Latest performance measurements (LibCuckoo universal benchmark) confirmed the performance improvement on the latest version of the patch. So, I guess it can be merged.

@kboyarinov kboyarinov merged commit f71cccc into master Feb 24, 2026
29 checks passed
@kboyarinov kboyarinov deleted the dev/kboyarinov/distributed_size_combined branch February 24, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants