SlideShare a Scribd company logo
Code & Coffee #22
Low-latency Java:
breaking the boundaries
Ruslan Shevchenko
<ruslan@shevchenko.kiev.ia>
@rssh1
Overview
❖ What is low-latency and when it needed.
❖ LL-specific programming techniques:
❖ Concurrent flows
❖ Memory
❖ Layout issues,
❖ GC
❖ Unmanaged memory access.
❖ JNI
HPC != HPC
throughput
efficiency
speed
compromise
//low latency
low-latency java:
❖ Ineffective
❖ hardware is underused.
❖ Non-scalable
❖ operational range is strictly defined.
❖ Uncomfortable
❖ api reflect low-level details.
// needed: soft realtime
soft realtime
❖ trading (HTF)
❖ video/audio processing:
❖ orchestration infrastructure:
// NYSE trading floor.
// was closed for humans in 200
softrealtime: why JVM (?)
❖ Balance (99 % - ‘Usual code’, 1% -
soft realtime)
❖ crossing JVM boundaries is expensive.
❖ don’t do this. [if you can]
Softrealtime & JVM: Programming techniques.
❖ Don’t guess, know.
❖ Measure
❖ profiling [not alw. practical];
❖ sampling (jvm option: -hprof) [jvisualvm, jconsole, flight recorder]
❖ log safepoint / gc pauses
❖ Experiments
❖ benchmarks: http://openjdk.java.net/projects/code-tools/jmh/
❖ critical patch: N2N flow.
❖ Know details, how code is executed.
Programming techniques: Concurrent models
❖ Concurrent flows:
❖ minimise context switches:
❖ don’t switch [ number of flows < number of all
processor cores].
❖ Java: main-thread + service-thread + listener-
thread; [ user threads: cores-3 ]
❖ pin thread to core [thread affinity]
❖ JNI [JNA], exists OSS libraries [OpenHFT]
Programming techniques: data exchange
❖ Concurrent flows:
❖ data exchange between threads:
❖ each thread have own ‘local’ memory state.
// state can be unsynchronised
// local access is match faster than volatile
L1 cache: 0.3ns
L2 cache: 1ns
L3 cache: 10ns
RAM: 120ns
Volatile write = RAM write + invalidate cache lines.
❖ queue between threads is faster then shared access.
❖ locks are evil.
Programming techniques: memory issues
❖ GC
❖ young generation (relative short)
❖ full.
❖ [Stop-the-world], pause ~ heap size
❖ Contention
❖ flushing cache lines is expensive
Soft-realtime: memory
❖ Object: what is java object for the JVM ?
class Order
{
long id
int timestamp;
String symbol;
long price;
int quantity;
Side side;
boolean limit;
Party party;
Venue venue;
}
1002,t,”APPL”,p,q,Bu
y/Sell, Owner,
Venue.
Soft-realtime: memory
❖ Object: what is java object for the JVM ?
class Order
{
long id;
int timestamp;
String symbol;
long price;
int quantity;
Side side;
boolean limit;
Party party;
Venue venue;
}
t,”APPL”,p,q,Buy/
Sell, Owner, Venue.
header [64]:
class [32|64]
id [64]:
timestamp 32:
symbol [32-64];
price [64]
quantity[32]
side [32|64]
limit [32]
party [32|64]
venue [32|64]
… padding [0-63]
header,class:128
data: 64 “APPL”
header,class: 128
………..
header,class:128
………..
pointer (direct or compressed)
direct = address in memory
Soft-realtime: memory
❖ Object: what JMV do ?
Order order = new Order() // alloc 80 bytes from heap
// order in a local variables (GC root)
int t = order.getTimestamp(); // memory read
Party p = order.getParty(); // memory read
order.setParty(p1);
// memory write +
//mark object to be rechecked in next GC cycle
//can force GC is memory reached threshold.
Soft-realtime: memory
❖ How ‘idiomatic’ Java code will behave ?
List<Order> send = new ArrayList<>();
while(!buffer.isEmpty()) {
Order order = buffer.readOrder();
int fullPrice = order.price*order.quantity;
if (order.getParty().getLimit()+fullPrice > maxLimit) {
client.rejected(order,”party-limit”)
}else{
engine.process(order);
send.add(order);
}
}
Soft-realtime: memory
❖ How ‘idiomatic’ Java code will behave ?
List<Order> send = new ArrayList<>();
while(!buffer.isEmpty()) {
Order order = buffer.readOrder();
int fullPrice = order.price*order.quantity;
if (order.getParty().getLimit()+fullPrice > maxLimit) {
client.rejected(order,”party-limit”)
}else{
engine.process(order);
send.add(order);
}
}
- order will be created
- added to long-lived collections
will cause ‘StopTheWorld’
Soft-realtime: memory
❖ V1: Die young or live forever.
LongSet send = LongSet.create();
while(!buffer.isEmpty()) {
Order order = buffer.readOrder();
int fullPrice = order.price*order.quantity;
if (order.getParty().getLimit()+fullPrice > maxLimit) {
client.rejected(order,”party-limit”)
}else{
engine.process(order);
send.add(order.getId());
}
}
- order will be created
- collected in young generation
Soft-realtime: memory
❖ V2: Preallocate all.
LongSet send = LongSet.create();
Order order = new Order();
while(!buffer.isEmpty()) {
buffer.fillOrder(order);
int fullPrice = order.price*order.quantity;
if (order.getParty().getLimit()+fullPrice > maxLimit) {
client.rejected(order,”party-limit”)
}else{
engine.process(order);
send.add(order.getId());
}
}
- order will be created
- one ‘static’ object per thread
- no allocations.
Soft-realtime: memory
❖ V3: Access to serialised data instead object
class OrderAccess
{
static void getId(Buffer b,int offset)
{ return b.getLong(offset+0) }
static void putId(Buffer b, int offset, long id)
{ b.putLong(offset+0,id) }
static int getTimestamp(Buffer b, int offset)
{ return b.getInt(offset+8); }
……..
}
Soft-realtime: memory
❖ V3: Access to serialised data instead object
LongSet send = LongSet.create();
for(int offset=0; !buffer.atEnd(offset);
offset+=OrderAccess.SIZE) {
long price = OrderAccess.getPrice(buffer,offset);
int quantity = OrderAccess.getQuantity(buffer,offset);
int fullPrice = price * quantity;
long partyLimit = OrderAccess.getPartyLimit(buffer,offset
if (partyLimit > maxLimit) {
client.rejected(buffer,offset,”party-limit”)
}else{
engine.process(buffer,offset);
send.add(order.getId());
}
}
- no temporary objects
- no allocations
- slightly unusual API
Soft-realtime: memory
❖ V4: Offheap memory access via unsafe
sun.misc.Unsafe
❖ internal low-level sun API
❖ implemented by JIT intrinsic
❖ JVM crash on error
❖ widely used but not recommended
❖ will be deprecated in Java-9
❖ (removed in Java 10)
❖ (we will discuss alternatives)
class Unsafe
{
byte getByte(long addr)
void setByte(long addr, byte value)
….
byte getByte(Object value, long offs)
….
//same for primitive types.
….
// access to Object internals.
}
Soft-realtime: memory
❖ V4: Offheap memory access via unsafe
class OrderAccess
{
static void getId(long address)
{ return unsafe.getLong(address) }
static void putId(long address, long id)
{ unsafe.putLong(offset+0,id) }
static int getTimestamp(Buffer b, int offset)
{ return b.getInt(offset+8); }
……..
}
Soft-realtime: memory
❖ V4: Offheap memory access via unsafe
LongSet send = LongSet.create();
for(long address=buffer.begin; address!=buffer.end();
address=advance(address,OrderAccess.SIZE) ) {
long price = OrderAccess.getPrice(address);
int quantity = OrderAccess.getQuantity(address);
int fullPrice = price * quantity;
long partyLimit = OrderAccess.getPartyLimit(address)
if (partyLimit > maxLimit) {
client.rejected(address,”party-limit”)
}else{
engine.process(address);
send.add(order.getId());
}
}
- no allocations
- any memory
- subtle bugs are possible.
// better wrap by more hight-level interfaces (buffer, etc)
Soft-realtime: memory
❖ V3, V4 Problem: Verbose API
- bytecode transformation from more convenient API
- Metaprogramming within hight-level JVM languages.
http://scala-miniboxing.org/ildl/
https://github.com/densh/scala-offheap
- Integration with unmanaged languages
- JVM with time-limited GC pauses. [Azul Systems]
Memory access API in next JVM versions
❖ VarHandlers (like methodHandlers)
❖ inject custom logic for variable access
❖ JEP 193 http://openjdk.java.net/jeps/193
❖ Value objects.
❖ can be located on stack
❖ JEP 169. http://openjdk.java.net/jeps/169
❖ Own intrinsics [project Panama]
❖ insert assembler instructions into JIT code.
❖ http://openjdk.java.net/projects/panama/
❖ JEP 191. http://openjdk.java.net/jeps/191
❖ ObjectLayout [Arrays 2.0]
❖ better contention
❖ http://objectlayout.github.io/ObjectLayout/
Low latency Java: access to native code
❖ JNA
❖ (idea — API to build native stack call and get result)
❖ pro: not require packaging native libraries.
❖ cons: SLOWWWW (but one-time: ok)
❖ JNI
❖ (idea — bridge between JNI/native code)
❖ pro: faster than JNA, exists critical jni
❖ cons: need packaging native library
❖ Shares Memory
❖ (idea — use same binary address from native & jvm code)
❖ pro: fast
❖ cons: unsafe, unusual API
Low latency Java: JNI
❖ JNI
❖ (idea — bridge between JNI/native code)
❖ Java Object => Handle for native (maintain table)
❖ Callbacks are extremely slow
❖ Critical JNI
❖ not in official documentation
❖ substituted instead JNI after JI
// part of Cliff Click presentation
(advise for VM writers)
Low latency Java: JNI
❖ JNI
❖ (idea — bridge between JNI/native code)
❖ Java Object => Handle for native (maintain table)
❖ Callbacks are extremely slow
extern Java_nativeEventLoop(JEnv jenv, JObject job) {
while(!endOfBuffer(buff)) {
packet p = getData(buff);
if (checked(p)) {
processInJavaCallback(p);
}
}
}
C:
class JNIWrapper
{
void native eventLoop();
void processCallback(Packet p);
}
- p will be marshalled/ unmarshalled each time
- slow
Low latency Java: JNI
extern Java_nativeEvent(JEnv jenv, JObject job) {
static int state = START;
switch(state) {
case START:
state = LOOP;
while(! endOfBuffer()) {
case LOOP:
Packet p = readData();
if (checked(p)) {
return (long)p;
}
}
}
return -1;
}
class JNIWrapper
{
void native event();
void process(long packetAddr
}
…
for(;;) {
p=event();
if (p==-1L) break;
process(p);
}
// better use return instead callback
Low latency Java: JNI
❖ Critical JNI
❖ not in official documentation
❖ substituted instead JNI after JIT warm-up.
❖ only primitive types; static calls.
❖ must not be long-running. (GC is disabled)
extern long Java_nativeEvent(JEnv jenv, JObject job)
->
extern long JavaCritical_nativeEvent()
// want add timeout to satisfy ‘last’ condition
Low latency java: shared memory interface
❖ idea:
❖ spawn process or native thread.
❖ mmap file with given name to memory on ‘native
side’.
❖ mmap file with given name to memory on ‘java’ side.
❖ have shared memory persist to the same file in java &
native code.
Low latency Java/Native code data exchange
// buffer space
shared access
structure
struct BufferAccess
{
volatile long readIndex;
long[7] rpadding;
volatile long writeIndex;
long[7] wpadding;
}
C
class BufferAccessAccess // Java (example)
{
long getReadAddress(long baseAddr)
void setReadAddress(long baseAddr, long readAddr);
long getWriteAddress(long baseAddr)
}
base addr
Java
Low latency Java/fw
❖ Low-latency on JVM is
❖ possible
❖ sometimes non-trivial
❖ special techniques exists, in future will be better.
Thanks for attention.
❖ Questions ?
// ruslan@shevchenko.kiev.ua
// @rssh1
// https://github.com/rssh
Ad

Recommended

Toward low-latency Java applications - javaOne 2014
Toward low-latency Java applications - javaOne 2014
John Davies
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
Ruslan Shevchenko
 
The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018
Charles Nutter
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
Charles Nutter
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
Charles Nutter
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3x
Matthew Gaudet
 
JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013
Vladimir Ivanov
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
Matthew Gaudet
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
Alex Blewitt
 
Swift - Under the Hood
Swift - Under the Hood
C4Media
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
Marcus Lagergren
 
Open Source Swift Under the Hood
Open Source Swift Under the Hood
C4Media
 
Java Performance Tuning
Java Performance Tuning
Minh Hoang
 
How DSL works on Ruby
How DSL works on Ruby
Hiroshi SHIBATA
 
Neo4 + Grails
Neo4 + Grails
stasimus
 
Concurrency Constructs Overview
Concurrency Constructs Overview
stasimus
 
2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization
fangjiafu
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-final
Marcus Lagergren
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
Serge Stinckwich
 
IDLs
IDLs
Ruslan Shevchenko
 
The Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics Development
ukdpe
 
DSLs in JavaScript
DSLs in JavaScript
elliando dias
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
ngotogenome
 
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
MLconf
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
mametter
 
WTF is Twisted?
WTF is Twisted?
hawkowl
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Low latency Java apps
Low latency Java apps
Simon Ritter
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
J On The Beach
 
Java Concurrency Quick Guide
Java Concurrency Quick Guide
Anton Shchastnyi
 

More Related Content

What's hot (19)

Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
Alex Blewitt
 
Swift - Under the Hood
Swift - Under the Hood
C4Media
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
Marcus Lagergren
 
Open Source Swift Under the Hood
Open Source Swift Under the Hood
C4Media
 
Java Performance Tuning
Java Performance Tuning
Minh Hoang
 
How DSL works on Ruby
How DSL works on Ruby
Hiroshi SHIBATA
 
Neo4 + Grails
Neo4 + Grails
stasimus
 
Concurrency Constructs Overview
Concurrency Constructs Overview
stasimus
 
2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization
fangjiafu
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-final
Marcus Lagergren
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
Serge Stinckwich
 
IDLs
IDLs
Ruslan Shevchenko
 
The Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics Development
ukdpe
 
DSLs in JavaScript
DSLs in JavaScript
elliando dias
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
ngotogenome
 
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
MLconf
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
mametter
 
WTF is Twisted?
WTF is Twisted?
hawkowl
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Swift 2 Under the Hood - Gotober 2015
Swift 2 Under the Hood - Gotober 2015
Alex Blewitt
 
Swift - Under the Hood
Swift - Under the Hood
C4Media
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
Marcus Lagergren
 
Open Source Swift Under the Hood
Open Source Swift Under the Hood
C4Media
 
Java Performance Tuning
Java Performance Tuning
Minh Hoang
 
Neo4 + Grails
Neo4 + Grails
stasimus
 
Concurrency Constructs Overview
Concurrency Constructs Overview
stasimus
 
2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization
fangjiafu
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-final
Marcus Lagergren
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
Serge Stinckwich
 
The Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics Development
ukdpe
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
ngotogenome
 
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
Chris Fregly, Research Scientist, PipelineIO at MLconf ATL 2016
MLconf
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
mametter
 
WTF is Twisted?
WTF is Twisted?
hawkowl
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 

Viewers also liked (20)

Low latency Java apps
Low latency Java apps
Simon Ritter
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
J On The Beach
 
Java Concurrency Quick Guide
Java Concurrency Quick Guide
Anton Shchastnyi
 
Get Back in Control of your SQL
Get Back in Control of your SQL
Java Usergroup Berlin-Brandenburg
 
Die Java Plattform Strategie
Die Java Plattform Strategie
Java Usergroup Berlin-Brandenburg
 
Presentation Erfolgreiche Software mit großartiger Dokumentation - Asciidoctor
Presentation Erfolgreiche Software mit großartiger Dokumentation - Asciidoctor
Robert Panzer
 
Robust and Scalable Concurrent Programming: Lesson from the Trenches
Robust and Scalable Concurrent Programming: Lesson from the Trenches
Sangjin Lee
 
IBM Java PackedObjects
IBM Java PackedObjects
Marcel Mitran
 
Was jeder Java-Entwickler über Strings wissen sollte
Was jeder Java-Entwickler über Strings wissen sollte
berndmueller
 
What are the Cool Kids Doing With Continuous Delivery?
What are the Cool Kids Doing With Continuous Delivery?
CA Technologies
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe World
Christoph Engelbert
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
Technische Schulden in Architekturen erkennen und beseitigen
Technische Schulden in Architekturen erkennen und beseitigen
Carola Lilienthal
 
Workshop: Introduction to the Disruptor
Workshop: Introduction to the Disruptor
Trisha Gee
 
Infrastructure as Code
Infrastructure as Code
Sascha Möllering
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
Robert Scholte
 
Introduction to the Disruptor
Introduction to the Disruptor
Trisha Gee
 
Continuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as Code
Sascha Möllering
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
Takipi
 
Built To Last - Nachhaltige Software-Entwicklung
Built To Last - Nachhaltige Software-Entwicklung
Java Usergroup Berlin-Brandenburg
 
Low latency Java apps
Low latency Java apps
Simon Ritter
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
J On The Beach
 
Java Concurrency Quick Guide
Java Concurrency Quick Guide
Anton Shchastnyi
 
Presentation Erfolgreiche Software mit großartiger Dokumentation - Asciidoctor
Presentation Erfolgreiche Software mit großartiger Dokumentation - Asciidoctor
Robert Panzer
 
Robust and Scalable Concurrent Programming: Lesson from the Trenches
Robust and Scalable Concurrent Programming: Lesson from the Trenches
Sangjin Lee
 
IBM Java PackedObjects
IBM Java PackedObjects
Marcel Mitran
 
Was jeder Java-Entwickler über Strings wissen sollte
Was jeder Java-Entwickler über Strings wissen sollte
berndmueller
 
What are the Cool Kids Doing With Continuous Delivery?
What are the Cool Kids Doing With Continuous Delivery?
CA Technologies
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe World
Christoph Engelbert
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
Technische Schulden in Architekturen erkennen und beseitigen
Technische Schulden in Architekturen erkennen und beseitigen
Carola Lilienthal
 
Workshop: Introduction to the Disruptor
Workshop: Introduction to the Disruptor
Trisha Gee
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
Robert Scholte
 
Introduction to the Disruptor
Introduction to the Disruptor
Trisha Gee
 
Continuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as Code
Sascha Möllering
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
Takipi
 
Ad

Similar to Java & low latency applications (20)

QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
The State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila Szegedi
ZeroTurnaround
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Tech in Asia ID
 
Evented Ruby VS Node.js
Evented Ruby VS Node.js
Nitin Gupta
 
Engineer Engineering Software
Engineer Engineering Software
Yung-Yu Chen
 
What’s Slowing Down Your Kafka Pipeline? With Ruizhe Cheng and Pete Stevenson...
What’s Slowing Down Your Kafka Pipeline? With Ruizhe Cheng and Pete Stevenson...
HostedbyConfluent
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
Quey-Liang Kao
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
sosorry
 
introduction to node.js
introduction to node.js
orkaplan
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
Alexandra Masterson
 
Node
Node
Arjun Raj
 
Experiences with Microservices at Tuenti
Experiences with Microservices at Tuenti
Andrés Viedma Peláez
 
Quantifying the Performance Impact of Shard-per-core Architecture
Quantifying the Performance Impact of Shard-per-core Architecture
ScyllaDB
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
OpenBlend society
 
Highly concurrent yet natural programming
Highly concurrent yet natural programming
Infinit
 
Jvm profiling under the hood
Jvm profiling under the hood
RichardWarburton
 
Node js
Node js
hazzaz
 
Node.js for Rubists
Node.js for Rubists
Sagiv Ofek
 
Get your teeth into Plack
Get your teeth into Plack
Workhorse Computing
 
QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
The State of Managed Runtimes 2013, by Attila Szegedi
The State of Managed Runtimes 2013, by Attila Szegedi
ZeroTurnaround
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
Tech in Asia ID
 
Evented Ruby VS Node.js
Evented Ruby VS Node.js
Nitin Gupta
 
Engineer Engineering Software
Engineer Engineering Software
Yung-Yu Chen
 
What’s Slowing Down Your Kafka Pipeline? With Ruizhe Cheng and Pete Stevenson...
What’s Slowing Down Your Kafka Pipeline? With Ruizhe Cheng and Pete Stevenson...
HostedbyConfluent
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
Quey-Liang Kao
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
sosorry
 
introduction to node.js
introduction to node.js
orkaplan
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
Alexandra Masterson
 
Experiences with Microservices at Tuenti
Experiences with Microservices at Tuenti
Andrés Viedma Peláez
 
Quantifying the Performance Impact of Shard-per-core Architecture
Quantifying the Performance Impact of Shard-per-core Architecture
ScyllaDB
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
OpenBlend society
 
Highly concurrent yet natural programming
Highly concurrent yet natural programming
Infinit
 
Jvm profiling under the hood
Jvm profiling under the hood
RichardWarburton
 
Node js
Node js
hazzaz
 
Node.js for Rubists
Node.js for Rubists
Sagiv Ofek
 
Ad

More from Ruslan Shevchenko (20)

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Ruslan Shevchenko
 
Svitla talks 2021_03_25
Svitla talks 2021_03_25
Ruslan Shevchenko
 
Akka / Lts behavior
Akka / Lts behavior
Ruslan Shevchenko
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Ruslan Shevchenko
 
Scala / Technology evolution
Scala / Technology evolution
Ruslan Shevchenko
 
{co/contr} variance from LSP
{co/contr} variance from LSP
Ruslan Shevchenko
 
N flavors of streaming
N flavors of streaming
Ruslan Shevchenko
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Ruslan Shevchenko
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
Ruslan Shevchenko
 
Few simple-type-tricks in scala
Few simple-type-tricks in scala
Ruslan Shevchenko
 
Scala jargon cheatsheet
Scala jargon cheatsheet
Ruslan Shevchenko
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016
Ruslan Shevchenko
 
R ext world/ useR! Kiev
R ext world/ useR! Kiev
Ruslan Shevchenko
 
Jslab rssh: JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 
Behind OOD: domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
Ruslan Shevchenko
 
scala-gopher: async implementation of CSP for scala
scala-gopher: async implementation of CSP for scala
Ruslan Shevchenko
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N years
Ruslan Shevchenko
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
Ruslan Shevchenko
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan Shevchenko
 
Web architecture - overview of techniques.
Web architecture - overview of techniques.
Ruslan Shevchenko
 
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Ruslan Shevchenko
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Ruslan Shevchenko
 
Scala / Technology evolution
Scala / Technology evolution
Ruslan Shevchenko
 
{co/contr} variance from LSP
{co/contr} variance from LSP
Ruslan Shevchenko
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Ruslan Shevchenko
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
Ruslan Shevchenko
 
Few simple-type-tricks in scala
Few simple-type-tricks in scala
Ruslan Shevchenko
 
Jslab rssh: JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 
Behind OOD: domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
Ruslan Shevchenko
 
scala-gopher: async implementation of CSP for scala
scala-gopher: async implementation of CSP for scala
Ruslan Shevchenko
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N years
Ruslan Shevchenko
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
Ruslan Shevchenko
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan Shevchenko
 
Web architecture - overview of techniques.
Web architecture - overview of techniques.
Ruslan Shevchenko
 

Recently uploaded (20)

Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
ElectraSuite_Prsentation(online voting system).pptx
ElectraSuite_Prsentation(online voting system).pptx
mrsinankhan01
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
ElectraSuite_Prsentation(online voting system).pptx
ElectraSuite_Prsentation(online voting system).pptx
mrsinankhan01
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 

Java & low latency applications

  • 1. Code & Coffee #22 Low-latency Java: breaking the boundaries Ruslan Shevchenko <[email protected]> @rssh1
  • 2. Overview ❖ What is low-latency and when it needed. ❖ LL-specific programming techniques: ❖ Concurrent flows ❖ Memory ❖ Layout issues, ❖ GC ❖ Unmanaged memory access. ❖ JNI
  • 4. low-latency java: ❖ Ineffective ❖ hardware is underused. ❖ Non-scalable ❖ operational range is strictly defined. ❖ Uncomfortable ❖ api reflect low-level details. // needed: soft realtime
  • 5. soft realtime ❖ trading (HTF) ❖ video/audio processing: ❖ orchestration infrastructure: // NYSE trading floor. // was closed for humans in 200
  • 6. softrealtime: why JVM (?) ❖ Balance (99 % - ‘Usual code’, 1% - soft realtime) ❖ crossing JVM boundaries is expensive. ❖ don’t do this. [if you can]
  • 7. Softrealtime & JVM: Programming techniques. ❖ Don’t guess, know. ❖ Measure ❖ profiling [not alw. practical]; ❖ sampling (jvm option: -hprof) [jvisualvm, jconsole, flight recorder] ❖ log safepoint / gc pauses ❖ Experiments ❖ benchmarks: http://openjdk.java.net/projects/code-tools/jmh/ ❖ critical patch: N2N flow. ❖ Know details, how code is executed.
  • 8. Programming techniques: Concurrent models ❖ Concurrent flows: ❖ minimise context switches: ❖ don’t switch [ number of flows < number of all processor cores]. ❖ Java: main-thread + service-thread + listener- thread; [ user threads: cores-3 ] ❖ pin thread to core [thread affinity] ❖ JNI [JNA], exists OSS libraries [OpenHFT]
  • 9. Programming techniques: data exchange ❖ Concurrent flows: ❖ data exchange between threads: ❖ each thread have own ‘local’ memory state. // state can be unsynchronised // local access is match faster than volatile L1 cache: 0.3ns L2 cache: 1ns L3 cache: 10ns RAM: 120ns Volatile write = RAM write + invalidate cache lines. ❖ queue between threads is faster then shared access. ❖ locks are evil.
  • 10. Programming techniques: memory issues ❖ GC ❖ young generation (relative short) ❖ full. ❖ [Stop-the-world], pause ~ heap size ❖ Contention ❖ flushing cache lines is expensive
  • 11. Soft-realtime: memory ❖ Object: what is java object for the JVM ? class Order { long id int timestamp; String symbol; long price; int quantity; Side side; boolean limit; Party party; Venue venue; } 1002,t,”APPL”,p,q,Bu y/Sell, Owner, Venue.
  • 12. Soft-realtime: memory ❖ Object: what is java object for the JVM ? class Order { long id; int timestamp; String symbol; long price; int quantity; Side side; boolean limit; Party party; Venue venue; } t,”APPL”,p,q,Buy/ Sell, Owner, Venue. header [64]: class [32|64] id [64]: timestamp 32: symbol [32-64]; price [64] quantity[32] side [32|64] limit [32] party [32|64] venue [32|64] … padding [0-63] header,class:128 data: 64 “APPL” header,class: 128 ……….. header,class:128 ……….. pointer (direct or compressed) direct = address in memory
  • 13. Soft-realtime: memory ❖ Object: what JMV do ? Order order = new Order() // alloc 80 bytes from heap // order in a local variables (GC root) int t = order.getTimestamp(); // memory read Party p = order.getParty(); // memory read order.setParty(p1); // memory write + //mark object to be rechecked in next GC cycle //can force GC is memory reached threshold.
  • 14. Soft-realtime: memory ❖ How ‘idiomatic’ Java code will behave ? List<Order> send = new ArrayList<>(); while(!buffer.isEmpty()) { Order order = buffer.readOrder(); int fullPrice = order.price*order.quantity; if (order.getParty().getLimit()+fullPrice > maxLimit) { client.rejected(order,”party-limit”) }else{ engine.process(order); send.add(order); } }
  • 15. Soft-realtime: memory ❖ How ‘idiomatic’ Java code will behave ? List<Order> send = new ArrayList<>(); while(!buffer.isEmpty()) { Order order = buffer.readOrder(); int fullPrice = order.price*order.quantity; if (order.getParty().getLimit()+fullPrice > maxLimit) { client.rejected(order,”party-limit”) }else{ engine.process(order); send.add(order); } } - order will be created - added to long-lived collections will cause ‘StopTheWorld’
  • 16. Soft-realtime: memory ❖ V1: Die young or live forever. LongSet send = LongSet.create(); while(!buffer.isEmpty()) { Order order = buffer.readOrder(); int fullPrice = order.price*order.quantity; if (order.getParty().getLimit()+fullPrice > maxLimit) { client.rejected(order,”party-limit”) }else{ engine.process(order); send.add(order.getId()); } } - order will be created - collected in young generation
  • 17. Soft-realtime: memory ❖ V2: Preallocate all. LongSet send = LongSet.create(); Order order = new Order(); while(!buffer.isEmpty()) { buffer.fillOrder(order); int fullPrice = order.price*order.quantity; if (order.getParty().getLimit()+fullPrice > maxLimit) { client.rejected(order,”party-limit”) }else{ engine.process(order); send.add(order.getId()); } } - order will be created - one ‘static’ object per thread - no allocations.
  • 18. Soft-realtime: memory ❖ V3: Access to serialised data instead object class OrderAccess { static void getId(Buffer b,int offset) { return b.getLong(offset+0) } static void putId(Buffer b, int offset, long id) { b.putLong(offset+0,id) } static int getTimestamp(Buffer b, int offset) { return b.getInt(offset+8); } …….. }
  • 19. Soft-realtime: memory ❖ V3: Access to serialised data instead object LongSet send = LongSet.create(); for(int offset=0; !buffer.atEnd(offset); offset+=OrderAccess.SIZE) { long price = OrderAccess.getPrice(buffer,offset); int quantity = OrderAccess.getQuantity(buffer,offset); int fullPrice = price * quantity; long partyLimit = OrderAccess.getPartyLimit(buffer,offset if (partyLimit > maxLimit) { client.rejected(buffer,offset,”party-limit”) }else{ engine.process(buffer,offset); send.add(order.getId()); } } - no temporary objects - no allocations - slightly unusual API
  • 20. Soft-realtime: memory ❖ V4: Offheap memory access via unsafe sun.misc.Unsafe ❖ internal low-level sun API ❖ implemented by JIT intrinsic ❖ JVM crash on error ❖ widely used but not recommended ❖ will be deprecated in Java-9 ❖ (removed in Java 10) ❖ (we will discuss alternatives) class Unsafe { byte getByte(long addr) void setByte(long addr, byte value) …. byte getByte(Object value, long offs) …. //same for primitive types. …. // access to Object internals. }
  • 21. Soft-realtime: memory ❖ V4: Offheap memory access via unsafe class OrderAccess { static void getId(long address) { return unsafe.getLong(address) } static void putId(long address, long id) { unsafe.putLong(offset+0,id) } static int getTimestamp(Buffer b, int offset) { return b.getInt(offset+8); } …….. }
  • 22. Soft-realtime: memory ❖ V4: Offheap memory access via unsafe LongSet send = LongSet.create(); for(long address=buffer.begin; address!=buffer.end(); address=advance(address,OrderAccess.SIZE) ) { long price = OrderAccess.getPrice(address); int quantity = OrderAccess.getQuantity(address); int fullPrice = price * quantity; long partyLimit = OrderAccess.getPartyLimit(address) if (partyLimit > maxLimit) { client.rejected(address,”party-limit”) }else{ engine.process(address); send.add(order.getId()); } } - no allocations - any memory - subtle bugs are possible. // better wrap by more hight-level interfaces (buffer, etc)
  • 23. Soft-realtime: memory ❖ V3, V4 Problem: Verbose API - bytecode transformation from more convenient API - Metaprogramming within hight-level JVM languages. http://scala-miniboxing.org/ildl/ https://github.com/densh/scala-offheap - Integration with unmanaged languages - JVM with time-limited GC pauses. [Azul Systems]
  • 24. Memory access API in next JVM versions ❖ VarHandlers (like methodHandlers) ❖ inject custom logic for variable access ❖ JEP 193 http://openjdk.java.net/jeps/193 ❖ Value objects. ❖ can be located on stack ❖ JEP 169. http://openjdk.java.net/jeps/169 ❖ Own intrinsics [project Panama] ❖ insert assembler instructions into JIT code. ❖ http://openjdk.java.net/projects/panama/ ❖ JEP 191. http://openjdk.java.net/jeps/191 ❖ ObjectLayout [Arrays 2.0] ❖ better contention ❖ http://objectlayout.github.io/ObjectLayout/
  • 25. Low latency Java: access to native code ❖ JNA ❖ (idea — API to build native stack call and get result) ❖ pro: not require packaging native libraries. ❖ cons: SLOWWWW (but one-time: ok) ❖ JNI ❖ (idea — bridge between JNI/native code) ❖ pro: faster than JNA, exists critical jni ❖ cons: need packaging native library ❖ Shares Memory ❖ (idea — use same binary address from native & jvm code) ❖ pro: fast ❖ cons: unsafe, unusual API
  • 26. Low latency Java: JNI ❖ JNI ❖ (idea — bridge between JNI/native code) ❖ Java Object => Handle for native (maintain table) ❖ Callbacks are extremely slow ❖ Critical JNI ❖ not in official documentation ❖ substituted instead JNI after JI // part of Cliff Click presentation (advise for VM writers)
  • 27. Low latency Java: JNI ❖ JNI ❖ (idea — bridge between JNI/native code) ❖ Java Object => Handle for native (maintain table) ❖ Callbacks are extremely slow extern Java_nativeEventLoop(JEnv jenv, JObject job) { while(!endOfBuffer(buff)) { packet p = getData(buff); if (checked(p)) { processInJavaCallback(p); } } } C: class JNIWrapper { void native eventLoop(); void processCallback(Packet p); } - p will be marshalled/ unmarshalled each time - slow
  • 28. Low latency Java: JNI extern Java_nativeEvent(JEnv jenv, JObject job) { static int state = START; switch(state) { case START: state = LOOP; while(! endOfBuffer()) { case LOOP: Packet p = readData(); if (checked(p)) { return (long)p; } } } return -1; } class JNIWrapper { void native event(); void process(long packetAddr } … for(;;) { p=event(); if (p==-1L) break; process(p); } // better use return instead callback
  • 29. Low latency Java: JNI ❖ Critical JNI ❖ not in official documentation ❖ substituted instead JNI after JIT warm-up. ❖ only primitive types; static calls. ❖ must not be long-running. (GC is disabled) extern long Java_nativeEvent(JEnv jenv, JObject job) -> extern long JavaCritical_nativeEvent() // want add timeout to satisfy ‘last’ condition
  • 30. Low latency java: shared memory interface ❖ idea: ❖ spawn process or native thread. ❖ mmap file with given name to memory on ‘native side’. ❖ mmap file with given name to memory on ‘java’ side. ❖ have shared memory persist to the same file in java & native code.
  • 31. Low latency Java/Native code data exchange // buffer space shared access structure struct BufferAccess { volatile long readIndex; long[7] rpadding; volatile long writeIndex; long[7] wpadding; } C class BufferAccessAccess // Java (example) { long getReadAddress(long baseAddr) void setReadAddress(long baseAddr, long readAddr); long getWriteAddress(long baseAddr) } base addr Java
  • 32. Low latency Java/fw ❖ Low-latency on JVM is ❖ possible ❖ sometimes non-trivial ❖ special techniques exists, in future will be better.
  • 33. Thanks for attention. ❖ Questions ? // [email protected] // @rssh1 // https://github.com/rssh