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

Extreme performance hit in several GetHashCode implementations #1073

Closed
1 of 2 tasks
znakeeye opened this issue Nov 20, 2018 · 2 comments · Fixed by #1178
Closed
1 of 2 tasks

Extreme performance hit in several GetHashCode implementations #1073

znakeeye opened this issue Nov 20, 2018 · 2 comments · Fixed by #1178

Comments

@znakeeye
Copy link

  • Bug
  • Feature

Version of ClosedXML
0.93.1

What is the current behavior?
Saving the workbook takes longer than on previous versions. Profiler tells us that 50% of the time is spent in GetHashCode() where most of the time is spent in ToUpperInvariant() (causing a subsequent GC):

https://github.com/ClosedXML/ClosedXML/blob/develop/ClosedXML/Excel/Style/XLFontKey.cs#L63
https://github.com/ClosedXML/ClosedXML/blob/develop/ClosedXML/Excel/Style/XLNumberFormatKey.cs#L15

There are a few more places. I think all GetHashCode() implementations needs an overhaul. In general, you must never allocate heap objects in GetHashCode! This is the perfect performance killer (especially if your application has high memory pressure).

Did this work in previous versions of our tool? Which versions?
It worked a bit better in 0.90.0. (But there we had crazy delays in IsEmpty() method instead.)

@igitur
Copy link
Member

igitur commented Nov 20, 2018

Sounds like you're halfway to contributing a PR. Keep going!

@Pankraty
Copy link
Member

Pankraty commented Apr 9, 2019

@znakeeye could you provide an example you used as a benchmark? I admit, that using ToUpperInvariant in GetHashCode was not a brilliant idea, but did not see 50% performance hit either.

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 a pull request may close this issue.

3 participants