Jump to content

Stefan Glienke

Members
  • Content Count

    1370
  • Joined

  • Last visited

  • Days Won

    130

Posts posted by Stefan Glienke


  1. I just noticed yet another time that selecting text from a post contains invisible characters - in this particular case I selected the URL from this post:

    by selecting from the starting h of http and moved the mouse a bit to the right and down so it selected the entire rest of the line.

     

    When I then clicked "go to" in my context menu (using Chrome) I got a 404 which confused me because the url is valid. I eventually found out that the selected text contained some UTF-8 BOM bytes at the end.

    Also when inspecting the elements it showed this:

     

    image.png.1b7438520860f3c7ddf8d4b240c67617.png

     

    which according to a google search is a zero width no-break space - turning off JS makes them disappear.

    The weird spans are also shown with Firefox however selecting the text does not cause it to contain garbage.

     

    Edit: I found what is causing the spans with the ZWNBSP - its the "quote selection" popup that leaves them there. So the issue I am describing here only happens when you selected the text, deselected and then selected again to contain the hidden ZWNBSP character.


  2. There is no such function in the RTL, its called UIntToStr and has two overloads for Cardinal and UInt64 - it's there at least since Delphi XE and works there as far as I can tell.

     

    I don't immediately remember a bug with that function (which does not mean anything) - but I know there was a bug with the opposite related to System.Val which was fixed in XE4 - see https://stackoverflow.com/q/6077258/587106


  3. On 2/2/2019 at 4:57 PM, Allen@Grijjy said:

    The way we do it is we created a small class to inherit from ITestListener and ITestListenerX that acts like a simple remote TCP client on the mobile device to intercept the results of the tests as they happen and a simple TCP server with a GUI on Windows using Indy that the client connects to display the tests.

    That's exactly what TestInsight does...


  4. Seems to be written in 10.3 where TStringDynArray is declared as TArray<string> whereas before it was a dedicated array of string.

    My suggestion is to not use the dynamic array types from System.Types anywhere and wherever you work with any RTL functions that use them, hardcast in order to be compatible to <10.3.


  5. There clearly is a race condition somewhere in the SeaMM.dll - either it works, or it raises AVs until it stackoverflows or it gets stuck inside a loop (keep clicking Start/Stop if it does not raise AV/SO) with these instructions:

     

    00007FF9B59FB520 664103D0         add dx,r8w
    00007FF9B59FB524 488BD9           mov rbx,rcx
    00007FF9B59FB527 66895774         mov [rdi+$74],dx
    00007FF9B59FB52B 488B01           mov rax,[rcx]
    00007FF9B59FB52E 488BC8           mov rcx,rax
    00007FF9B59FB531 4883C801         or rax,$01
    00007FF9B59FB535 4883F801         cmp rax,$01
    00007FF9B59FB539 75E5             jnz $00007ff9b59fb520

    Anyway as you seem to be the author/modifier of that code you should be able to debug that yourself.

    As soon as I put a breakpoint I could not get the AV - which confirms my guess about the race condition.


  6. Try removing the inline from function TIocpCrossSocket._NewIoData: PPerIoData; - possible that it trips over something there - apart from that I don't see how this could be related to anonymous methods. The variable assigned to is a local variable of a regular method and there are no anonymous methods in procedure TIocpCrossSocket._NewAccept(AListen: ICrossListen); that could change the location of that variable to somewhere else than the stack.

     

    Possible that the TBB code is sensitive to some garbage value in a volatile register that it does not properly check for.


  7. The approach to store Min and Max Value for sets does not work as sets in Delphi can be max size of 32 Byte (set of Byte) - good luck storing that in an Integer.

     

    The core idea though is nice - I think I have also done this before: use a generic type as storage for type related values.


  8. 5 minutes ago, Микола Петрівський said:

    Second link counts COW as immutable. While in Delphi community we usually treat it as attribute of mutable strings.

    Technically in Delphi strings are only mutable if they have a ref-count of 1, otherwise a copy happens.

    And while it might be convenient to the average developer if you actually look under the hood how much instructions and implicit heap allocations happen if you are not paying attention and naively work with strings you will be scared.


  9. 7 hours ago, Silver Black said:

    You didn't answer me: have you got the patch and the IDE fixes I mentioned? Any improvement?

    - the december patch does not mention anything about IDE stability fixes

    - IDE FixPack is not yet released and only alpha state (and even may cause issues - well more precisely the CompilerFixPack for 64bit windows does - see https://quality.embarcadero.com/browse/RSP-23405)

    - DDevExtensions does not fix IDE stability issues but adds productivity features

     

    I am only using 10.3 for toying and it more often crashes (well the compiler gets into some state where it produces nothing than some internal errors after it eventually brings down the IDE) - and yes I am using the IDEFixPack alpha because I am not producing any production software with it.


  10. As I mentioned before the jump optimization highly depends on the CPU - and of course it only affects methods that are being called and not inlined. When inlined you have a jump no matter what. Only when being called it can benefit from two returns in each branch to avoid the jump over. 

    Edit: Clarification - when inlined, putting the raise first is better because it only needs one conditional jump instruction (jump over raise call or not), taken in the common case.

    When putting it below it still has the conditional jump which is not taken in the common case but has a jump over this code in all cases when the common path is being used.

     

    What I would do regardless is to put the exception raising code into a non inlined subroutine to reduce generated binary code because then the code being jumped over is just a call (5bytes on 32bit).

     

    Another optimization is to make use of {$POINTERMATH ON} for your pointer type because then you can write:

     

      Target := @FData;
      Target[FCount] := AItem;

     

    And another neat trick to check if an Integer index is in range that only uses one compare:

     

    if Cardinal(AIndex) >= Cardinal(FCount) then

     

    By the way - putting all cases into the same binary often influences results and even the order in which you execute them changes the output - I had a similar case where just changing order made one or another faster or slower.

    Measuring performance is not as easy at it sounds :)

    • Like 3

  11. Any pure speed benchmark would be rather useless/biased because it all depends on what you are in fact doing apart from creating the list. If this workload is small enough the object creation would mean a significant overhead.

    In the end you would just benchmark object creation. Also what affects performance is pointer indirection and memory, CPU cache. In some micro benchmark this would not occur as all memory fits into L2 or even L1 cache.

     

    Benchmarking the effect on heap usage/fragmentation is way harder because that cannot be done in pure isolation and usually only manifests in production.

     

    FWIW performance for System.Generics.Collections.TList<T>.Add (and other methods) between 10.2 and 10.3 also differs quite significantly (got better).

     

    And another thing that sometimes significantly improves performance when adding items to a list is to preset its Capacity to avoid reallocations - in the example given in the blog article with adding 64 integers this already improves performance by 33%.

    • Like 1

  12. Yes, and performance of these things sometimes heavily differs between the different CPUs (for example I had a case where I got some severe slowdown in some code on my ivy bridge i5 whereas it was not there on a skylake i7 one).

    Anyhow not having a jump is still better than a predicted one. But that is micro optimization (which I did invest some time into as the code I was testing is core framework code, which I usually consider collection types part of).

    • Like 1
×