How much does bytecode size affect JIT / Inlining / Performance?

I stuck in mscorlib to find out how the generic collection optimized their counts, and I came across this:

// in List<T>.Enumerator<T>
public bool MoveNext()
{
    List<T> list = this.list;
    if ((this.version == list._version) && (this.index < list._size))
    {
        this.current = list._items[this.index];
        this.index++;
        return true;
    }
    return this.MoveNextRare();
}

The stack size is 3, and the bytecode size must be 80 bytes. The naming of the method MoveNextRarehelped me on the toes, and there is a case with an error in it, as well as an empty case with an assembly, so obviously this violates the separation of concern.

I guess the method is MoveNextbroken down in such a way as to optimize the stack space and help JIT, and I would like to do the same for some of my bottlenecks, but without hard data I don't want my voodoo programming turning into a load-cult ;)

Thank! Florian

+3
2

, List<T>.Enumerator "" , : . ; , .

, BCL / , . BCL, ; , BCL NGEN- . , , - .

, : , , , - . , , , /, .

, - , .

+3

:

, , . . 80 , , inline ( 32 , , .NET 2.0).

, , , , .

( true).

, MoveNextRare false, , , , , JIT , jmp .

+1

Source: https://habr.com/ru/post/1733160/


All Articles