Skip to content

Clean-up of TypeFactory #1483

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

Merged

Conversation

fredericDelaporte
Copy link
Member

  • Removing undue global thread sync and concurrency checks, the concurrent dictionary handles already that.
  • Removing useless singleton pattern, likely a remnant of Java port.

Many static methods of TypeFactory and SqlTypeFactory for obtaining types were marked with [MethodImpl(MethodImplOptions.Synchronized)], causing a global lock of the type. This was done for protecting the cache of types from concurrent writes. But those methods are since some times implemented with a concurrent dictionary, and are no more needing such a strict synchronization, bad for performances.

This change may allow duplicated types to be build when they are not already cached, but only one will be yielded and cached. Those types are lightweight objects without critical resources, having sometime built a dup will not cause troubles.

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented Dec 12, 2017

I have cancelled the build and enabled concurrency tests. This is done by rewriting MultiThreadRunner in order for it to allow detection of failed threads. The tests already using it had thus to be adapted.
One test, intended for testing the obsolete ThreadSafeDictionary and "fixed" by testing the native ConcurrentDictionnay instead, has been dropped.

@hazzik
Copy link
Member

hazzik commented Dec 13, 2017

it's really hard to understand what's been changed in this PR. I personally think that fields renaming and method orderings should be commited as separate changeset without others changes.

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented Dec 14, 2017

fields renaming and method orderings

There is no such things in TypeFactory.cs changes. Three methods have been suppressed because they were useless (and actually worst than useless: enforcing a bad way of using a concurrent dictionary), the others are just rewritten to correctly use the concurrent dictionary.

If that is the changes in MultiThreadRunner which cause issue to you, I can drop its separated commit, going back to the previous situation: no actual test of parallel usages.

@hazzik
Copy link
Member

hazzik commented Dec 14, 2017

I just cited the neighboring PR ;)

@fredericDelaporte
Copy link
Member Author

Yes I know it comes from bahusoid, but does it really apply here? I could remove some syntax update and whitespace fixes, but their are not numerous and not hard to identify.

 * Removing undue global thread sync and concurrency checks, the concurrent dictionary handles already that.
 * Removing useless singleton pattern, likely a remnant of Java port.
@fredericDelaporte fredericDelaporte added this to the 5.1 milestone Jan 15, 2018
@fredericDelaporte fredericDelaporte merged commit a46b2d5 into nhibernate:master Jan 16, 2018
@fredericDelaporte fredericDelaporte deleted the typeFactoryCleanUp branch January 16, 2018 11:43
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.

2 participants