Impressed

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jul 27 12:14:02 PDT 2012


On Fri, Jul 27, 2012 at 09:04:06PM +0200, Stuart wrote:
> On Friday, 27 July 2012 at 16:28:50 UTC, Dmitry Olshansky wrote:
> >
> >But this advantage is unimportant since arbitrary deep recursion is a
> >security risk (especially for servers that typically use threads with
> >tiny stacks).
> 
> I would like to point out here that the example VB.NET code I just
> gave for lazy-populating a list of all files on a drive uses NO
> recursion whatsoever.
> 
> Recursion isn't just a security risk - it's a performance hit as well.

I'm pretty sure Yield has a performance hit as well, 'cos it amounts to
an implicit context-switch between two fibers. Once translated to the
machine level, there is no such thing as yielding; you have to save your
current state and return control to the caller, then recover your state
when you get called again.

Of course, from what I understand, C# runs on a VM, correct? If so, this
performance hit is probably hidden in the VM overhead, since the VM is
already keeping track of states anyway, so the cost of tracking multiple
states is absorbed into the VM's overall overhead. So you probably won't
_notice_ the cost, but it's definitely there.


T

-- 
People walk. Computers run.


More information about the Digitalmars-d mailing list