Skip to content

Add a shortcut to reduce Transaction.Current reads #2213

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

Since some users complain of a reduction performance with transactions and NHibernate v5.x, I have a look in which changes may have an impact. See here and here for the reports on performance losses.

In v4.x and previous versions, there was a shortcut avoiding to read Transaction.Current when the session was already having a transaction context.

So I have made a bench for comparing accessing the session transaction context vs the current transaction. The later is around twenty times slower on my setup.

As a consequence I propose re-adding that shortcut.

(Still the first thread states the negative impact occurs also with regular transactions, while upgrading from NHv3.3. But with regular transactions, there is never a transaction context on the session, so the shortcut is not taken, and the current transaction is read. And in v3.3, the default transaction factory was already the system transaction one. The only explanation I could have would be that the performance of reading the current transaction itself has also dropped with .Net Framework v4, those old projects upgrades having probably also upgraded from an old framework.)

@fredericDelaporte
Copy link
Member Author

CodeFactor:

Insert parentheses within the conditional AND and OR expressions to declare the operator precedence.

Seriously? That is beginner level basic knowledge... I am reluctant to add parenthesis for making explicit such a trivial operator precedence.

@hazzik
Copy link
Member

hazzik commented Sep 15, 2019

It's really hard to read because the logic is inverted (gorge of negations and conjunctions). Adding parenthesis will not improve readability though. Either invert if statement or extract a method. I would prefer later one.

@hazzik hazzik force-pushed the reduce-sysTran-impact branch from 55ec205 to cca5e7f Compare September 15, 2019 21:30
@hazzik hazzik force-pushed the reduce-sysTran-impact branch from cca5e7f to 86b7291 Compare September 15, 2019 21:31
@hazzik hazzik added this to the 5.3 milestone Sep 15, 2019
@fredericDelaporte fredericDelaporte merged commit 03500af into nhibernate:master Sep 16, 2019
@fredericDelaporte fredericDelaporte deleted the reduce-sysTran-impact branch September 16, 2019 18:24
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