SlideShare a Scribd company logo
High Performance Pascal Code On Servers
Arnaud Bouchez โ€“ Synopse / LiveMon
High Performance
Pascal Code On Servers
High Performance Pascal Code On Servers
Arnaud Bouchez
โ€“ Delphi / FPC
โ€ข Various solutions (from Vatican to gaming industry)
โ€ข IoT solution (RSI)
โ€ข Real-time Monitoring solution (LiveMon)
โ€“ Open Source
โ€ข mORMot (SOA ORM MVC framework)
โ€ข SynPDF SynMustache SynDB SynCrypto
โ€“ Training and consultancy
โ€ข Synopse one-man company
High Performance Pascal Code On Servers
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
High Performance Pascal Code On Servers
High Performance
Make our Software
Great Again
(Donald K.)
High Performance Pascal Code On Servers
High Performance
Make our Software
Great Again
(attributed to Donald K.)
High Performance Pascal Code On Servers
High Performance
Premature Optimization
is the root of all evil
(D. Knuth)
High Performance Pascal Code On Servers
High Performance
"Programmers waste enormous amounts of time
thinking about, or worrying about, the speed of
noncritical parts of their programs, and these
attempts at efficiency actually have a strong
negative impact when debugging and
maintenance are considered. We should forget
about small efficiencies, say about 97% of the
time: premature optimization is the root of all
evil. Yet we should not pass up our opportunities
in that critical 3%."
High Performance Pascal Code On Servers
High Performance
"Programmers waste enormous amounts of time
thinking about, or worrying about, the speed of
noncritical parts of their programs, and these
attempts at efficiency actually have a strong
negative impact when debugging and
maintenance are considered. We should forget
about small efficiencies, say about 97% of the
time: premature optimization is the root of all
evil. Yet we should not pass up our opportunities
in that critical 3%."
High Performance Pascal Code On Servers
High Performance
Premature Optimization
is the root of all evil
(D. Knuth)
High Performance Pascal Code On Servers
High Performance
No Premature Optimization
1. Make it right, then make it fast
Unit tests, then performance tests
2. Be Lazy
Change only what is worth optimizing
High Performance Pascal Code On Servers
High Performance
No Premature Optimization
1. Testing is everything
to avoid regression when refactoring
2. Measure, donโ€™t guess
Use a profiler and/or performance logs
High Performance Pascal Code On Servers
High Performance
Premature Optimization
is the root of all evil
(D. Knuth - again)
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
High Performance Pascal Code On Servers
On Servers
Not your daddyโ€™s RAD way
โ€ข RAD is database centric
creating proper indexes wonโ€™t hurt
โ€ข RAD is for rich clients
(a lot of) process / business logic
is done on the client side
High Performance Pascal Code On Servers
On Servers
REpresentational State Transfer (REST)
โ€ข It is not easy to switch from RAD to REST
but from proper isolation
comes ( may/should come? )
better performance
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข Guess your needs, prepare for eventual
Scaling is (really) hard
Your company may not need GAFA scaling
But you want to maximize ROI
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข Scaling is about uncoupling
Get rid of identified Bottlenecks
and Single Point of Failures
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข Database as Bottleneck
from Vertical Scaling
more CPU, RAM, switch to NVMeโ€ฆ
to Horizontal Scaling
add Microservices instances
with their own storage
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข MicroServices with Local Storage
Using Containers for API and DB servers
(RDMS, NoSQL โ€“ MongoDB, Redis)
Using stand-alone database
(objects, SQLite3)
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข MicroServices with Local Storage
Works as a local cache of data
Updates made via Events
High Performance Pascal Code On Servers
On Servers
Scaling
โ€ข MicroServices with Local Storage
Updates made via Events
leads to Eventual Consistency
Use a centralized DB for transactional data
High Performance Pascal Code On Servers
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
High Performance Pascal Code On Servers
In Pascal Code
From Existing: Reuse, Test and Publish
โ€ข Reuse years (decades) of proven code
โ€ข Opportunity to add/enhance testing
โ€ข Open your solution to 3rd parties clients
High Performance Pascal Code On Servers
In Pascal Code
For new projects: Object Pascal
โ€ข Object Pascal is
readable (by nature)
safe (strong typing)
abstract (strings, interfaces)
fast (native/compiled, no GC)
High Performance Pascal Code On Servers
In Pascal Code
For new projects: Object Pascal
โ€ข Object Pascal is
your favorite / most fluent language
and you know your company business
High Performance Pascal Code On Servers
In Pascal Code
Not only the Delphi Language
โ€ข Complementary compilers/transpilers
FPC, TMS WebCore,
SmartMobileStudio, ElevateWebBuilderโ€ฆ
High Performance Pascal Code On Servers
In Pascal Code
Not only the Delphi Language
โ€ข Complementary compilers/transpilers
low-level optimizations usually work
for a single target compiler only
JavaScript execution VM/JIT is very specific
High Performance Pascal Code On Servers
In Pascal Code
The Last Resort
โ€ข Best performance comes from design
But code optimization may help
High Performance Pascal Code On Servers
In Pascal Code
Make it Fast?
โ€ข Make it right
then
โ€ข Make your Design Fast
โ€ข Make your Code Fast
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
Make your design fast
Make your code fast
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Measure against your company goals
Identify the bottlenecks
- Profiling (on dev/coder side)
- Performance Logging (client/prod side)
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Profiling
External Tools (AQTime, DelphiToolsโ€ฆ)
Running on real-live usecases
using automated load stress tests
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Client/prod side performance logging
Log Timing of
Database Statements
SOA/REST methods calls
Main identified bottleneck functions
into logs โ€“ as text or DB (SQLite3)
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Client/prod side performance logging
Log Timing as part of mORMot
SQL, SOA on multiple threads
โ†’ show some real logs
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Cache is your friend
In-process Cache
MicroService local DB
preloading the most used values
mORMot TSynDictionary in RAM
High Performance Pascal Code On Servers
Make your Design Fast
โ€ข Cache is your friend
Shared Cache
Dedicated Service
REDIS Server
High Performance Pascal Code On Servers
High Performance
Pascal Code On Servers
โ€ข High Performance
โ€ข On Servers
โ€ข In Pascal Code
Make your design fast
Make your code fast
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Processors are very complex beasts
https://www.agner.org/optimize
High Performance Pascal Code On Servers
Make your Code Fast
High Performance Pascal Code On Servers
Make your Code Fast
High Performance Pascal Code On Servers
Make your Code Fast
Shut down the profiler,
keep your regression tests close,
and letโ€™s begin the fun !
(from the most obvious
to the most tenuous)
High Performance Pascal Code On Servers
Make your Code Fast
Shut down the profiler,
keep your regression tests close,
and letโ€™s begin the fun !
(and donโ€™t take my word for it)
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Avoid Unneeded Calls
Cache and reuse values
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Use Tuned Libraries
Written with performance in mind
Hardware accelerated (AES-NI, crc32c)
Link some C code known for efficiency
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Avoid Memory Allocation
Heap allocation has a cost,
especially on multi-threaded applications
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Avoid Copies or Reference Counting
By using const or var input parameters
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Avoid Hidden try..finally Blocks
By using a sub-function
when managed types are involved
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Better Register Allocation
By using a sub-function for loops
High Performance Pascal Code On Servers
Make your Code Fast
โ€ข Faster Data Structures
(Dynamic) arrays put all data in a row
are likely to stay in L1 cache
can be accessed using TDynArray wrapper
High Performance Pascal Code On Servers
โ€ข Questions?
High Performance
Pascal Code On Servers

More Related Content

Similar to High Performance Object Pascal Code on Servers (at EKON 22) (20)

ODP
DevOps, CLI, APIs, Oh My! Security Gone Agile
Matt Tesauro
ย 
PDF
A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)
Spark Summit
ย 
ODP
Testing at-cloud-speed sans-app-sec-austin-2013
Matt Tesauro
ย 
PPTX
Intro to big data analytics using microsoft machine learning server with spark
Alex Zeltov
ย 
PDF
Stay productive while slicing up the monolith
Markus Eisele
ย 
PPTX
Ceph Community Talk on High-Performance Solid Sate Ceph
Ceph Community
ย 
PDF
Ipc mysql php
Anis Berejeb
ย 
PPTX
Westpac Bank Tech Talk 1: Dive into Apache Kafka
confluent
ย 
PDF
AskTom: How to Make and Test Your Application "Oracle RAC Ready"?
Markus Michalewicz
ย 
PDF
Novinky v Oracle Database 18c
MarketingArrowECS_CZ
ย 
PDF
Low latency high throughput streaming using Apache Apex and Apache Kudu
DataWorks Summit
ย 
PDF
071410 sun a_1515_feldman_stephen
Steve Feldman
ย 
PPT
Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...
Denny Lee
ย 
PPTX
Typesafe spark- Zalando meetup
Stavros Kontopoulos
ย 
PDF
Our Multi-Year Journey to a 10x Faster Confluent Cloud
HostedbyConfluent
ย 
PDF
Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...
Kaseya
ย 
PDF
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
Docker, Inc.
ย 
PDF
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld
ย 
PDF
Stay productive_while_slicing_up_the_monolith
Markus Eisele
ย 
DevOps, CLI, APIs, Oh My! Security Gone Agile
Matt Tesauro
ย 
A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)
Spark Summit
ย 
Testing at-cloud-speed sans-app-sec-austin-2013
Matt Tesauro
ย 
Intro to big data analytics using microsoft machine learning server with spark
Alex Zeltov
ย 
Stay productive while slicing up the monolith
Markus Eisele
ย 
Ceph Community Talk on High-Performance Solid Sate Ceph
Ceph Community
ย 
Ipc mysql php
Anis Berejeb
ย 
Westpac Bank Tech Talk 1: Dive into Apache Kafka
confluent
ย 
AskTom: How to Make and Test Your Application "Oracle RAC Ready"?
Markus Michalewicz
ย 
Novinky v Oracle Database 18c
MarketingArrowECS_CZ
ย 
Low latency high throughput streaming using Apache Apex and Apache Kudu
DataWorks Summit
ย 
071410 sun a_1515_feldman_stephen
Steve Feldman
ย 
Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...
Denny Lee
ย 
Typesafe spark- Zalando meetup
Stavros Kontopoulos
ย 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
HostedbyConfluent
ย 
Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...
Kaseya
ย 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
Docker, Inc.
ย 
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld
ย 
Stay productive_while_slicing_up_the_monolith
Markus Eisele
ย 

More from Arnaud Bouchez (20)

PDF
mORMot 2 - Pascal Cafe 2025 in Nederlands
Arnaud Bouchez
ย 
PDF
EKON28 - Beyond Legacy Apps with mORMot 2
Arnaud Bouchez
ย 
PDF
EKON28 - Winning the 1BRC Challenge In Pascal
Arnaud Bouchez
ย 
PDF
EKON28 - Diving Into X.509 Certificates with mORMot 2
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez FPC and Lazarus
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez mORMot Gems
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez From RAD to REST and SOA
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez ORM ODM and mORMot
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez From Classes to Interfaces
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez Technical Debt
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez Test Driven Design
Arnaud Bouchez
ย 
PDF
2024 DAPUG Conference Arnaud Bouchez mORMot as a ToolBox
Arnaud Bouchez
ย 
PDF
EKON27-FrameworksTuning.pdf
Arnaud Bouchez
ย 
PDF
EKON27-FrameworksExpressiveness.pdf
Arnaud Bouchez
ย 
PDF
Ekon25 mORMot 2 Server-Side Notifications
Arnaud Bouchez
ย 
PDF
Ekon25 mORMot 2 Cryptography
Arnaud Bouchez
ย 
PDF
Ekon24 from Delphi to AVX2
Arnaud Bouchez
ย 
PDF
Ekon24 mORMot 2
Arnaud Bouchez
ย 
PDF
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Arnaud Bouchez
ย 
PDF
Ekon23 (1) Kingdom-Driven-Design
Arnaud Bouchez
ย 
mORMot 2 - Pascal Cafe 2025 in Nederlands
Arnaud Bouchez
ย 
EKON28 - Beyond Legacy Apps with mORMot 2
Arnaud Bouchez
ย 
EKON28 - Winning the 1BRC Challenge In Pascal
Arnaud Bouchez
ย 
EKON28 - Diving Into X.509 Certificates with mORMot 2
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez FPC and Lazarus
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez mORMot Gems
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez From RAD to REST and SOA
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez ORM ODM and mORMot
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez From Classes to Interfaces
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez Technical Debt
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez Test Driven Design
Arnaud Bouchez
ย 
2024 DAPUG Conference Arnaud Bouchez mORMot as a ToolBox
Arnaud Bouchez
ย 
EKON27-FrameworksTuning.pdf
Arnaud Bouchez
ย 
EKON27-FrameworksExpressiveness.pdf
Arnaud Bouchez
ย 
Ekon25 mORMot 2 Server-Side Notifications
Arnaud Bouchez
ย 
Ekon25 mORMot 2 Cryptography
Arnaud Bouchez
ย 
Ekon24 from Delphi to AVX2
Arnaud Bouchez
ย 
Ekon24 mORMot 2
Arnaud Bouchez
ย 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Arnaud Bouchez
ย 
Ekon23 (1) Kingdom-Driven-Design
Arnaud Bouchez
ย 
Ad

Recently uploaded (20)

PDF
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 
PDF
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
ย 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
ย 
PPTX
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
ย 
PDF
>Wondershare Filmora Crack Free Download 2025
utfefguu
ย 
PDF
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
ย 
PPTX
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
ย 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeonยดs SAPPA P...
info969686
ย 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
ย 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
ย 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
ย 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
ย 
PDF
Dealing with JSON in the relational world
Andres Almiray
ย 
PPTX
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
ย 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
PDF
Code Once; Run Everywhere - A Beginnerโ€™s Journey with React Native
Hasitha Walpola
ย 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
ย 
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
ย 
Automated Test Case Repair Using Language Models
Lionel Briand
ย 
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
ย 
>Wondershare Filmora Crack Free Download 2025
utfefguu
ย 
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
ย 
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
ย 
Laboratory Workflows Digitalized and live in 90 days with Scifeonยดs SAPPA P...
info969686
ย 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
ย 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
ย 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
ย 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
ย 
Dealing with JSON in the relational world
Andres Almiray
ย 
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
ย 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
Code Once; Run Everywhere - A Beginnerโ€™s Journey with React Native
Hasitha Walpola
ย 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
ย 
Ad

High Performance Object Pascal Code on Servers (at EKON 22)

  • 1. High Performance Pascal Code On Servers Arnaud Bouchez โ€“ Synopse / LiveMon High Performance Pascal Code On Servers
  • 2. High Performance Pascal Code On Servers Arnaud Bouchez โ€“ Delphi / FPC โ€ข Various solutions (from Vatican to gaming industry) โ€ข IoT solution (RSI) โ€ข Real-time Monitoring solution (LiveMon) โ€“ Open Source โ€ข mORMot (SOA ORM MVC framework) โ€ข SynPDF SynMustache SynDB SynCrypto โ€“ Training and consultancy โ€ข Synopse one-man company
  • 3. High Performance Pascal Code On Servers
  • 4. High Performance Pascal Code On Servers High Performance Pascal Code On Servers
  • 5. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code
  • 6. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code
  • 7. High Performance Pascal Code On Servers High Performance Make our Software Great Again (Donald K.)
  • 8. High Performance Pascal Code On Servers High Performance Make our Software Great Again (attributed to Donald K.)
  • 9. High Performance Pascal Code On Servers High Performance Premature Optimization is the root of all evil (D. Knuth)
  • 10. High Performance Pascal Code On Servers High Performance "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
  • 11. High Performance Pascal Code On Servers High Performance "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
  • 12. High Performance Pascal Code On Servers High Performance Premature Optimization is the root of all evil (D. Knuth)
  • 13. High Performance Pascal Code On Servers High Performance No Premature Optimization 1. Make it right, then make it fast Unit tests, then performance tests 2. Be Lazy Change only what is worth optimizing
  • 14. High Performance Pascal Code On Servers High Performance No Premature Optimization 1. Testing is everything to avoid regression when refactoring 2. Measure, donโ€™t guess Use a profiler and/or performance logs
  • 15. High Performance Pascal Code On Servers High Performance Premature Optimization is the root of all evil (D. Knuth - again)
  • 16. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code
  • 17. High Performance Pascal Code On Servers On Servers Not your daddyโ€™s RAD way โ€ข RAD is database centric creating proper indexes wonโ€™t hurt โ€ข RAD is for rich clients (a lot of) process / business logic is done on the client side
  • 18. High Performance Pascal Code On Servers On Servers REpresentational State Transfer (REST) โ€ข It is not easy to switch from RAD to REST but from proper isolation comes ( may/should come? ) better performance
  • 19. High Performance Pascal Code On Servers On Servers Scaling โ€ข Guess your needs, prepare for eventual Scaling is (really) hard Your company may not need GAFA scaling But you want to maximize ROI
  • 20. High Performance Pascal Code On Servers On Servers Scaling โ€ข Scaling is about uncoupling Get rid of identified Bottlenecks and Single Point of Failures
  • 21. High Performance Pascal Code On Servers On Servers Scaling โ€ข Database as Bottleneck from Vertical Scaling more CPU, RAM, switch to NVMeโ€ฆ to Horizontal Scaling add Microservices instances with their own storage
  • 22. High Performance Pascal Code On Servers On Servers Scaling โ€ข MicroServices with Local Storage Using Containers for API and DB servers (RDMS, NoSQL โ€“ MongoDB, Redis) Using stand-alone database (objects, SQLite3)
  • 23. High Performance Pascal Code On Servers On Servers Scaling โ€ข MicroServices with Local Storage Works as a local cache of data Updates made via Events
  • 24. High Performance Pascal Code On Servers On Servers Scaling โ€ข MicroServices with Local Storage Updates made via Events leads to Eventual Consistency Use a centralized DB for transactional data
  • 25. High Performance Pascal Code On Servers
  • 26. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code
  • 27. High Performance Pascal Code On Servers In Pascal Code From Existing: Reuse, Test and Publish โ€ข Reuse years (decades) of proven code โ€ข Opportunity to add/enhance testing โ€ข Open your solution to 3rd parties clients
  • 28. High Performance Pascal Code On Servers In Pascal Code For new projects: Object Pascal โ€ข Object Pascal is readable (by nature) safe (strong typing) abstract (strings, interfaces) fast (native/compiled, no GC)
  • 29. High Performance Pascal Code On Servers In Pascal Code For new projects: Object Pascal โ€ข Object Pascal is your favorite / most fluent language and you know your company business
  • 30. High Performance Pascal Code On Servers In Pascal Code Not only the Delphi Language โ€ข Complementary compilers/transpilers FPC, TMS WebCore, SmartMobileStudio, ElevateWebBuilderโ€ฆ
  • 31. High Performance Pascal Code On Servers In Pascal Code Not only the Delphi Language โ€ข Complementary compilers/transpilers low-level optimizations usually work for a single target compiler only JavaScript execution VM/JIT is very specific
  • 32. High Performance Pascal Code On Servers In Pascal Code The Last Resort โ€ข Best performance comes from design But code optimization may help
  • 33. High Performance Pascal Code On Servers In Pascal Code Make it Fast? โ€ข Make it right then โ€ข Make your Design Fast โ€ข Make your Code Fast
  • 34. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code Make your design fast Make your code fast
  • 35. High Performance Pascal Code On Servers Make your Design Fast โ€ข Measure against your company goals Identify the bottlenecks - Profiling (on dev/coder side) - Performance Logging (client/prod side)
  • 36. High Performance Pascal Code On Servers Make your Design Fast โ€ข Profiling External Tools (AQTime, DelphiToolsโ€ฆ) Running on real-live usecases using automated load stress tests
  • 37. High Performance Pascal Code On Servers Make your Design Fast โ€ข Client/prod side performance logging Log Timing of Database Statements SOA/REST methods calls Main identified bottleneck functions into logs โ€“ as text or DB (SQLite3)
  • 38. High Performance Pascal Code On Servers Make your Design Fast โ€ข Client/prod side performance logging Log Timing as part of mORMot SQL, SOA on multiple threads โ†’ show some real logs
  • 39. High Performance Pascal Code On Servers Make your Design Fast โ€ข Cache is your friend In-process Cache MicroService local DB preloading the most used values mORMot TSynDictionary in RAM
  • 40. High Performance Pascal Code On Servers Make your Design Fast โ€ข Cache is your friend Shared Cache Dedicated Service REDIS Server
  • 41. High Performance Pascal Code On Servers High Performance Pascal Code On Servers โ€ข High Performance โ€ข On Servers โ€ข In Pascal Code Make your design fast Make your code fast
  • 42. High Performance Pascal Code On Servers Make your Code Fast โ€ข Processors are very complex beasts https://www.agner.org/optimize
  • 43. High Performance Pascal Code On Servers Make your Code Fast
  • 44. High Performance Pascal Code On Servers Make your Code Fast
  • 45. High Performance Pascal Code On Servers Make your Code Fast Shut down the profiler, keep your regression tests close, and letโ€™s begin the fun ! (from the most obvious to the most tenuous)
  • 46. High Performance Pascal Code On Servers Make your Code Fast Shut down the profiler, keep your regression tests close, and letโ€™s begin the fun ! (and donโ€™t take my word for it)
  • 47. High Performance Pascal Code On Servers Make your Code Fast โ€ข Avoid Unneeded Calls Cache and reuse values
  • 48. High Performance Pascal Code On Servers Make your Code Fast โ€ข Use Tuned Libraries Written with performance in mind Hardware accelerated (AES-NI, crc32c) Link some C code known for efficiency
  • 49. High Performance Pascal Code On Servers Make your Code Fast โ€ข Avoid Memory Allocation Heap allocation has a cost, especially on multi-threaded applications
  • 50. High Performance Pascal Code On Servers Make your Code Fast โ€ข Avoid Copies or Reference Counting By using const or var input parameters
  • 51. High Performance Pascal Code On Servers Make your Code Fast โ€ข Avoid Hidden try..finally Blocks By using a sub-function when managed types are involved
  • 52. High Performance Pascal Code On Servers Make your Code Fast โ€ข Better Register Allocation By using a sub-function for loops
  • 53. High Performance Pascal Code On Servers Make your Code Fast โ€ข Faster Data Structures (Dynamic) arrays put all data in a row are likely to stay in L1 cache can be accessed using TDynArray wrapper
  • 54. High Performance Pascal Code On Servers โ€ข Questions? High Performance Pascal Code On Servers