Delphi High Performance: Master the art of concurrency, parallel programming, and memory management to build fast Delphi apps, 2nd Edition
9781805125877, 1805125877
Discover algorithm performance, high- and low-level optimizations, and the internal behavior of programs written in the
Table of contents : Cover Title Page Copyright and Credits Contributors Table of Contents Preface Chapter 1: About Performance Technical requirements What is performance? Different types of speed Algorithm complexity Big O and Delphi data structures Data structures in practice Mr. Smith’s first program Looking at code through Big O eyes Summary Chapter 2: Profiling the Code Technical requirements Don’t guess, measure! Profiling with TStopwatch Profilers Summary Chapter .3: Fixing the Algorithm Technical requirements Writing responsive user interfaces Updating a progress bar Bulk updates Virtual display Caching Memoization Dynamic cache Speeding up SlowCode Summary Chapter 4: Don’t Reinvent, Reuse Technical requirements Spring for Delphi Enumerations, collections, and lists IEnumerable ICollection IList Other interfaces TEnumerable Stacks and queues Trees Red-black trees Sets and dictionaries ISet IMultiSet IDictionary IBiDiDictionary Summary Chapter 5: Fine-Tuning the Code Technical requirements Delphi compiler settings Code inlining control Optimization Record field alignment Assertions Overflow checking Range checking Extracting common expressions The helpful CPU window Behind the scenes A plethora of types Simple types Strings Arrays Records Classes Interfaces Optimizing method calls Parameter passing Method inlining The magic of pointers Going the assembler way Returning to SlowCode Summary Chapter 6: Memory Management Technical requirements Optimizing strings and array allocations Memory management functions Dynamic record allocation FastMM4 internals Memory allocation in a parallel world Replacing the default memory manager Logging memory manager FastMM4 with release stack FastMM5 TBBMalloc Comparing memory managers There is no silver bullet Fine-tuning SlowCode Summary Chapter 7: Getting Started with the Parallel World Technical requirements Processes and threads Multithreading Multitasking When to parallelize code The most common problems Never access the UI from a background thread Simultaneous reading and writing Sharing a variable Hidden behavior Synchronization Critical sections Other locking mechanisms A short note on coding style Shared data with built-in locking Interlocked operations Object life cycle Communication Windows messages Synchronize and Queue Polling Performance Third-party libraries Summary Chapter 8: Working with Parallel Tools Technical requirements TThread Automatic life cycle management Advanced TThread Setting up a communication channel Sending messages from a thread Using TCommThread Implementing a timer Synchronizing with multiple workers WaitForMultipleObjects Condition variables Comparing both approaches Summary Chapter 9: Exploring Parallel Practices Technical requirements Tasks and patterns Variable capturing Tasks Exceptions in tasks Parallelizing a loop Thread pooling Async/Await Join Join/Await Future Parallel for Pipelines Web spider The filter stage The downloader stage The parser stage Summary Chapter 10: More Parallel Patterns Technical requirements Using OmniThreadLibrary Blocking collections Using blocking collections with TThread-based threads Async/Await Join Future Parallel Task Background Worker Initial query Pipeline Creating the pipeline Stages Displaying the result and shutting down Map Timed Task Summary Chapter 11: Using External Libraries Technical requirements Linking with object files Object file formats Object file linking in practice Using C++ libraries Writing exported functions Using a proxy DLL in Delphi Summary Chapter 12: Best Practices About performance Profiling the code Fixing the algorithm Don’t reinvent, reuse Fine-tuning the code Memory management Getting started with the parallel world Working with parallel tools Exploring parallel practices More parallel patterns Using external libraries Final words Index Other Books You May Enjoy