SlideShare une entreprise Scribd logo
1  sur  54
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

XP - Extreme Programming
XP - Extreme ProgrammingXP - Extreme Programming
XP - Extreme Programming
Rodrigo Branas
 

Tendances (20)

Introdução ao Spring Framework MVC
Introdução ao Spring Framework MVCIntrodução ao Spring Framework MVC
Introdução ao Spring Framework MVC
 
React JS - Parte 1
React JS - Parte 1React JS - Parte 1
React JS - Parte 1
 
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
서비스 모니터링 구현 사례 공유 - Realtime log monitoring platform-PMon을 ...
 
Apresentação modelagem de_negócio_rup
Apresentação modelagem de_negócio_rupApresentação modelagem de_negócio_rup
Apresentação modelagem de_negócio_rup
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 
Entity Framework Core
Entity Framework CoreEntity Framework Core
Entity Framework Core
 
OutSystems User Groups - Introduction to OutSystems Architecture (Pune - 7 A...
 OutSystems User Groups - Introduction to OutSystems Architecture (Pune - 7 A... OutSystems User Groups - Introduction to OutSystems Architecture (Pune - 7 A...
OutSystems User Groups - Introduction to OutSystems Architecture (Pune - 7 A...
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
 
Java SE 8 技術手冊第 14 章 - NIO 與 NIO2
Java SE 8 技術手冊第 14 章 - NIO 與 NIO2Java SE 8 技術手冊第 14 章 - NIO 與 NIO2
Java SE 8 技術手冊第 14 章 - NIO 與 NIO2
 
SQL Server コンテナ入門(Docker編)
SQL Server コンテナ入門(Docker編)SQL Server コンテナ入門(Docker編)
SQL Server コンテナ入門(Docker編)
 
Create Amazing Reports in OutSystems
Create Amazing Reports in OutSystemsCreate Amazing Reports in OutSystems
Create Amazing Reports in OutSystems
 
XP - Extreme Programming
XP - Extreme ProgrammingXP - Extreme Programming
XP - Extreme Programming
 
NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA  NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA
 
Extending OutSystems with Javascript
Extending OutSystems with JavascriptExtending OutSystems with Javascript
Extending OutSystems with Javascript
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
Curso de ReactJS
Curso de ReactJSCurso de ReactJS
Curso de ReactJS
 
Princípios S.O.L.I.D.
Princípios S.O.L.I.D.Princípios S.O.L.I.D.
Princípios S.O.L.I.D.
 
Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...
Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...
Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...
 
Modelos de Processo de Software Parte 1
Modelos de Processo de Software Parte 1Modelos de Processo de Software Parte 1
Modelos de Processo de Software Parte 1
 
Modelagem Ágil
Modelagem ÁgilModelagem Ágil
Modelagem Ágil
 

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

Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013
Matt Tesauro
 
Intro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with sparkIntro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with spark
Alex Zeltov
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
Markus Eisele
 
Low latency high throughput streaming using Apache Apex and Apache Kudu
Low latency high throughput streaming using Apache Apex and Apache KuduLow latency high throughput streaming using Apache Apex and Apache Kudu
Low latency high throughput streaming using Apache Apex and Apache Kudu
DataWorks Summit
 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
Docker, Inc.
 
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld
 

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

DevOps, CLI, APIs, Oh My! Security Gone Agile
DevOps, CLI, APIs, Oh My!  Security Gone AgileDevOps, CLI, APIs, Oh My!  Security Gone Agile
DevOps, CLI, APIs, Oh My! Security Gone Agile
 
A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)
A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)
A Big Data Lake Based on Spark for BBVA Bank-(Oscar Mendez, STRATIO)
 
Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013
 
Intro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with sparkIntro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with spark
 
Ml2
Ml2Ml2
Ml2
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Ceph Community Talk on High-Performance Solid Sate Ceph
Ceph Community Talk on High-Performance Solid Sate Ceph Ceph Community Talk on High-Performance Solid Sate Ceph
Ceph Community Talk on High-Performance Solid Sate Ceph
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
Westpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache KafkaWestpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache Kafka
 
AskTom: How to Make and Test Your Application "Oracle RAC Ready"?
AskTom: How to Make and Test Your Application "Oracle RAC Ready"?AskTom: How to Make and Test Your Application "Oracle RAC Ready"?
AskTom: How to Make and Test Your Application "Oracle RAC Ready"?
 
Novinky v Oracle Database 18c
Novinky v Oracle Database 18cNovinky v Oracle Database 18c
Novinky v Oracle Database 18c
 
Low latency high throughput streaming using Apache Apex and Apache Kudu
Low latency high throughput streaming using Apache Apex and Apache KuduLow latency high throughput streaming using Apache Apex and Apache Kudu
Low latency high throughput streaming using Apache Apex and Apache Kudu
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen
 
Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...
Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...
Building and Deploying Large Scale SSRS using Lessons Learned from Customer D...
 
Running Business Critical Workloads on AWS
Running Business Critical Workloads on AWS Running Business Critical Workloads on AWS
Running Business Critical Workloads on AWS
 
Typesafe spark- Zalando meetup
Typesafe spark- Zalando meetupTypesafe spark- Zalando meetup
Typesafe spark- Zalando meetup
 
Our Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent CloudOur Multi-Year Journey to a 10x Faster Confluent Cloud
Our Multi-Year Journey to a 10x Faster Confluent Cloud
 
Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...
Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...
Kaseya Connect 2013: Optimizing Your K Server - Best Practices in Kaseya Infr...
 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
 
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
VMworld 2013: Strategic Reasons for Classifying Workloads for Tier 1 Virtuali...
 

Plus de Arnaud Bouchez

Plus de Arnaud Bouchez (20)

EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdf
 
EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdf
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 Cryptography
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2
 
Ekon24 mORMot 2
Ekon24 mORMot 2Ekon24 mORMot 2
Ekon24 mORMot 2
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-Design
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOA
 
Ekon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven Design
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop Delphi
 
Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference
 
2016 mORMot
2016 mORMot2016 mORMot
2016 mORMot
 
A1 from n tier to soa
A1 from n tier to soaA1 from n tier to soa
A1 from n tier to soa
 
D1 from interfaces to solid
D1 from interfaces to solidD1 from interfaces to solid
D1 from interfaces to solid
 
A3 from sql to orm
A3 from sql to ormA3 from sql to orm
A3 from sql to orm
 
A2 from soap to rest
A2 from soap to restA2 from soap to rest
A2 from soap to rest
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 
A4 from rad to mvc
A4 from rad to mvcA4 from rad to mvc
A4 from rad to mvc
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
 

Dernier

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

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