On 17.02.21 21:43, Ryan Joseph via fpc-pascal wrote:
So where is your 10% performance hit coming from then?

on init:

InitInterfacePointers or TInterfacedObject.AfterConstruction?


I benchmarked it years ago, I do not remember the details.

But InitInterfacePointers was bad. Just look at it:

      procedure InitInterfacePointers(objclass: tclass;instance : pointer);

        var
          ovmt: PVmt;
          i: longint;
          intftable: pinterfacetable;
          Res: pinterfaceentry;
        begin
          ovmt := PVmt(objclass);
          while assigned(ovmt) and {$ifdef VER3_0}(ovmt^.vIntfTable <> @emptyintf){$else}assigned(ovmt^.vIntfTable){$endif} do
            begin
              intftable:=ovmt^.vIntfTable;
              {$ifdef VER3_0}
              if assigned(intftable) then
              {$endif VER3_0}
              begin
                i:=intftable^.EntryCount;
Res:=@intftable^.Entries[0];
                while i>0 do begin
                  if Res^.IType = etStandard then
                    ppointer(@(pbyte(instance)[Res^.IOffset]))^:=
                      pointer(Res^.VTable);
                  inc(Res);
                  dec(i);
                end;
              end;
              ovmt:=ovmt^.vParent;
            end;
        end;


But reusing objects avoids calling all the functions from create. (but reusing is also expensive, besides the memory increase, it needs a free list and thread safe handling of the head of the list)


otherwise, during the wrapper function? As Sven pointed out the ref counting 
happens with records operators also. ARC is general may just be slow if you 
implement it everywhere.


The wrapper function was not included in the 10%


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to