Faster compiler, constant records, $include_once

Executive summary of recent DWS changes from the bleeding edge:

  • Compiler/parser performance improved by about 15%.
  • Added support for constant records declaration.
  • The $include_once directive is now supported, it will include a file only if it hasn’t been already included (be it by a previous $include_once or a regular $include).
  • Fixed some issues with script-side Exception.StackTrace method for wrapped Delphi-side exceptions.
  • Fixed-size arrays accesses with constant indexes are now checked at compile-time.
  • Multiple minor fixes, refactorings, minor optimizations and unit test coverage improvements.

Something “big” is also brewing in the DWScript lab, if not quite ready for prime-time just yet 😉

A Fistful of TMonitors

…or why you can’t hide under the complexity carpet 😉

As uncovered in previous episodes, one of the keys behind TMonitor performance issues is that it allocates a dynamic block of memory for its locking purposes, and when those blocks end up allocated on the same CPU cache line, the two TMonitor on the same cache line will end up fighting for the cache line, resulting in a drastic drop of performance and thread contention. The technical term for that behavior is false sharing.
(more…)

Once upon a time in a thread…

Last episode in the TMonitor saga. In the previous episode, Chris Rolliston posted a more complete test case, for which he got surprising results (including that a Critical Section approach wouldn’t scale with the thread count). Starting from  his code I initially also got similar surprising results.

edit: apparently the “crash” part of the TMonitor issues have been acknowledged by the powers that be, and a hotfix could be on the way, though it points back to QC 78415, an issue reported in 2009, ouch. Guess those 4 bytes per instance haven’t seen much use…
(more…)

TMonitor woes

Primoz Gabrijelcic recently reported a possible bug with TMonitor, in the more advanced side of TMonitor.

However, when experimenting with it for DWS, I bumped on issues in the basic usage scenarios too, and reverted to using critical sections. It seems that as of Delphi XE, short of a patch, TMonitor is just a waste of 4 bytes per object instance.
(more…)