The TFB challenge is a performance comparison of many web app platforms, exercising JSON, database, ORM, HTML templates, all over HTTP. It compares the best frameworks written in C++, Rust, Go, JS, Java, C#… and now Pascal – thanks to mORMot. In this session, we will look and compare the source code of some frameworks samples, to distinguish their typical philosophy. We will see how modern Object Pascal is still relevant, and propose some ideas for the future of the language.
10. The TFB Challenge
Web Frameworks Benchmarks
• Since 2013, a collaborative project
• Now one official round per year
• Hundredths of frameworks tested
• Seven web /endpoints tested
• 24/7 continuous tests on dedicated HW
11. The TFB Challenge
One official round per year
• Round 22 is just finished
• Round 22 should be published very soon
• Including object pascal with mORMot
12. The TFB Challenge
Hundredths of frameworks tested
• Currently 301 frameworks
• In 791 flavors/configurations
• All languages
14. The TFB Challenge
Seven web /endpoints tested
/plaintext
/json
/db
/query?queries=###
/cached_queries?count=###
/update?queries=###
/fortunes
15. The TFB Challenge
24/7 continuous tests on big HW
• Three homogeneous Dell R440 servers:
as web client, web server, database
• Each with an Intel Xeon Gold 5120 CPU
• 32 GB of memory, enterprise SSD
• Dedicated Cisco 10-gigabit Ethernet switch
16. The TFB Challenge
24/7 continuous tests on big HW
Latest runs are available at
https://tfb-status.techempower.com
17. The TFB Challenge
Motivation(s)
• Officially: measure performance
to reduce cost of ownership
and enhance usability and scalability
• For us: investigate the diverse philosophies
of the frameworks
and their corresponding languages
18. The TFB Challenge
Demo
• Reproduce on my dev laptop
• Compiled on Linux with Lazarus
• Run locally on the very same machine
20. Languages & Frameworks
Opinioned Language Clustering
• Old and boring: C, C++, C#, Java
• Trendy: Go, Rust
• Fast scripts: JavaScript, TypeScript
• Slow scripts: PhP, Python, Ruby
• Esoteric: xyz…
21. Languages & Frameworks
Opinioned Language Clustering
• Old and boring: C, C++, C#, Java
• Trendy: Go, Rust
• Fast scripts: JavaScript, TypeScript
• Slow scripts: PhP, Python, Ruby
• Esoteric: xyz… object pascal?
22. Languages & Frameworks
Performance and Languages
• Some trends:
most Rust is on top, most Python is on bottom
• But it depends on the framework
e.g. you can have poorly behaving C++
and amazing or dead slow JavaScript
23. Languages & Frameworks
Performance and Frameworks
• Some are Performance focused
other are Features focused
• Proof of concept
or Production ready
• Usually, the more featured, the slower
and top frameworks are more like POC
24. Languages & Frameworks
Performance Bottlenecks
• The Web Server
• The Database layer
• The threading/execution Model
• The RTL (JSON, heap…)
25. Languages & Frameworks
Performance Languages
• async / coroutines :
when the threading/execution Model
is built into the language
• The fastest use it (C++, Rust, Go, C#, JS)
• The slowest (ruby, python) are not compiled
and have scaling issues (giant locks)
26. Languages & Frameworks
Performance Languages
asp.net core
https://github.com/TechEmpower/Framewo
rkBenchmarks/tree/master/frameworks/C
Sharp/aspnetcore/src/Platform
27. Languages & Frameworks
Performance Languages
c libh2o
https://github.com/TechEmpower/Framewo
rkBenchmarks/blob/master/frameworks/C
/h2o/src/handlers/plaintext.c
28. Languages & Frameworks
Performance Languages
Rust ntex
https://github.com/TechEmpower/Framewo
rkBenchmarks/blob/master/frameworks/R
ust/ntex/src/main.rs
29. Languages & Frameworks
Performance Languages
JavaScript just
https://github.com/TechEmpower/Framewo
rkBenchmarks/blob/master/frameworks/J
avaScript/just/techempower.js
30. Languages & Frameworks
Performance Languages
Java vertx
https://github.com/TechEmpower/Framewo
rkBenchmarks/blob/master/frameworks/J
ava/vertx/src/main/java/vertx/App.java
31. Languages & Frameworks
Performance Frameworks
• Manual tuning in user code
with minimalistic/baremetal framework
• High-level user code
and very optimized/PoC framework
32. Languages & Frameworks
Performance and Production
• e.g. custom PostgreSQL driver
using (at best) MD5 password
• no parsing of the HTTP headers
• optimized for a few identical requests
from a fast local client
• no GC/stability measurement
34. Object Pascal & mORMot
Object Pascal – why not?
• Delphi is mostly Windows-centric
and not an Open Source compiler
• FPC is a niche, underestimated compiler
• Old and boring language
• Mostly used on client side for RAD UI
with a 2-layer DB design
not a 3-layer Web framework design
35. Object Pascal & mORMot
Object Pascal
• As system language:
pointers, buffers - close to the metal
• As high-level language:
class, string, interface - abstract
36. Object Pascal & mORMot
mORMot 2
• 10+ years of Web Server code experience
• Full rewrite
for performance and maintainability
• Validated with the TFB challenge
for stability and scalability
37. Object Pascal & mORMot
mORMot 2
• Cross-platform & cross-compiler RTL
• REST over several Web Servers
• High level SOA/REST using interfaces
• Low level WEB/HTTP classes
38. Object Pascal & mORMot
mORMot 2
• Cross-platform & cross-compiler RTL
• REST over several Web Servers
• High level SOA/REST using interfaces
• Low level WEB/HTTP classes
41. Object Pascal & mORMot
Performance Frameworks
• Manual tuning in user code
with minimalistic/baremetal framework
• High-level user code
and very optimized/PoC framework
43. Some Thoughts
No Magic Bullet
• “Fast” languages could make
“Slow” projects
• “Slow” languages could make
“Fast” projects
44. Some Thoughts
Pascal Still Relevant
• Easy to read and write
• ‘asynchronous-of-the-poor’ ™
anonymous methods do help
still missing an async keyword
• Not restricted to RAD and Windows
• Open Source rocks (FPC & mORMot)