Professional Documents
Culture Documents
Performance Issue - Machine Learning To The Rescue Maarten Smeets
Performance Issue - Machine Learning To The Rescue Maarten Smeets
Performance Issue - Machine Learning To The Rescue Maarten Smeets
Machine Learning
to the Rescue!
Agenda
• Introduction
• Measuring performance
• What is performance?
• How is traditional tuning done?
• Now for something completely different!
• Results
• Checking the results
• Verifying the model
2
About me
• Several certifications
SOA, BPM, MCS, Java, SQL, PL/SQL,
Mule, AWS, etc
• Enthusiastic blogger
http://javaoraclesoa.blogspot.com
https://nl.linkedin.com/in/smeetsm
@MaartenSmeetsNL
3
What is performance?
• Better performance indicates more work can be done using less resources or time
• What is work?
• Starting an application
• Time required to process a single request (response times)
• Number of requests which can be processed during a certain period (throughput)
• Which resources?
• CPU / cores
• Memory
• Disk
• Compare it to a baseline
• If it’s good, keep it, else revert Add a bit of Machine Learning Wouldn’t it help if you could more
accurately determine the variable to
manipulate before starting a trial and
• Try another variable error process?
5
What do you need
to let the Machine augment ‘informed judgement’
• Lots of performance data! • A model to process the data
• Different kinds of ‘work’ • Understands the structure of the data
• response times • Is suitable for my data
• throughput • Can tell me which variables are important
Framework
Throughput
Requests per second
Memory JVM
(8,11,12,13)
Cores
Response time
Concurrency Garbage Collection
7
How does the data look?
8
How did I measure?
Summarize results
Bash (awk, sed, curl), Python, Apache Bench
Visualize results
Python / Jupyter: pandas, numpy, pyplot
9
Challenges measuring
User processes
Load generators
JVM process
1 2 3
10
Challenges generating load
• No more containers
Effects of containers are slower startup and Docker NAT overhead
No more need to create and clean up containers -> simpler code
12
Disclaimer
The performance tests mentioned in this presentation were conducted with intention to obtain
information on which variables have most effect for performance. A best effort has been made to
conduct an unbiased test. Still, performance depends on many parameters such as hardware,
specifics of the implementation, the usage of different back-ends, concurrency, versions of libraries,
OS, virtualization and various other factors. Also performance can be measured in many different
ways. I cannot provide any guarantees that the same variables are important in other situations or
that my selection of variables to look at is suitable for other environments. The use of these results is
at your own risk. I shall in no case accept liability for any loss resulting from the use of the results or
decisions based on them.
14
Results
Framework and JVM
Average response time [ms]
15
Results
Garbage Collection Algorithm
Average response time [ms]
16
Results response time
How do frameworks deal with more CPUs?
17
Results throughput
How do frameworks deal with more CPUs?
18
Some general observations
• Docker has overhead
• Network (Docker NAT). Even between containers
• Startup times (due to loading of shared libraries and inability to use certain caching features).
• GraalVMs native compilation is worthwhile, especially when you pay for resources
• Reduced container size, memory usage, startup time
• Increased response times and throughput
• JVMs
• OpenJ9 has the best startup time outside a container and works best at low memory
• Oracle JDK and OpenJDK do not differ much
19
Lots of data
20
What are the most important variables
determining my performance?
And which are the variables I can (more or less) safely ignore
21
Can Machine Learning solve this for me?
22
Machine Learning
23
Machine Learning challenges
• Prediction error
• Bias
• Variance
24
Prediction error
Total error
Reducible error
25
Bias and variance
• Bias error
• How far is the predicted value from the true value
• The systematic error of the model
• It is about the model and the data itself
• Variance error
• The error caused by sensitivity to
small variances in the training data set
• The dispersion of predicted values
over target values with different train-sets
• It is about the model sensitivity
https://community.alteryx.com/t5/Data-Science-Blog/Bias-Versus-Variance/ba-p/351862
26
Overfitting and underfitting
https://community.alteryx.com/t5/Data-Science-Blog/Bias-Versus-Variance/ba-p/351862
27
The bias variance curse
a property of supervised machine learning models
28
Model selection
• Is it easy to use?
• Flexible
• Can be used with many variables
• Can be used for classification but also for regression
• Easy
200 trees
Create a model to predict ytrain based on Xtrain
Use the model to do predictions based on Xtest
• Feature Importance!
30
Introduction Random Forest
31
How is a Random Forest created?
https://victorzhou.com/blog/intro-to-random-forests/
32
For an individual Decision Tree
• Find in the first branch for that part of the data again the best split.
That is the first sub node (decision node)
• Continue creating decision nodes until splitting doesn’t improve the situation
The average value of the target variable is assigned to the leaf (terminal node)
• Continue until there are only leaf nodes left or until a minimum value is reached
• Now the decision tree can be used to do a prediction based on the input features
33
Determine the best split
34
Processing the ensemble of trees called
The Random Forest
• Take a set of variables
• Run them through every decision tree
• Determine a predicted target variable for each of the trees
• Average the result of all trees
35
How to evaluate the model?
36
Back to the data
37
Coefficient of determination R^2 = 0.99 for both graphs
and for train and test sets
Model accuracy
the proportion of the variance in the measurements
that is predictable by the different features using the model
Akka on OpenJ9
38
A Random Forest has a cool feature
39
Feature Importance
• However
• the variable importance measures are not reliable in situations where potential predictor variables
vary in their scale of measurement or their number of categories
40
Results response time
41
Results throughput
42
Feature Importance
• However
• the variable importance measures are not reliable in situations where potential predictor variables
vary in their scale of measurement or their number of categories
43
Permutation Feature Importance
• Shuffle values from one feature in the selected dataset (keep the same variance)
• Pass the dataset to the model again to obtain predictions and calculate the accuracy. The
feature importance is the difference between the benchmark score and the one from the
modified (permuted) dataset.
44
Permutation Feature Importance
47
Finally
• The model has been created based on the supplied variables and data
• I had to make choices and scope the test due to time limitations.
• Many more variables can be relevant!
• How accurate are predictions outside the scope of measurements?
• Performance
• is a great use case for machine learning (e.g. data with patterns, optimization challenges)
• a fresh look by a machine can help us be more efficient in our tuning efforts
48
49