SlideShare a Scribd company logo
1 of 10
High-Performance Java



          Bill La Forge
  CTO, Jactor Consulting
 http://jactorconsulting.com
High-Performance Java
●   When is it needed?
●   Development Methodology
●   High-Performance Considerations
When is it Needed?
●   Most Java code is fast enough for its intended
    use.
●   When optimization is needed, it is usually best
    done after the code is debugged.
●   But when the utility of the code is directly linked
    to its performance, the development of high-
    performance code can sometimes justify the
    expense of its development.
Development Methodology
●   A test-centric approach is needed to identify
    non-performant code early in the development
    cycle.
●   Performance testing is needed in both unit
    testing and system testing.
●   For critical sections of code it is sometimes
    better to duplicate code instead of subclassing.
    But a small memory footprint may be more
    important. Finding the most performant
    compromises requires performance testing.
High-Performance
                  Considerations
●   Algorithms
●   JIT
●   Garbage Collection
●   Multi-Threading
●   Memory Architecture
Algorithms
●   There is no best algorithm or best data
    structure, only best fit for a specific context.
●   Algorithms which fit in high-speed cache may
    perform better than expected.
●   Array backed data structures shared across
    threads may work better than linked data
    structures.
●   Critical performance considerations are often
    opaque, with performance testing the only
    recourse.
JIT
●   Methods with bytecode longer than 60 bytes
    are NOT optimized, so adding a line of code to
    a method will sometimes result in a dramatic
    loss of speed.
●   Use final classes and final methods where
    possible. Consider code duplication in place of
    subclassing for critical sections.
●   Performance tests should exercise code heavily
    before doing any timings to ensure that the JIT
    has compiled the bytecode under test.
Garbage Collection
●   Garbage collection is a common cause for non-
    performant code.
●   Minimize object creation within loops.
●   Minimize the number of references an object
    has to other objects.
●   Avoid circular structures as much as possible.
●   Clear references to objects as soon as
    possible.
Multi-Threading
●   In general, using a single thread is orders of
    magnitude faster than using multiple threads,
    as passing data between threads is
    comparitively slow.
●   When there is justification for passing data
    between threads, pass as much a possible
    each time. For example, use a pipeline where
    backpressure from the next stage is used to
    control the amount of data being passed.
●   When passing data between threads, flow
    control is critical for good overall performance.
Memory Architecture
●   When using a thread pool, remember that the code
    and the data will need to be loaded into the CPU's
    local cache, making for a slow start when a thread is
    allocated a task. And having more CPUs only makes
    this worse.
●   Linked data structures make for frequent cache
    misses, which is why table-backed sturctures are often
    faster.
●   Sharing data blocks between threads, especially when
    more than one thread does the updates, will slow
    things down—even if the same data within a block is
    not being shared.

More Related Content

Viewers also liked

SSO with the WSO2 Identity Server
SSO with the WSO2 Identity ServerSSO with the WSO2 Identity Server
SSO with the WSO2 Identity Server
WSO2
 
High-performance Team Development
High-performance Team DevelopmentHigh-performance Team Development
High-performance Team Development
Peter Pfeiffer
 
SAML / OpenID Connect / OAuth / SCIM 技術解説 - ID&IT 2014 #idit2014
SAML / OpenID Connect / OAuth / SCIM 技術解説  - ID&IT 2014 #idit2014SAML / OpenID Connect / OAuth / SCIM 技術解説  - ID&IT 2014 #idit2014
SAML / OpenID Connect / OAuth / SCIM 技術解説 - ID&IT 2014 #idit2014
Nov Matake
 

Viewers also liked (19)

WSO2 Identity Server
WSO2 Identity ServerWSO2 Identity Server
WSO2 Identity Server
 
Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 
High performance java ee with j cache and cdi
High performance java ee with j cache and cdiHigh performance java ee with j cache and cdi
High performance java ee with j cache and cdi
 
SSO with the WSO2 Identity Server
SSO with the WSO2 Identity ServerSSO with the WSO2 Identity Server
SSO with the WSO2 Identity Server
 
Practical Steps For Building High Performance Teams
Practical Steps For Building High Performance TeamsPractical Steps For Building High Performance Teams
Practical Steps For Building High Performance Teams
 
High-performance Team Development
High-performance Team DevelopmentHigh-performance Team Development
High-performance Team Development
 
Leading High Performance Teams
Leading High Performance TeamsLeading High Performance Teams
Leading High Performance Teams
 
WSO2 Identity Server 5.3.0 - Product Release Webinar
WSO2 Identity Server 5.3.0 - Product Release WebinarWSO2 Identity Server 5.3.0 - Product Release Webinar
WSO2 Identity Server 5.3.0 - Product Release Webinar
 
High Performance Java EE with JCache and CDI
High Performance Java EE with JCache and CDIHigh Performance Java EE with JCache and CDI
High Performance Java EE with JCache and CDI
 
SAML Smackdown
SAML SmackdownSAML Smackdown
SAML Smackdown
 
High Performance Flow Matching Architecture for Openflow Data Plane
High Performance Flow Matching Architecture for Openflow Data PlaneHigh Performance Flow Matching Architecture for Openflow Data Plane
High Performance Flow Matching Architecture for Openflow Data Plane
 
SAML Protocol Overview
SAML Protocol OverviewSAML Protocol Overview
SAML Protocol Overview
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
 
Introduction to SAML
Introduction to SAMLIntroduction to SAML
Introduction to SAML
 
SAML / OpenID Connect / OAuth / SCIM 技術解説 - ID&IT 2014 #idit2014
SAML / OpenID Connect / OAuth / SCIM 技術解説  - ID&IT 2014 #idit2014SAML / OpenID Connect / OAuth / SCIM 技術解説  - ID&IT 2014 #idit2014
SAML / OpenID Connect / OAuth / SCIM 技術解説 - ID&IT 2014 #idit2014
 
15 Years of Web Security: The Rebellious Teenage Years
15 Years of Web Security: The Rebellious Teenage Years15 Years of Web Security: The Rebellious Teenage Years
15 Years of Web Security: The Rebellious Teenage Years
 
IdP, SAML, OAuth
IdP, SAML, OAuthIdP, SAML, OAuth
IdP, SAML, OAuth
 
Java Performance: Speedup your application with hardware counters
Java Performance: Speedup your application with hardware countersJava Performance: Speedup your application with hardware counters
Java Performance: Speedup your application with hardware counters
 

More from Bill La Forge (6)

JA Brocure v3
JA Brocure v3JA Brocure v3
JA Brocure v3
 
Jactor for Dummies
Jactor for DummiesJactor for Dummies
Jactor for Dummies
 
JActor Cluster Platform
JActor Cluster PlatformJActor Cluster Platform
JActor Cluster Platform
 
Incremental Java Deserialization/Reserialization
Incremental Java Deserialization/ReserializationIncremental Java Deserialization/Reserialization
Incremental Java Deserialization/Reserialization
 
Code Samples
Code SamplesCode Samples
Code Samples
 
Actors in the Small
Actors in the SmallActors in the Small
Actors in the Small
 

Recently uploaded

Recently uploaded (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 ..
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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 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...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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...
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

High performance-java

  • 1. High-Performance Java Bill La Forge CTO, Jactor Consulting http://jactorconsulting.com
  • 2. High-Performance Java ● When is it needed? ● Development Methodology ● High-Performance Considerations
  • 3. When is it Needed? ● Most Java code is fast enough for its intended use. ● When optimization is needed, it is usually best done after the code is debugged. ● But when the utility of the code is directly linked to its performance, the development of high- performance code can sometimes justify the expense of its development.
  • 4. Development Methodology ● A test-centric approach is needed to identify non-performant code early in the development cycle. ● Performance testing is needed in both unit testing and system testing. ● For critical sections of code it is sometimes better to duplicate code instead of subclassing. But a small memory footprint may be more important. Finding the most performant compromises requires performance testing.
  • 5. High-Performance Considerations ● Algorithms ● JIT ● Garbage Collection ● Multi-Threading ● Memory Architecture
  • 6. Algorithms ● There is no best algorithm or best data structure, only best fit for a specific context. ● Algorithms which fit in high-speed cache may perform better than expected. ● Array backed data structures shared across threads may work better than linked data structures. ● Critical performance considerations are often opaque, with performance testing the only recourse.
  • 7. JIT ● Methods with bytecode longer than 60 bytes are NOT optimized, so adding a line of code to a method will sometimes result in a dramatic loss of speed. ● Use final classes and final methods where possible. Consider code duplication in place of subclassing for critical sections. ● Performance tests should exercise code heavily before doing any timings to ensure that the JIT has compiled the bytecode under test.
  • 8. Garbage Collection ● Garbage collection is a common cause for non- performant code. ● Minimize object creation within loops. ● Minimize the number of references an object has to other objects. ● Avoid circular structures as much as possible. ● Clear references to objects as soon as possible.
  • 9. Multi-Threading ● In general, using a single thread is orders of magnitude faster than using multiple threads, as passing data between threads is comparitively slow. ● When there is justification for passing data between threads, pass as much a possible each time. For example, use a pipeline where backpressure from the next stage is used to control the amount of data being passed. ● When passing data between threads, flow control is critical for good overall performance.
  • 10. Memory Architecture ● When using a thread pool, remember that the code and the data will need to be loaded into the CPU's local cache, making for a slow start when a thread is allocated a task. And having more CPUs only makes this worse. ● Linked data structures make for frequent cache misses, which is why table-backed sturctures are often faster. ● Sharing data blocks between threads, especially when more than one thread does the updates, will slow things down—even if the same data within a block is not being shared.