Jump to content

Stefan Glienke

Members
  • Content Count

    1366
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Stefan Glienke

  1. Stefan Glienke

    Help with string extraction function

    No, it's not the same codegen, its a test and jnz less. You don't want forward jumps taken in the common case. Also a very important fact (I think it was mentioned before) - depending on where the compiler puts the code the hot loop code might cross cache lines - that slows things down significantly and can happen when you add or change unrelated code in other routines or in this routine - such as a check for Length or similar. When I let the routine start at some 64byte aligned address the loop body will cross cache lines and be slower. To my knowledge there is no way to control the alignment of generated executable code so that you can force hot code into a single or as few cache lines as possible.
  2. Stefan Glienke

    TCriticalSection and cache line size

    If you really worry about performance in this area then don't use TCriticalSection but embed the TRTLCriticalSection (or the appropriate thing for POSIX) into the object where you need it - that way you also eliminated an indirection. And make sure that your allocated memory from the memory manager is aligned cacheline friendly (it won't by default)
  3. Stefan Glienke

    Just-in-time compiling for Delphi's Regular Expressions

    RAD Studio Project - every Jira project has a unique code
  4. Stefan Glienke

    Anybody up for an ethics question?

    @Rollo62 Reminds me of Zen of Python
  5. Slightly OT: Use whatever you want for private projects or within a company but please - whenever someone does open source don't turn off possible contributors by having to install yet another VCS. Git has won, deal with it!
  6. Stefan Glienke

    Running Tokyo 10.2.3 dcc32 from the command line

    Now that is clearly shorter than calling dcc32! /irony off
  7. Stefan Glienke

    Buggy Optimizer in Delphi 10.4

    I challenge you to write this method in a more performant way than what it currently is without completely turning it into an even less readable mess: https://bitbucket.org/sglienke/spring4d/src/534d63bccd0891d165d6cee1cbfff18df790661e/Source/Base/Spring.pas#lines-10122
  8. @vfbb Depending on the tree the balancing is pretty damn efficient - but the memory layout after a few iterations can be totally screwed up which I mentioned earlier. But as always it depends - there is no "best for everything" data structure or algorithms but you typically want the "reasonably well for most cases" (bonus if they are "not exceptionally terrible for some rare cases"). Typically the decision is if the thing is often read or often written. If both is the case you have to evaluate the costs of going down the rabbit hole of implementing some special case data structure or simply roll with some standard implementation.
  9. What Kas said - it's similar to the performance of array vs. linked list on modern computers - using objects or any dynamically allocated memory without special suballocator that ensures clustered memory and cache friendly layout will cause memory that's scattered all over the heap the longer the data structure exists unless you perform some defragmentation. Also using objects wastes at least precious Pointersize*2 Bytes of memory for every node. If you then throw virtual methods into the mix you very likely end up with a pretty terribly performing tree structure compared to how it could perform according to its big O.
  10. A binary search tree that uses objects as nodes will be crap if you are after the pure performance advantages of a BST simply because all the cache misses caused by indirection will blow it out of the window. Simply talking about the Big O of the algorithm does not tell the full story because it simply ignores all those factors.
  11. Stefan Glienke

    Running Tokyo 10.2.3 dcc32 from the command line

    Because msbuild opens an entirely different can of worms and actually requires a dproj - compiling some dpr with dcc is a no brainer
  12. Stefan Glienke

    Running Tokyo 10.2.3 dcc32 from the command line

    Open cmd, type dcc32 it prints (almost) all parameters. You will find the -NS switch for namespace search path. So what you do is pass -NSvcl (probably there are some more needed such as Winapi - just take those that a new project in Delphi usually gets)
  13. Stefan Glienke

    Help with string extraction function

    By the way: LoopStuff.dpr.26: while i < count do 0041BDB0 3BFB cmp edi,ebx 0041BDB2 7E0C jle $0041bdc0 LoopStuff.dpr.28: dosomething(i); 0041BDB4 8BC3 mov eax,ebx 0041BDB6 E8D5FFFFFF call dosomething LoopStuff.dpr.29: inc(i); 0041BDBB 43 inc ebx LoopStuff.dpr.26: while i < count do 0041BDBC 3BFB cmp edi,ebx 0041BDBE 7FF4 jnle $0041bdb4 LoopStuff.dpr.26: if (i < count) then // this branch can be emited if i holds at compile time. 0041BDB0 3BFB cmp edi,ebx 0041BDB2 7E0C jle $0041bdc0 LoopStuff.dpr.29: dosomething(i); 0041BDB4 8BC3 mov eax,ebx 0041BDB6 E8D5FFFFFF call dosomething LoopStuff.dpr.30: inc(i); 0041BDBB 43 inc ebx LoopStuff.dpr.31: until (i = count); 0041BDBC 3BFB cmp edi,ebx 0041BDBE 75F4 jnz $0041bdb4 As I said: sometimes the compiler does the check at the top for the while loop.
  14. Stefan Glienke

    Help with string extraction function

    @Mahdi Safsafi I would not use that code as evidence because there actually the for loop produces better code than the other one. I was talking about while x do loop vs if x then repeat until not x conversion. Also it makes a difference if you have a static count or not - the benefit of the for to loop is that the compiler does no additional cmp after it decrements the internal "counting down to zero" variable but does the conditional jmp depending on the outcome of the dec. An until loop produces an additional cmp instruction (reported as https://quality.embarcadero.com/browse/RSP-22124) As always: it depends - while I certainly would not use a for-to loop when dealing with some string parsing but rather prever PChar I just found recently that using a for-to loop with indexing into a pointer was faster than inc(thatpointer).
  15. Stefan Glienke

    Anybody up for an ethics question?

    Giving an error is *always* better than assuming an "instead of" value for invalid data. You can potentially ruin the entire system by doing that. The strategy of giving the error is up to the developer - the "it simply crashes and refuses to do anything with the entire data" is fine. It depends on the data itself if let's say all valid entries can be imported and only the invalid ones can be left out and possibly reported back so the customer can fix them and then import those.
  16. Stefan Glienke

    Assign a pointer to a dynamic array

    Best solution would probably to change the type of segment_ptr but then probably the E2010 pops up somewhere else. Anyhow a simple hardcast will do what it did before they tightened the assignment rule in 10.2: p := TWordArray(segment_ptr); Also shouldn't FastReports have fixed that code some while ago given they support 10.2 and higher?
  17. Backup/restore of a remote git repository is simply backup/restore of a file system folder
  18. I just had a glimpse over the source but I think the line can just be removed. There is nothing to deallocate and any managed fields in the record will be finalized automatically from the RTL.
  19. Stefan Glienke

    GExperts supports even more laziness

    I was not sure what "current" means in the context of being called from the IDE from the hooked "break because of exception" method - but you could be right - that would make it easier.
  20. Stefan Glienke

    Buggy Optimizer in Delphi 10.4

    https://xkcd.com/292/ just saying
  21. Stefan Glienke

    GExperts supports even more laziness

    You probably have to use an IOTADebuggerNotifier to detect ProcessCreated/ProcessDestroyed - there you have to add/remove IOTAProcessNotifier and get ThreadCreated/ThreadDestroyed and you can already guess it add/remove an IOTAThreadNotifier which has ThreadNotify where you are interested in TOTANotifyReason.nrException. The corresponding IOTAThread instance has all the required information like the OSThreadID or Handle properties
  22. Stefan Glienke

    Patch 2 for RAD Studio 10.4 now available

    Just remove the : record constraint from FromRecord and it will work. Just don't pass anything but a record then :p
  23. Stefan Glienke

    Patch 2 for RAD Studio 10.4 now available

    Spring4D is not negatively affected by Patch2
  24. Stefan Glienke

    GExperts supports even more laziness

    Probably possible using the debugger evaluation or something but being able to have an "any" option in the exception class field would be enough - and probably a button "ignore any" in the exception dialog. Currently I am solving this by setting a non breaking breakpoint at the start of the unit tests with "ignore subsequent exceptions" but I forget to set that up often enough.
  25. Stefan Glienke

    GExperts supports even more laziness

    The filters work on Exception class name and that does not support regex or does a sub type check
×