Skip to content

include: interval_set: Relax requirements and enhance performance of interval sets#60250

Merged
aainscow merged 13 commits intoceph:mainfrom
aainscow:interval_set_enhancements
Jan 30, 2025
Merged

include: interval_set: Relax requirements and enhance performance of interval sets#60250
aainscow merged 13 commits intoceph:mainfrom
aainscow:interval_set_enhancements

Conversation

@aainscow
Copy link
Contributor

These commits enhance the insert/erase function of interval sets. The main intent is to enhance flexibility to callers, but in many cases, performance is likely also improved. Where performance is not improved, there should be no performance reduction.

There is also a new "align" method which allows for all intervals within a set to be aligned to an arbitrary alignment. This will be consumed by the new optimised erasure code.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@github-actions github-actions bot added the tests label Oct 10, 2024
@aainscow aainscow force-pushed the interval_set_enhancements branch from ef9cb0a to 14c5386 Compare October 10, 2024 16:32
@aainscow
Copy link
Contributor Author

jenkins test make check
jenkins test make check arm64

@aainscow
Copy link
Contributor Author

jenkins test make check

1 similar comment
@aainscow
Copy link
Contributor Author

aainscow commented Nov 1, 2024

jenkins test make check

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@aainscow
Copy link
Contributor Author

Updated to latest version of changes. I am basing this on top of the legacy_ec changes, as that is the priority order of the deliver. If this gets reviewed quickly and I get a request, I can re-order the commits.

Please only review the interval set changes here.

@github-actions github-actions bot removed the stale label Jan 17, 2025
const_iterator &operator*() {
return *this;
}
constexpr bool contains(K _off, K _len) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

unorthodox naming convention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent was something analagous to map::contains().

Happy to change to a better, more conventional name.

auto start = range_start();
auto end = range_end();

/* Only loop over the overlapping range of a */
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@aainscow aainscow force-pushed the interval_set_enhancements branch from 0134c8e to d9c8e93 Compare January 23, 2025 09:31
@aainscow aainscow force-pushed the interval_set_enhancements branch from 14920d0 to 055f85a Compare January 27, 2025 09:03

/** This insert method adds an interval into the interval map, with some
* caveats and restrictions. Inserts must be new interval or append to
* an existing interval. Adding an unsupported interval will result in an
Copy link
Contributor

Choose a reason for hiding this comment

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

s/an unsupported interval/an interval that intersects existing one/ ?

* caveats and restrictions. Inserts must be new interval or append to
* an existing interval. Adding an unsupported interval will result in an
* assert firing.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

"This function is intended for cases where intervals are required to never to overlap."
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will reword comment with the above recommendations

* @param len - the length of the interval being added.
* @param pstart (optional) returns the start of the resulting interval
* @param plen (optional) returns the length of the resulting interval.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Good stuff.

} else {
T old_len = 0;
T new_end = end;
for (;p != m.end() && end >= p->first; p = m.erase(p)) {
Copy link
Contributor

@aclamk aclamk Jan 27, 2025

Choose a reason for hiding this comment

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

Are we updating _size accordingly? I don't see it.
Update:
I see it now. old_len accumulates size that is in erased intervals.

//cout << "insert " << start << "~" << len << endl;
T new_len = len;
auto p = find_adj_m(start);
auto o = std::pair(start, len);
Copy link
Contributor

Choose a reason for hiding this comment

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

o is unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

// For some maps, inserting here corrupts p, so we need
// to insert, then recover p, so that we can delete it if needed.
p = m.insert(p, std::pair(end, pend-end));
--p;
Copy link
Contributor

Choose a reason for hiding this comment

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

return;?
There is noting to do beyond this point, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I will add.

Copy link
Contributor Author

@aainscow aainscow Jan 27, 2025

Choose a reason for hiding this comment

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

Doing so caused this test to fail:

// erase overlapping start by 1
  {
    ISet iset1, iset2;

    iset1.union_insert(3, 4);
    iset1.erase(1, 3);
    iset2.union_insert(4, 3);

    ASSERT_EQ(iset1, iset2);
  }

error:

Expected equality of these values:
  iset1
    Which is: { (3, 0), (4, 3) }
  iset2
    Which is: { (4, 3) }

So I have reverted this.

 These new utilities add the ability to:
   get_lower_range: Return the lowest interval iterator which covers the specified range
   get_start_off(): return the first offset in the interval.
   get_end_off(): Return the end offset of the last interval
   contains(): Return true if specified is entirely contained within the interval map.

Signed-off-by: Alex Ainscow <[email protected]>
…within range.

Determine, for a particular interval iterator, whether the specified range is entirely contained inside the interval.

Signed-off-by: Alex Ainscow <[email protected]>
…rely contained within the set.

Signed-off-by: Alex Ainscow <[email protected]>
…llow more flexibility.

The old insert was restrictive in ranges that could be added in. The new interface allows for a range to be added, whether it extends or joins other intervals.

Also change a number of interfaces to use the new insert.

Signed-off-by: Alex Ainscow <[email protected]>
The old erase would only allow intervals which exist to be erased. It is often useful to erase any interval, even if it does not exist or partially overlaps one or many intervals.

Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
A reviewer (see github) was concerned that the policing provided by insert() may have been required for some applications of insert_set. As such, I have re-instated the old insert method and instead refactored "union_insert". IU have also enhanced the comments.

Signed-off-by: Alex Ainscow <[email protected]>
Here we duplicate all the original tests which used "insert" to verify they also pass with "union_insert". All new tests are modified to use "union_of" and "union_insert"

Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
Copy link
Contributor Author

jenkins test make check

@aainscow aainscow force-pushed the interval_set_enhancements branch from b5369d9 to adaafdd Compare January 27, 2025 15:32
Copy link
Contributor

@aclamk aclamk left a comment

Choose a reason for hiding this comment

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

Fine stuff.

@aainscow
Copy link
Contributor Author

jenkins test make check

@aainscow
Copy link
Contributor Author

jenkins test make check arm64

@aainscow
Copy link
Contributor Author

jenkins test make check

@aainscow
Copy link
Contributor Author

jenkins test make check arm64

@aainscow aainscow merged commit 4c6831e into ceph:main Jan 30, 2025
12 checks passed
@aainscow aainscow added the no-backport-required Label that can be optionally added to show that we do not need to backport. label Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/ops common core crimson no-backport-required Label that can be optionally added to show that we do not need to backport. performance tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants