SlideShare a Scribd company logo
Releasing Kyo:
When Performance Meets Elegance In Scala
Flavio Brasil
Functional Scala 2023
How can I build
solutions that are
●Simple
●Safe
●Fast
How can I build
solutions that are
?
Activate
My first open
source project
https://github.com/fwbrasil/activate
Bond
Type-level
validation
https://github.com/fwbrasil/bond
Clump: Batching
https://github.com/getclump/clump
Future: High-perf futures
https://github.com/traneio/future
Arrows: Monadic staging
https://github.com/traneio/arrows
NDBC: Async DB drivers
https://github.com/traneio/ndbc
Quill
Compile-time
Language
Integrated Queries
https://github.com/zio/zio-quill
Monadless
Syntactic sugar
for monads
https://github.com/monadless/monadless
When your hobby
becomes your
worry …
It’s time for a break!
A decade working on
large-scale systems
● SoundCloud, Twitter, Nubank
● Delivered major performance
optimizations for Finagle, Twitter
Future, Stitch, Graal, Clojure
● Saw hundreds of crashes
Scala ♥ Graal
ScalaMatsuri 2019
https://youtu.be/a6dK3eXhO7k?si=T775S1sKFu5B4wSf
Functional
Programming is
great
Functional
Programming is
great (but terrible)
Interpretation
overhead
User-level interpreted language
Highly dynamic execution
High allocation rate
Code complexity
Innovation
begins with
broken rules
ZIO[R, E, A]
ZIO[R, E, A]
type IO[+E, +A] = ZIO[Any, E, A]
type Task[+A] = ZIO[Any, Throwable, A]
type RIO[-R, +A] = ZIO[R, Throwable, A]
type UIO[+A] = ZIO[Any, Nothing, A]
type URIO[-R, +A] = ZIO[R, Nothing, A]
ZIO[R, E, A]
Do we really need a fixed arity?
Why assume the computation uses IO and Async?
Why only dependency injection and short-circuiting?
What if we could express an unbounded number of effects?
Let’s break
the rules
again :)
ZIO[R, E, A]
A > (R & E)
A > (Envs[R] & Aborts[E])
A > Aborts[E]
A > Any
A > Any
A pure value 😱
A > (Envs[Database] & Aborts[DBException])
A > (Envs[Database] & Aborts[DBException] & IOs)
type Databases = Envs[Database] & Aborts[DBException] & IOs
A > Databases
type Caches = Envs[Cache] & IOs
type Databases = Envs[Database] & Aborts[DBException] & IOs
A > (Databases & Caches)
type Caches = Envs[Cache] & IOs
type Databases = Envs[Database] & Aborts[DBException] & Caches
A > Databases
Leveraging
Scala’s advanced
type system
A > (Envs[Database] & Aborts[DBException] & IOs)
A > (Aborts[DBException] & Envs[Database] & IOs)
A > (Aborts[DBException] & IOs & Envs[Database])
Unordered Pending Effects
opaque type >[+T, -S]
Original Design
opaque type >[+T, -S] = T | Kyo[_, _, _, T, S]
Original Design
opaque type >[+T, -S] = T | Kyo[_, _, _, T, S]
Original Design
Implicit conversions
from/to T > Any and T
opaque type >[+T, -S] = T | Kyo[_, _, _, T, S]
After Scala 2 support
type >[+T, -S] >: T
After Scala 2 support
type >[+T, -S] >: T
After Scala 2 support
Any type T is a subclass of T > Any
type >[+T, -S] >: T
After Scala 2 support
Any type T is a subclass of T > Any
val a: Int > Any = 1
val b: Int = a.pure
Effect Widening
val a: Int > Any = 1
Effect Widening
val a: Int > Any = 1
val b: Int > Options = a
Effect Widening
val a: Int > Any = 1
val b: Int > Options = a
val c: Int > (Options & Tries) = b
Effect Widening
val a: Int > Any = 1
val b: Int > Options = a
val c: Int > (Options & Tries) = b
val d: Int > (Options & Tries) = 42
def example1(v: Int > (Options & Tries)) =
v.map(_ + 1)
Fluent APIs
def example1(v: Int > (Options & Tries)) =
v.map(_ + 1)
def example2(v: Int > Tries) =
example1(v)
Fluent APIs
Fluent APIs
def example1(v: Int > (Options & Tries)) =
v.map(_ + 1)
def example2(v: Int > Tries) =
example1(v)
def example3 = example1(42)
There is no
flatMap
(or map depending
on how you see it)
def example(
a: Int > Options,
b: Int > Tries
): Int > (Options & Tries) =
a.flatMap(v => b.map(_ + v))
def example(
a: Int > Options,
b: Int > Tries
): Int > (Options & Tries) =
a.map(v => b.map(_ + v))
Direct
syntax
support
Kyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Quick
effects
rundown
Envs: Dependency Injection
Envs: Dependency Injection
Aborts: Short Circuiting
Aborts: Short Circuiting
Resources: Resource Safety
Lists: Exploratory Branching
Lists: Exploratory Branching
Fibers: Green Threads
Fibers: Green Threads
Requests: HTTP Client via Sttp
Requests: HTTP Client via Sttp
Locals Scoped Values
Aspects Aspect-Oriented Programming
Options Optional Values
Tries Exception Handling
Consoles Console Interaction
Clocks Time Management
Randoms Random Values
Loggers Logging
Stats Observability
Queues Concurrent Queuing
Channels Backpressured Communication
Hubs Broadcasting with Backpressure
Meters Computational Limits
Timers Scheduled Execution
Latches Fiber Coordination
Atomics Concurrent State
Adders Concurrent Accumulation
Caches Memoized Functions via Caffeine
Unparalleled
performance
https://tinyurl.com/kyo-benchs
Targets
Kyo, Cats-effect, ZIO, Ox
Data
Throughput, Allocation, Profiling
Environment
Github Large Runner
8 cores, 32 GB
Ubuntu 22.04
Source code
https://github.com/getkyo/kyo/tree/main/kyo-bench/src/main/scala/kyo/bench
https://tinyurl.com/kyo-benchs
Kyo’s
throughput is
249% higher
than the best contender
(average across benchmarks)
Overhead-free abstraction
Overhead-free abstraction
Overhead-free abstraction
High-performance
asynchronous
primitives
High-performance
asynchronous
primitives
High-performance
asynchronous
primitives
Low-overhead
Fibers
(only 32B
each!)
Low-overhead
Fibers
(only 32B
each!)
Low-overhead
Fibers
(only 32B
each!)
Blazing-fast channels
Blazing-fast channels
Blazing-fast channels
How about
Caprese?
Caprese
Kyo delivers
Caprese’s
key promises
Caprese
Kyo delivers
Caprese’s
key promises
without language
changes
Caprese
Kyo delivers
Caprese’s
key promises
without language
changes,
with a complete set of
effects
Caprese
Kyo delivers Caprese’s
key promises
without language
changes,
with a complete set of
effects
and next-level
performance
Caprese
Kyo delivers Caprese’s
key promises
without language changes,
with a complete set of
effects
and next-level
performance
in Scala 2, 3, and JS
Caprese
Kyo delivers Caprese’s
key promises
without language changes,
with a complete set of
effects
and next-level performance
in Scala 2, 3, and JS
today
CREDITS: This presentation template was created
by Slidesgo, and includes icons by Flaticon and
infographics & images by Freepik
Thanks!
Any questions?
https://getkyo.io
https://dev.to/fwbrasil
@fbrasisil

More Related Content

PPTX
Introduction For seq2seq(sequence to sequence) and RNN
PPTX
How to implement a simple dalvik virtual machine
PPTX
9 subprograms
PPTX
Cypher technique
PDF
Linux Locking Mechanisms
PDF
Rolling upgrade OpenStack
PDF
Dawid Weiss- Finite state automata in lucene
PPTX
Understanding DPDK algorithmics
Introduction For seq2seq(sequence to sequence) and RNN
How to implement a simple dalvik virtual machine
9 subprograms
Cypher technique
Linux Locking Mechanisms
Rolling upgrade OpenStack
Dawid Weiss- Finite state automata in lucene
Understanding DPDK algorithmics

What's hot (20)

PDF
Natural Language Toolkit (NLTK), Basics
PDF
COSCUP2023 RSA256 Verilator.pdf
PPT
linux device driver
PPTX
Introduction Linux Device Drivers
PDF
Seq2Seq (encoder decoder) model
PDF
DPDK In Depth
PPTX
Subprogramms
PDF
Security Monitoring with eBPF
ODP
Dpdk performance
PDF
Multi-armed Bandits
PPTX
Fast boot
PPTX
Tuning PostgreSQL for High Write Throughput
PDF
High-Performance Networking Using eBPF, XDP, and io_uring
PDF
Python programming : Abstract classes interfaces
PPTX
Building Named Entity Recognition Models Efficiently using NERDS
PDF
Project meeting: Android Graphics Architecture Overview
PPTX
Inheritance in c++
PPT
INTRODUCTION TO LISP
PDF
Audio Drivers
Natural Language Toolkit (NLTK), Basics
COSCUP2023 RSA256 Verilator.pdf
linux device driver
Introduction Linux Device Drivers
Seq2Seq (encoder decoder) model
DPDK In Depth
Subprogramms
Security Monitoring with eBPF
Dpdk performance
Multi-armed Bandits
Fast boot
Tuning PostgreSQL for High Write Throughput
High-Performance Networking Using eBPF, XDP, and io_uring
Python programming : Abstract classes interfaces
Building Named Entity Recognition Models Efficiently using NERDS
Project meeting: Android Graphics Architecture Overview
Inheritance in c++
INTRODUCTION TO LISP
Audio Drivers
Ad

Similar to Kyo - Functional Scala 2023.pdf (20)

PDF
The things we don't see – stories of Software, Scala and Akka
PDF
scalaliftoff2009.pdf
PDF
scalaliftoff2009.pdf
PDF
scalaliftoff2009.pdf
PDF
scalaliftoff2009.pdf
PDF
Enterprise Algebras, Scala World 2016
PDF
An Introduction to Scala - Blending OO and Functional Paradigms
PDF
Real Time Big Data Management
PDF
Real world cats
PPTX
PDF
Scala - core features
PDF
PDF
Starting with Scala : Frontier Developer's Meetup December 2010
PPTX
ZIO: Powerful and Principled Functional Programming in Scala
PPT
Scala idioms
PDF
Scala In The Wild
PDF
Getting Started With Scala
PDF
Getting Started With Scala
PDF
What's new in Scala and the Scala IDE for Eclipse for 2.8.0
PDF
Ankara Jug - Practical Functional Programming with Scala
The things we don't see – stories of Software, Scala and Akka
scalaliftoff2009.pdf
scalaliftoff2009.pdf
scalaliftoff2009.pdf
scalaliftoff2009.pdf
Enterprise Algebras, Scala World 2016
An Introduction to Scala - Blending OO and Functional Paradigms
Real Time Big Data Management
Real world cats
Scala - core features
Starting with Scala : Frontier Developer's Meetup December 2010
ZIO: Powerful and Principled Functional Programming in Scala
Scala idioms
Scala In The Wild
Getting Started With Scala
Getting Started With Scala
What's new in Scala and the Scala IDE for Eclipse for 2.8.0
Ankara Jug - Practical Functional Programming with Scala
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PDF
Approach and Philosophy of On baking technology
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MYSQL Presentation for SQL database connectivity
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
Approach and Philosophy of On baking technology
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Kyo - Functional Scala 2023.pdf