Jump to content

Stefan Glienke

Members
  • Content Count

    1366
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Stefan Glienke

  1. Stefan Glienke

    Delphi 64bit compiler RTL speedup

    Why isn't the code of those dlls open source as well? If they are simply directly taken from those Intel libraries, provide a link how to get them directly from the original source.
  2. I would like to add: "because good compilers can turn such code into the most efficient code."
  3. Stefan Glienke

    Addendum to Martin Fowler quote

    Notice that I wrote "efficient code" - it's not only about applications running fast (enough) but also energy efficient which most people tend to forget.
  4. Then you are almost at an Introsort (Spring4D uses that instead of plain Quicksort)
  5. Always understand the reason behind guidelines, suggestions, principles: why is it a good thing to do x - not just because famous person y said so. Because when you understand why something is a good or bad thing to do you are able to evaluate the situations where you want or dont want to follow them and what implications arise.
  6. Stefan Glienke

    The Case of Delphi Const String Parameters

    The question stands - there is no "yes/no" about that - their reference count is threadsafe - an assignment is not because its not atomic (which is the very same issue that Dalija wrote about in her blog post). About this discussion I think it is nonsense - the issue being pointed out by Marco arises when you access something with a broader scope than where you are currently - i.e. a global variable or a variable outside of the current nested routine - that also includes passing the same variable by reference twice or more and modifying it. f(i,i) would also be defect if it was implemented like this: while a > 0 do begin Inc(b); Dec(a); end; "Better" for strings would raise the question: better for what? Memory consumption? UTF8, string interning. Multithreading? Immutability. Memory locality? Short string optimization (i.e. avoiding the memory indirection) - there are probably more and most of them would be a complete breaking change even more than Delphi 2009.
  7. Stefan Glienke

    The Case of Delphi Const String Parameters

    What is thread safety anyway?
  8. Stefan Glienke

    git and Delphi tooling?

    I uninstalled SourceTree (which I had been using for years before with decreasing joy) the day I started using Fork and never looked back - back then Fork was completely free and changed to a paid license later but those 50 bucks were very well spent.
  9. Stefan Glienke

    DPM Package Manager - presentation

    I kinda like DPM - TLAs FTW
  10. Stefan Glienke

    Manage overloaded IfThen functions

    That or something like this.
  11. Stefan Glienke

    Is someone using MVVM?

    Best since sliced bread ... if you're not in Delphi
  12. What if we could write optimized code right from the start and would not have to deal with all that shit because the compiler has the intelligence of a rock. What if good coding practices could be tought by the editor via suggesting things (look at quick actions in Visual Studio that will help you with many different things - from fixing formatting to suggesting some refactoring) Much backwards compatibility is eyewash and simply means: "we did not change the signature but sacrificed some firstborn to make it still work". If you provide - there is it again - tooling to detect and guide you with moving forward (yes, often backwards compatibility is nice because I don't have to ifdef my code for a dozen different versions) then breaking changes are not bad.
  13. I disagree - this is exactly the mindset that we got trained all these years because we did not know any better - the world moved on - heck there are people working on programming tools based on ML so it can suggest refactorings based on refactorings you have done in the past! And yet here we are mostly doing yolo driven development - "if it aint break it might be ok" (ok, I am exaggerating here). If the tooling can point out possible optimizations because they understand what you are doing that can just be good regardless of how much of a measurable improvement that will make. And if its just for some junior coders at Embarcadero slapping together some ... ahem ... non ideal code that never gets properly reviewed because lack of time. It took them years and an actual change of the FreeAndNil function to find bugs in their code that static code analysis could have found ages ago.
  14. Stefan Glienke

    Manage overloaded IfThen functions

    https://en.wikipedia.org/wiki/Principle_of_least_astonishment And now imagine some compiler that turns that into proper code with as little conditional jumps as possible: https://godbolt.org/z/KqhKnx
  15. @Mahdi Safsafi Add this on the issue please.
  16. And then you put them into an array and have no contiguous memory where the data resides in but just a bunch of pointers pointing all over the heap -> bad.
  17. And on win32 those try/finally have a significant effect even worse than a heap allocation at times because they completely trash a part of the CPUs branch prediction mechanism - see RSP-27375
  18. Stefan Glienke

    Hex2Binary

    @Mahdi Safsafi Optimized it: {$O+} function foo(I: Integer): Integer; begin case I of 0: Exit(random(255)); 1..5: Exit(i+2); // 2: Exit(4); // 3: Exit(5); // 4: Exit(6); // 5: Exit(7); else Exit(0); end; end; Scnr
  19. SamplingProfiler usually gives a good overview to find the particularly time consuming parts. (although it says up to XE4 on that page it works just fine for up to 10.4)
  20. Stefan Glienke

    Hex2Binary

    Exactly - that's why I just recently rearranged some of my code from this pattern (which I personally like very much for its readability and less indention): if not check then SomeErrorMessageStuff/raise/exit Usual stuff; to: if check then begin do usual stuff optionally exit end else Error stuff With some noticable improvements. Not only will the common part be on the fallthrough but also it avoids unnecessary register preserving when you have an error raising subroutine that will never return which the compiler does not know of. I wish Delphi would have something like noreturn
  21. Stefan Glienke

    Hex2Binary

    Keep in mind the slightly different tendencies to branch predict on different CPUs when microbenchmarking cold code. https://xania.org/201602/bpu-part-one
  22. As a guideline: try to remove overhead from prologues and epilogues caused by variables of managed types (explicit or implicit) such as strings or interfaces that are only there for the uncommon path. Another example was the error raising code in the hextobin thread that can be put into a subroutine that gets called only when the rase case of a invalid char occurs. Eric Grange wrote a nice article about this some years ago that I like to recommend: https://www.delphitools.info/2009/05/06/code-optimization-go-for-the-jugular/
  23. Stefan Glienke

    Hex2Binary

    Nice, now make it run on multiple cores 😅
  24. Stefan Glienke

    Default value

    No need for multiple inheritance - you can also apply the mechanism from Spring.TManagedObject to any other class - simply override NewInstance and FreeInstance
  25. Stefan Glienke

    Hex2Binary

    Why can't we have both - a fast compilation generating debug friendly non optimized code and one that churns a little longer and emits those juicy optimizations. Anyhow the current slowliness in the compiler comes from sloppy code in the compiler and not because it does so many amazing things.
×