Skip to content

Prevent calling UpdateTimestampsCache if query spaces are not changed #2120

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
merged 7 commits into from
Feb 20, 2020

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Apr 11, 2019

Fixes #2115

if (spaces.Count == 0)
return;

Lock.EnterUpgradeableReadLock();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is, most-likely, invalid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is invalid. I will try to update the async generator to support it. I think that it is better to use EnterReadLock instead EnterUpgradeableReadLock as here doesn't seem to be needed. Also, the async version of EnterUpgradeableReadLock is harder to implement and it is also not available in the latest AsyncEx library.

Copy link
Member Author

@hazzik hazzik Apr 17, 2019

Choose a reason for hiding this comment

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

This lock upgrades to write lock a few lines below (in SetSpacesTimestampAsync).

I highly disagree with the decision to drop upgradable locks support from AsyncEx and with the reasoning behind them.

To be honest I’m biased against author of AsyncEx after they claimed that AsyncLocal does not impact performance in any how; which turned to be completely false claim in practice. So I do not accept their reasoning for dropping the upgradable locks support "developers do not need them" as valid.

I believe here is a perfect example of a need of upgradable read locks for high performance. Because we do not know the exact implementation of L2 Cache we assume the worst: it is slow. For example, L2 cache can be non local so there could be some latency in reading data. We want to allow people to read data while they are reading other data.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, I missed that. Wouldn't be better to just use (Enter\Exit)WriteLock instead of (Enter\Exit)UpgradeableReadLock inside PreInvalidate and Invalidate methods and remove the lock from the SetSpacesTimestamp as in this case it will always be upgraded, except when canceling the cancellation token when SetSpacesTimestampAsync is called which is very hard to happen.

About AyncEx, I do agree that their reasoning for droping the upgradable locks is not valid. Anyway, we will have to write our own implementation in order to avoid adding external dependencies and if we are able to avoid upgradeable locks we would have an easier job for implementing our own AsyncReadWriteLock.

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.

Long overdue approval, sorry for the delay.

@fredericDelaporte fredericDelaporte merged commit 97d2184 into nhibernate:master Feb 20, 2020
@hazzik hazzik deleted the gh2115 branch October 5, 2022 08:27
@hazzik hazzik restored the gh2115 branch October 5, 2022 08:29
@hazzik hazzik deleted the gh2115 branch October 5, 2022 08:30
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.

Statefull Session commit performance issue when nothing changed and second level cache with query cache enabled
5 participants