7

I upgraded ReSharper and seeing an error that I was not present previously. I checked around, but found nothing about the error or the underlying issue it is flagging.

** Edit **: as pointed out below, it is actually the 'Heap Allocation Viewer' plugin, not ReSharper itself that is marking it as an error -- though that doesn't change the question itself.

Slow delegate creation: from interface 'IPluginHandler' method

this occurs during the subscription of a plugin handler to events on an event aggregator.

public void Subscribe(IPluginHandler subscriber)
{
  Executing += subscriber.OnExecuting;
  // -- additional subscriptions --
}

in the above code, Executing is an event and subscriber.OnExecuting is an appropriate event handler for the event.

To be clear, this is a ReSharper 'soft error' as the code will still build and run as expected.

So my question is what is the underlying issue the good people at JetBrains are flagging for me and what are the ramifications of it.

Thanks

David Culp
  • 5,354
  • 3
  • 24
  • 32
  • [this](http://stackoverflow.com/a/2082895/1244816) might explain some of it - I didnt read the hole thing though :) – Jens Kloster Oct 15 '14 at 19:47

1 Answers1

4

This JetBrains blog post has the same question in a comment.

The reply there says this:

Hi! This plugin also has one more internal feature: code inspection to show ‘slow’ (>10x slower) delegate instance creations for CLR x86 JIT. You can run this test (it creates delegates from various kinds of methods – virtual/interface/generic/etc) to see the difference in delegate creation performance.

Just as with allocations inspection – you shouldn’t care about this much until some performance snapshot in some hot path of your application shows long invocations of CLR internals. And just like with allocations – this inspections may (and will) produce false positives with new RuyJIT, for example.

Note that the linked test highlights the "slow" delegation creations with an arrow comment: <--.

Community
  • 1
  • 1
Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
  • I do have the `Heap Allocations Viewer' installed. I will update the question with the correct source of the error message. This explains why it is flagged -- although I'm going to reduce the severity to a warning. Any insight on why writing it this way is `>10x slower` than other ways? Just wanting to understand as deeply as possible. Thanks. – David Culp Oct 15 '14 at 20:20
  • That test is pretty self-contained. Try running it and seeing what results you get; then you can decide whether it's worth switching to a different style. – Matthew Strawbridge Oct 16 '14 at 13:30