SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
JPoint 2015
Conference
overview
 Memory leaks profiling basics
 Some notes about java.lang.String class
 What technical debt is. How to measure it and how to sell.
 Regular expressions under hood
 Conclusion
Agenda
Memory Leaks
Different regions of memory
Default sizes
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal –version
Non-default sizes
-Xmx2g -Xms2g -XX:MaxPermSize=128m
-XX:MaxPermSize=128m
Garbage Collector
JVM subsystem responsible for object allocation and removing
OutOfMemoryError
JVM and Memory
Unused object - object with no reference on it
References:
From an object to the value of one of its instance fields
From an array to one of its elements
From an object to its class
From a class to its class loader
From a class to the value of one of its static fields
From a class to its superclass
GC roots - special objects, always considered to be alive
Reachability
Memory Leaks: Unused Objects
Memory Leaks
Caches without look-ups and eviction
Immortal threads
Unclosed IO streams
String.substring()
NOT Memory Leaks
Too high allocation rate
Cache with wrong size
Trying to load too much data at once
Fat data structures
Memory Leaks: Examples
JVM Options
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:file.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGClogFiles=N
GC Logs Analyzers
GCViewer
Fasterj
Memory Leaks: GC Logs
Binary representation of objects graph written to a file
One of the best ways to find out what consumes memory
Getting memory dump:
jmap -dump:format=b,file=heap.hprof
(!) Stop The World, 1 Thread, 4Gb ~4 sec
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./java_pid<pid>.hprof
Get as late as possible
Memory dump analyze tool:
MAT
Memory Leaks: Memory Dump
Shallow – size of the object itself with headers and fields but without
fields values
Deep – size of the object itself with headers, fields and fields values
Retained – the sub-graph size that will be unreached if we remove the
object
Memory Leaks: Object Size
Memory Leaks: MAT
Some Notes about
java.lang.String
Immutable
25% of objects are java.lang.String
String concat vs StringBuilder (3250 op/sec vs 125000 op/sec)
-XX:±OptimizeStringConcat
String
OFFSET SIZE TYPE DESCRIPTION
0 12 object header
12 4 char[] value
16 4 int hash
20 4 alligmeent loss
(“” + x) is faster then Integer.toString(x) (!) -XX:+OptimizeStringConcat
with side effects optimization is not working
string in JDK8 have no seek and count properties
do not use .intern() method as cache
StringTable is overflowed and can not be resized
-XX :+ PrintStringTableStatistics
equals implementation is intrinsic function (chose by compiler)
-XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=::_equals
String: Notes
String: HashCode Example
String str1 , str2 ;
public void setup () {
str1 = “superinstrument␣neglected"; // same length
str2 = " neglected␣ superinstrument "; // same length
}
int test1 () { return str1 . hashCode (); }
int test2 () { return str2 . hashCode (); }
Uses polynomial function
Collisions (the same result for different values)
String: HashCode
public int hashCode () {
int h = hash ;
if (h == 0) {
for ( char v : value ) {
h = 31 * h + v;
}
hash = h;
}
return h;
}
String: Regexp
String text = “Funny␣girl␣danced␣fell␣hurt␣and␣cried␣aloud.";
String textDup = text.replaceAll ("␣", "␣␣");
Pattern pattern = Pattern.compile ("␣␣");
String [] charSplit () { return text.split ("␣"); } //191.6 ns/op
String [] strSplit () { return textDup.split ("␣␣"); } //527.9 ns/op
String [] strSplit_pattern () { return pattern.split(textDup); } //416.2 ns/op
charSplit: fast path for 1 byte symbols
strSplit: internally creates Pattern
strSplit_pattern: reuse Pattern
Technical debt
Try to not create a technical debt
Code review
Precision estimates
Bus factor (save information)
Try to measure the date your application will start suffer from this debt
Collect metrics as much as possible
Try to build trend
Fishy code
Technical Debt
Include small refactoring in estimates
Formal code quality metrics (clear for you, not so clear for customer)
Developers group motivation (to not lose)
Technical Debt: Selling
Regular expressions
under hood
Backtrack
/^.*ab$/ matches “ab”
/^.*?b$/ matches “aab”
can took 30 sec in 100Kb text
Pattern.compile("(Joker|JPoint)+")
String "JokerJPoint…700 times…Joker“ will cause StackOverflowError
Solutions:
Pattern.compile("(Joker|JPoint)++") – possessive
Pattern.compile("(?>Joker|JPoint)+") – forget back-reference
Regular Expressions: Backtrack
Regular Expressions: Impl
TITLE RELEASED ALGORITHM
java.util.regex.Pattern 2015 Backtrack
com.basistech.tclre 2015 DFA
org.jruby.joni (Nashorn) 2014 Backtrack
Apache Oro 2000 Backtrack
JRegex 2013 backtrack
Deterministic automa
Non-deterministic automa
Regular Expressions: Test
/(x+x+)+y/.test("xxxxx……xxx")
Regular Expressions: Tradeoff
Java pattern
Non-deterministic response time
Managed backtrack
Low memory usage
TCL
DFA algorithm with deterministic response time
High memory usage
Visit Sperasoft online:
www/sperasoft.com
www.facebook.com/Sperasoft
www.twitter.com/sperasoft
Thanks!

Mais conteúdo relacionado

Mais procurados

Objective c
Objective cObjective c
Objective cStijn
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++•sreejith •sree
 
Face detection
Face detectionFace detection
Face detectionvmk
 
Flash workshop Day Three
Flash workshop Day ThreeFlash workshop Day Three
Flash workshop Day ThreeLaw Chng
 
Scientific computing on jruby
Scientific computing on jrubyScientific computing on jruby
Scientific computing on jrubyPrasun Anand
 
Fosdem2017 Scientific computing on Jruby
Fosdem2017  Scientific computing on JrubyFosdem2017  Scientific computing on Jruby
Fosdem2017 Scientific computing on JrubyPrasun Anand
 
Gremlin-ATL: a Scalable Model Transformation Framework
Gremlin-ATL: a Scalable Model Transformation FrameworkGremlin-ATL: a Scalable Model Transformation Framework
Gremlin-ATL: a Scalable Model Transformation FrameworkGwendal Daniel
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)Sangharsh agarwal
 
Generalized Linear Models with H2O
Generalized Linear Models with H2O Generalized Linear Models with H2O
Generalized Linear Models with H2O Sri Ambati
 
Stl Containers
Stl ContainersStl Containers
Stl Containersppd1961
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsPawanMM
 
A brief introduction to scalaz-stream
A brief introduction to scalaz-streamA brief introduction to scalaz-stream
A brief introduction to scalaz-streamFrank Thomas
 
Neo, Titan & Cassandra
Neo, Titan & CassandraNeo, Titan & Cassandra
Neo, Titan & Cassandrajohnrjenson
 

Mais procurados (20)

Lecture1
Lecture1Lecture1
Lecture1
 
Templates2
Templates2Templates2
Templates2
 
Objective c
Objective cObjective c
Objective c
 
STL in C++
STL in C++STL in C++
STL in C++
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Face detection
Face detectionFace detection
Face detection
 
Flash workshop Day Three
Flash workshop Day ThreeFlash workshop Day Three
Flash workshop Day Three
 
Scientific computing on jruby
Scientific computing on jrubyScientific computing on jruby
Scientific computing on jruby
 
Fosdem2017 Scientific computing on Jruby
Fosdem2017  Scientific computing on JrubyFosdem2017  Scientific computing on Jruby
Fosdem2017 Scientific computing on Jruby
 
Gremlin-ATL: a Scalable Model Transformation Framework
Gremlin-ATL: a Scalable Model Transformation FrameworkGremlin-ATL: a Scalable Model Transformation Framework
Gremlin-ATL: a Scalable Model Transformation Framework
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
 
Generalized Linear Models with H2O
Generalized Linear Models with H2O Generalized Linear Models with H2O
Generalized Linear Models with H2O
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
 
Lecture1 classes4
Lecture1 classes4Lecture1 classes4
Lecture1 classes4
 
A brief introduction to scalaz-stream
A brief introduction to scalaz-streamA brief introduction to scalaz-stream
A brief introduction to scalaz-stream
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Neo, Titan & Cassandra
Neo, Titan & CassandraNeo, Titan & Cassandra
Neo, Titan & Cassandra
 

Destaque

Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyondFabio Tiriticco
 
The spanish civil war
The spanish civil warThe spanish civil war
The spanish civil warPeter Abarca
 
Updated CV- Mmako
Updated CV- MmakoUpdated CV- Mmako
Updated CV- MmakoMmako Abram
 
Bolshevik Russia
Bolshevik RussiaBolshevik Russia
Bolshevik Russiakhooky
 
"Dall'informazione all’esperienza” - Federico Badaloni
"Dall'informazione all’esperienza” - Federico Badaloni"Dall'informazione all’esperienza” - Federico Badaloni
"Dall'informazione all’esperienza” - Federico Badaloninois3
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond RxFabio Tiriticco
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx javaCongTrung Vnit
 
The Spanish Civil War
The Spanish Civil WarThe Spanish Civil War
The Spanish Civil Warrakochy
 
Brand Positioning & Point parity,Point of difference.
Brand Positioning & Point parity,Point of difference.Brand Positioning & Point parity,Point of difference.
Brand Positioning & Point parity,Point of difference.Shofique Mahmud
 
Speed up your Tests - Devi Sridharan, ThoughtWorks
Speed up your Tests - Devi Sridharan, ThoughtWorksSpeed up your Tests - Devi Sridharan, ThoughtWorks
Speed up your Tests - Devi Sridharan, ThoughtWorksThoughtworks
 
Ascoltare la città - Rete di laboratori diffusi
Ascoltare la città - Rete di laboratori diffusiAscoltare la città - Rete di laboratori diffusi
Ascoltare la città - Rete di laboratori diffusiMarco Muzzarelli
 
Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Nate Murray
 
WCC Copyright blackboard-b bposting
WCC Copyright blackboard-b bpostingWCC Copyright blackboard-b bposting
WCC Copyright blackboard-b bpostingEdu Calvachi
 
Javascript Dependency Management
Javascript Dependency ManagementJavascript Dependency Management
Javascript Dependency ManagementSean Duncan
 
servidores+de+contenidos
servidores+de+contenidosservidores+de+contenidos
servidores+de+contenidosLissml
 

Destaque (20)

Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
 
Treaty of St Germain 1919
Treaty of St Germain 1919Treaty of St Germain 1919
Treaty of St Germain 1919
 
The spanish civil war
The spanish civil warThe spanish civil war
The spanish civil war
 
Updated CV- Mmako
Updated CV- MmakoUpdated CV- Mmako
Updated CV- Mmako
 
Nike brand mantra
Nike brand mantraNike brand mantra
Nike brand mantra
 
BDA CV
BDA CVBDA CV
BDA CV
 
Bolshevik Russia
Bolshevik RussiaBolshevik Russia
Bolshevik Russia
 
"Dall'informazione all’esperienza” - Federico Badaloni
"Dall'informazione all’esperienza” - Federico Badaloni"Dall'informazione all’esperienza” - Federico Badaloni
"Dall'informazione all’esperienza” - Federico Badaloni
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond Rx
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
 
The Spanish Civil War
The Spanish Civil WarThe Spanish Civil War
The Spanish Civil War
 
Brand Positioning & Point parity,Point of difference.
Brand Positioning & Point parity,Point of difference.Brand Positioning & Point parity,Point of difference.
Brand Positioning & Point parity,Point of difference.
 
Kilimo Bora Kwa Kina Mama Project: Empowering Women through Crop Cultivation ...
Kilimo Bora Kwa Kina Mama Project: Empowering Women through Crop Cultivation ...Kilimo Bora Kwa Kina Mama Project: Empowering Women through Crop Cultivation ...
Kilimo Bora Kwa Kina Mama Project: Empowering Women through Crop Cultivation ...
 
Speed up your Tests - Devi Sridharan, ThoughtWorks
Speed up your Tests - Devi Sridharan, ThoughtWorksSpeed up your Tests - Devi Sridharan, ThoughtWorks
Speed up your Tests - Devi Sridharan, ThoughtWorks
 
Ascoltare la città - Rete di laboratori diffusi
Ascoltare la città - Rete di laboratori diffusiAscoltare la città - Rete di laboratori diffusi
Ascoltare la città - Rete di laboratori diffusi
 
Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2Getting Started with PoolParty and EC2
Getting Started with PoolParty and EC2
 
WCC Copyright blackboard-b bposting
WCC Copyright blackboard-b bpostingWCC Copyright blackboard-b bposting
WCC Copyright blackboard-b bposting
 
Javascript Dependency Management
Javascript Dependency ManagementJavascript Dependency Management
Javascript Dependency Management
 
Qatar open data
Qatar open dataQatar open data
Qatar open data
 
servidores+de+contenidos
servidores+de+contenidosservidores+de+contenidos
servidores+de+contenidos
 

Semelhante a Sperasoft‬ talks j point 2015

JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...Maarten Balliauw
 
Introduction to c_plus_plus (6)
Introduction to c_plus_plus (6)Introduction to c_plus_plus (6)
Introduction to c_plus_plus (6)Sayed Ahmed
 
Introduction to c_plus_plus
Introduction to c_plus_plusIntroduction to c_plus_plus
Introduction to c_plus_plusSayed Ahmed
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it worksDmitriy Dumanskiy
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaChris Bailey
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...Chetan Khatri
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvmPrem Kuppumani
 
Real-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingDatabricks
 
Xml processing-by-asfak
Xml processing-by-asfakXml processing-by-asfak
Xml processing-by-asfakAsfak Mahamud
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
No more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in productionNo more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in productionChetan Khatri
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotVolha Banadyseva
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 

Semelhante a Sperasoft‬ talks j point 2015 (20)

JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
Introduction to c_plus_plus (6)
Introduction to c_plus_plus (6)Introduction to c_plus_plus (6)
Introduction to c_plus_plus (6)
 
Introduction to c_plus_plus
Introduction to c_plus_plusIntroduction to c_plus_plus
Introduction to c_plus_plus
 
Modern C++
Modern C++Modern C++
Modern C++
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it works
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient Java
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
15 Jo P Mar 08
15 Jo P Mar 0815 Jo P Mar 08
15 Jo P Mar 08
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Introduction to c part -3
 
jvm goes to big data
jvm goes to big datajvm goes to big data
jvm goes to big data
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
Real-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to Streaming
 
Xml processing-by-asfak
Xml processing-by-asfakXml processing-by-asfak
Xml processing-by-asfak
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
No more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in productionNo more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in production
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
C language
C languageC language
C language
 
C language
C languageC language
C language
 

Mais de Sperasoft

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4Sperasoft
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted WorldSperasoft
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Sperasoft
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Sperasoft
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay TagsSperasoft
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Sperasoft
 
Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Sperasoft
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databasesSperasoft
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen FrameworkSperasoft
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective МeetingsSperasoft
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 IntroductionSperasoft
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA DevelopmentSperasoft
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchSperasoft
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSSperasoft
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into KanbanSperasoft
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 ReviewSperasoft
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutesSperasoft
 
Database Indexes
Database IndexesDatabase Indexes
Database IndexesSperasoft
 

Mais de Sperasoft (20)

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted World
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay Tags
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4
 
Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databases
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen Framework
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security Threats
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective Мeetings
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA Development
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JS
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into Kanban
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutes
 
Database Indexes
Database IndexesDatabase Indexes
Database Indexes
 

Último

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Sperasoft‬ talks j point 2015

  • 2.  Memory leaks profiling basics  Some notes about java.lang.String class  What technical debt is. How to measure it and how to sell.  Regular expressions under hood  Conclusion Agenda
  • 4. Different regions of memory Default sizes java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal –version Non-default sizes -Xmx2g -Xms2g -XX:MaxPermSize=128m -XX:MaxPermSize=128m Garbage Collector JVM subsystem responsible for object allocation and removing OutOfMemoryError JVM and Memory
  • 5. Unused object - object with no reference on it References: From an object to the value of one of its instance fields From an array to one of its elements From an object to its class From a class to its class loader From a class to the value of one of its static fields From a class to its superclass GC roots - special objects, always considered to be alive Reachability Memory Leaks: Unused Objects
  • 6. Memory Leaks Caches without look-ups and eviction Immortal threads Unclosed IO streams String.substring() NOT Memory Leaks Too high allocation rate Cache with wrong size Trying to load too much data at once Fat data structures Memory Leaks: Examples
  • 8. Binary representation of objects graph written to a file One of the best ways to find out what consumes memory Getting memory dump: jmap -dump:format=b,file=heap.hprof (!) Stop The World, 1 Thread, 4Gb ~4 sec -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./java_pid<pid>.hprof Get as late as possible Memory dump analyze tool: MAT Memory Leaks: Memory Dump
  • 9. Shallow – size of the object itself with headers and fields but without fields values Deep – size of the object itself with headers, fields and fields values Retained – the sub-graph size that will be unreached if we remove the object Memory Leaks: Object Size
  • 12. Immutable 25% of objects are java.lang.String String concat vs StringBuilder (3250 op/sec vs 125000 op/sec) -XX:±OptimizeStringConcat String OFFSET SIZE TYPE DESCRIPTION 0 12 object header 12 4 char[] value 16 4 int hash 20 4 alligmeent loss
  • 13. (“” + x) is faster then Integer.toString(x) (!) -XX:+OptimizeStringConcat with side effects optimization is not working string in JDK8 have no seek and count properties do not use .intern() method as cache StringTable is overflowed and can not be resized -XX :+ PrintStringTableStatistics equals implementation is intrinsic function (chose by compiler) -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=::_equals String: Notes
  • 14. String: HashCode Example String str1 , str2 ; public void setup () { str1 = “superinstrument␣neglected"; // same length str2 = " neglected␣ superinstrument "; // same length } int test1 () { return str1 . hashCode (); } int test2 () { return str2 . hashCode (); }
  • 15. Uses polynomial function Collisions (the same result for different values) String: HashCode public int hashCode () { int h = hash ; if (h == 0) { for ( char v : value ) { h = 31 * h + v; } hash = h; } return h; }
  • 16. String: Regexp String text = “Funny␣girl␣danced␣fell␣hurt␣and␣cried␣aloud."; String textDup = text.replaceAll ("␣", "␣␣"); Pattern pattern = Pattern.compile ("␣␣"); String [] charSplit () { return text.split ("␣"); } //191.6 ns/op String [] strSplit () { return textDup.split ("␣␣"); } //527.9 ns/op String [] strSplit_pattern () { return pattern.split(textDup); } //416.2 ns/op charSplit: fast path for 1 byte symbols strSplit: internally creates Pattern strSplit_pattern: reuse Pattern
  • 18. Try to not create a technical debt Code review Precision estimates Bus factor (save information) Try to measure the date your application will start suffer from this debt Collect metrics as much as possible Try to build trend Fishy code Technical Debt
  • 19. Include small refactoring in estimates Formal code quality metrics (clear for you, not so clear for customer) Developers group motivation (to not lose) Technical Debt: Selling
  • 21. Backtrack /^.*ab$/ matches “ab” /^.*?b$/ matches “aab” can took 30 sec in 100Kb text Pattern.compile("(Joker|JPoint)+") String "JokerJPoint…700 times…Joker“ will cause StackOverflowError Solutions: Pattern.compile("(Joker|JPoint)++") – possessive Pattern.compile("(?>Joker|JPoint)+") – forget back-reference Regular Expressions: Backtrack
  • 22. Regular Expressions: Impl TITLE RELEASED ALGORITHM java.util.regex.Pattern 2015 Backtrack com.basistech.tclre 2015 DFA org.jruby.joni (Nashorn) 2014 Backtrack Apache Oro 2000 Backtrack JRegex 2013 backtrack Deterministic automa Non-deterministic automa
  • 24. Regular Expressions: Tradeoff Java pattern Non-deterministic response time Managed backtrack Low memory usage TCL DFA algorithm with deterministic response time High memory usage