Reduce JIT and type load overhead in WinForms startup (dotnet/corefx#39315)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 9 Jul 2019 21:37:53 +0000 (23:37 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Jul 2019 21:37:53 +0000 (23:37 +0200)
commitf25cef14ccf598c13382653b6532ed15d6a403d1
tree06177775a82a33ea4e6b9b240abb24a881d58f80
parentc7c606cfec20b8588887dd790a8f1158181240ec
Reduce JIT and type load overhead in WinForms startup (dotnet/corefx#39315)

https://github.com/dotnet/corefx/pull/37853#discussion_r300974699

The existing code was trading startup perf for throughput in a codepath that is unlikely to be executed commonly. The common scenario is that the `UserPreferencesChanging` event is not fired for the entire lifetime of the app (I left an app listening for this event running for an hour of normal work and never once was the event fired. I then changed system colors to force it).

To set up the high performance path, we have to load two unique `Func` instantiations and JIT a generic method. It's likely the throughput optimization won't pay for itself in terms of CPU cycles even if someone does change quite a few settings.

Commit migrated from https://github.com/dotnet/corefx/commit/3c37204d825c567ead19d8b2d9513efca25dd7c8
src/libraries/Common/src/System/Drawing/KnownColorTable.cs