Skip to content

Implement DecodeWithMemTracking for BoundedBTreeSet#915

Merged
bkchr merged 7 commits intoparitytech:masterfrom
dimartiro:master
Jun 18, 2025
Merged

Implement DecodeWithMemTracking for BoundedBTreeSet#915
bkchr merged 7 commits intoparitytech:masterfrom
dimartiro:master

Conversation

@dimartiro
Copy link
Contributor

Description

Implement DecodeWithMemTracking for BoundedBTreeMap

bkchr
bkchr previously approved these changes May 29, 2025
@bkchr bkchr requested a review from serban300 May 29, 2025 20:12
Copy link
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

From what I understand BoundedBTreeSet doesn't call on_before_alloc_mem when decoding and we need this in order to support DecodeWithMemTracking. We should use the same approach as in #906

@dimartiro
Copy link
Contributor Author

From what I understand BoundedBTreeSet doesn't call on_before_alloc_mem when decoding and we need this in order to support DecodeWithMemTracking. We should use the same approach as in #906

I'm not sure if I undertand it. Could you please point me to where on_before_alloc_mem is called in that PR?

@serban300
Copy link
Contributor

Could you please point me to where on_before_alloc_mem is called in that PR?

It's not specifically called in that PR. It's called in BTreeMap::decode() which is used in the PR: https://github.com/paritytech/parity-scale-codec/blob/5c51d86fc3d105e4846f3c0ddb22d26d6d11eea4/src/codec.rs#L1276

And for BtreeSet it's the same

@bkchr bkchr dismissed their stale review May 30, 2025 21:22

Not correct

@dimartiro
Copy link
Contributor Author

It's not specifically called in that PR. It's called in BTreeMap::decode() which is used in the PR: https://github.com/paritytech/parity-scale-codec/blob/5c51d86fc3d105e4846f3c0ddb22d26d6d11eea4/src/codec.rs#L1276

And for BtreeSet it's the same

Ok I think I got it, will try to address it today. Thanks!

@dimartiro
Copy link
Contributor Author

From what I understand BoundedBTreeSet doesn't call on_before_alloc_mem when decoding and we need this in order to support DecodeWithMemTracking. We should use the same approach as in #906

@serban300 I basically did the same as in #906. I'm not sure if I can reuse the same PrependCompactInput from bounded_btree_map, so I redefined it in bounded_btree_set.
I'll wait for your feedback.

@serban300
Copy link
Contributor

@serban300 I basically did the same as in #906. I'm not sure if I can reuse the same PrependCompactInput from bounded_btree_map, so I redefined it in bounded_btree_set.
I'll wait for your feedback.

Ok, thanks ! But please let's try to reuse PrependCompactInput somehow. We should be able to declare it in a shared file.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Please add some test

@dimartiro
Copy link
Contributor Author

please let's try to reuse PrependCompactInput somehow. We should be able to declare it in a shared file.

@serban300 Done! sorry for the delay, was harder than I expected with all the macro magic 🪄

Please add some test

@bkchr I even added more tests for jam cases than didn't exist before.

Let me know if there is something missing guys, and thanks for your time!

@dimartiro dimartiro requested review from bkchr and serban300 June 5, 2025 00:44
@serban300
Copy link
Contributor

Sorry, I was a bit busy last week. I will try to take a look these days

Copy link
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

LGTM ! Just left a nit.

@dimartiro dimartiro requested a review from serban300 June 16, 2025 13:09
@dimartiro
Copy link
Contributor Author

@bkchr I believe the remaining failing tests are not related to this change, right?

@bkchr bkchr merged commit 34c85f5 into paritytech:master Jun 18, 2025
7 of 11 checks passed
@dimartiro
Copy link
Contributor Author

@bkchr could you please create a new release with this change?

@serban300
Copy link
Contributor

I can do that, but probably tomorrow

@dimartiro
Copy link
Contributor Author

I can do that, but probably tomorrow

No rush! Thank you 🙏🏻

@serban300
Copy link
Contributor

Done: https://crates.io/crates/bounded-collections/0.3.1

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.

3 participants