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

Allocation free iterators for LinkedHashMap #3487

Conversation

wilbit
Copy link
Contributor

@wilbit wilbit commented Feb 8, 2024

fixes #3486

Possible breaking change: binary serializations of a session factory or a session from previous versions of NHibernate will not be deserializable with NHibernate 5.6.

@wilbit wilbit marked this pull request as ready for review February 8, 2024 12:09
@fredericDelaporte fredericDelaporte added this to the 5.6 milestone Feb 8, 2024
@fredericDelaporte fredericDelaporte removed this from the 5.6 milestone Feb 8, 2024
src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkedHashMap.cs Outdated Show resolved Hide resolved
@hazzik
Copy link
Member

hazzik commented Feb 9, 2024

@wilbit @fredericDelaporte would it be feasible to create a new class and use it?

@wilbit
Copy link
Contributor Author

wilbit commented Feb 9, 2024

@wilbit @fredericDelaporte would it be feasible to create a new class and use it?

Well, I see that LinkedHashMap is not used in public properties/fields/methods, so, technically it is feasible.
But also, LinkedHashMap implements IDeserializationCallback interface, and I'm not really sure what it brings. If nothing, that we are good to go and the only thing which is left is a new name and/or namespace for the internal class.

Another suggestion from me:

  1. keep the changes from this PR for a next major release (after some PR fixes, making LinkedHashMap internal and a rebase, see point 2)
  2. for an upcoming minor release fix the major part of LinkedHashMap creates enormous amount of memory traffic #3486 by casting LinkedHashMap to IDictionary<TKey, TValue> in BatchFetchQueue.GetCollectionBatchAsync (this should do a trick and foreach will use generic IEnumerator<> instead of non-generic IEnumerator).

@fredericDelaporte
Copy link
Member

Obsoleting LinkedHashMap entirely and adding an internal replacement seems to me as the best way to handle this.

But also, LinkedHashMap implements IDeserializationCallback interface, and I'm not really sure what it brings.

It is for supporting binary serialization. See also the Serializable attribute of the class. That thing is obsoleted in .Net Core for security reasons, but it is still used by many users especially under .Net Framework. The replacement class will have to be binary serializable too, because it will serve as state of many other classes which are serializable too. This allows to serialize the whole session and restore it later, by example.

@wilbit
Copy link
Contributor Author

wilbit commented Feb 9, 2024

@fredericDelaporte

  1. OK, where to put the new internal class and how to name it?
  2. about serialisation: would it work if somebody serialize a session with the current LinkedHashMap and deserialize with internal LinkedHashMap (which is, basically, would be a copy of the current LinkedHashMap in terms of fields...)?

@fredericDelaporte
Copy link
Member

  1. Why not LinkHashMap, same place?
  2. That will not work and will be a possible breaking change, but neither a binary one nor a source one, which is acceptable for a minor. We will have to warn in the release notes about the incompatibility of states serialized by version prior to the next minor with this next minor, and vice-versa.

@wilbit wilbit force-pushed the #3486-LinkedHashMap-GetEnumerator branch 2 times, most recently from 305588e to 35598c8 Compare February 10, 2024 15:19
@wilbit
Copy link
Contributor Author

wilbit commented Feb 10, 2024

added LinkHashMap, @hazzik , @fredericDelaporte

src/NHibernate.Test/UtilityTest/LinkedHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/UtilityTest/LinkHashMapFixture.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkHashMap.cs Outdated Show resolved Hide resolved
src/NHibernate/Util/LinkHashMap.cs Outdated Show resolved Hide resolved
@wilbit wilbit force-pushed the #3486-LinkedHashMap-GetEnumerator branch from 35598c8 to 79eb47f Compare February 10, 2024 19:17
@fredericDelaporte fredericDelaporte added this to the 5.6 milestone Feb 11, 2024
@wilbit wilbit force-pushed the #3486-LinkedHashMap-GetEnumerator branch from 79eb47f to ddb35a8 Compare February 11, 2024 20:26
@fredericDelaporte
Copy link
Member

Master branch protection requires the PR to be up-to-date with master. This PR has not edits for maintainers enabled, so, we cannot update it ourselves. Can you update it?

Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

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

Master branch protection requires the PR to be up-to-date with master. This PR has not edits for maintainers enabled, so, we cannot update it ourselves. Can you update the PR branch or enable edits for maintainers?
If you update it without enabling edits for maintainers, please also regenerate async files, as the automated task for this fails without this permission.

…ibernate#3486)

depricated LinkedHashMap class
made CollectionHelper.Remove method public (required fir unit tests) and removed it for netcore frameworks
@wilbit wilbit force-pushed the #3486-LinkedHashMap-GetEnumerator branch from d744821 to 3d08e08 Compare February 12, 2024 11:57
@wilbit
Copy link
Contributor Author

wilbit commented Feb 12, 2024

rebased, @fredericDelaporte

@fredericDelaporte fredericDelaporte enabled auto-merge (squash) February 12, 2024 21:37
@fredericDelaporte fredericDelaporte changed the title Allocation free iterators for LinkedHashMap WIP - Allocation free iterators for LinkedHashMap Feb 13, 2024
@fredericDelaporte fredericDelaporte changed the title WIP - Allocation free iterators for LinkedHashMap Allocation free iterators for LinkedHashMap Feb 13, 2024
@fredericDelaporte fredericDelaporte merged commit 5675110 into nhibernate:master Feb 13, 2024
22 of 23 checks passed
@wilbit wilbit deleted the #3486-LinkedHashMap-GetEnumerator branch February 14, 2024 11:31
wilbit added a commit to Intrigma/nhibernate-core that referenced this pull request Feb 14, 2024
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.

LinkedHashMap creates enormous amount of memory traffic
3 participants