Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
7844395b
Commit
7844395b
authored
4 years ago
by
Sören Henning
Browse files
Options
Downloads
Patches
Plain Diff
Use summed lag instead of just for input topic
parent
2d7c11d9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
execution/lag_analysis.py
+26
-0
26 additions, 0 deletions
execution/lag_analysis.py
execution/scalability-graph.ipynb
+30
-31
30 additions, 31 deletions
execution/scalability-graph.ipynb
with
56 additions
and
31 deletions
execution/lag_analysis.py
+
26
−
0
View file @
7844395b
...
@@ -50,6 +50,8 @@ for result in results:
...
@@ -50,6 +50,8 @@ for result in results:
df
=
pd
.
DataFrame
(
d
)
df
=
pd
.
DataFrame
(
d
)
# Do some analysis
input
=
df
.
loc
[
df
[
'
topic
'
]
==
"
input
"
]
input
=
df
.
loc
[
df
[
'
topic
'
]
==
"
input
"
]
#input.plot(kind='line',x='timestamp',y='value',color='red')
#input.plot(kind='line',x='timestamp',y='value',color='red')
...
@@ -83,6 +85,30 @@ plt.savefig(f"{filename}_plot.png")
...
@@ -83,6 +85,30 @@ plt.savefig(f"{filename}_plot.png")
df
.
to_csv
(
f
"
{
filename
}
_values.csv
"
)
df
.
to_csv
(
f
"
{
filename
}
_values.csv
"
)
# Load total lag count
response
=
requests
.
get
(
'
http://kube1.se.internal:32529/api/v1/query_range
'
,
params
=
{
'
query
'
:
"
sum by(group)(kafka_consumergroup_group_lag > 0)
"
,
'
start
'
:
start
.
isoformat
(),
'
end
'
:
end
.
isoformat
(),
'
step
'
:
'
5s
'
})
results
=
response
.
json
()[
'
data
'
][
'
result
'
]
d
=
[]
for
result
in
results
:
#print(result['metric']['topic'])
group
=
result
[
'
metric
'
][
'
group
'
]
for
value
in
result
[
'
values
'
]:
#print(value)
d
.
append
({
'
group
'
:
group
,
'
timestamp
'
:
int
(
value
[
0
]),
'
value
'
:
int
(
value
[
1
])
if
value
[
1
]
!=
'
NaN
'
else
0
})
df
=
pd
.
DataFrame
(
d
)
df
.
to_csv
(
f
"
{
filename
}
_totallag.csv
"
)
# Load partition count
# Load partition count
response
=
requests
.
get
(
'
http://kube1.se.internal:32529/api/v1/query_range
'
,
params
=
{
response
=
requests
.
get
(
'
http://kube1.se.internal:32529/api/v1/query_range
'
,
params
=
{
...
...
This diff is collapsed.
Click to expand it.
execution/scalability-graph.ipynb
+
30
−
31
View file @
7844395b
{
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {
"language_info": {
"name": "python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"version": "3.7.0-final"
},
"orig_nbformat": 2,
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3,
"kernelspec": {
"name": "python37064bitvenvvenv469ea2e0a7854dc7b367eee45386afee",
"display_name": "Python 3.7.0 64-bit ('.venv': venv)"
}
},
"cells": [
"cells": [
{
{
"cell_type": "code",
"cell_type": "code",
...
@@ -61,10 +38,9 @@
...
@@ -61,10 +38,9 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"exp_id =
35
\n",
"exp_id =
159
\n",
"warmup_sec = 60\n",
"warmup_sec = 60\n",
"threshold = 2000 #slope\n",
"threshold = 2000 #slope\n"
""
]
]
},
},
{
{
...
@@ -84,7 +60,7 @@
...
@@ -84,7 +60,7 @@
"\n",
"\n",
"raw_runs = []\n",
"raw_runs = []\n",
"\n",
"\n",
"filenames = [filename for filename in os.listdir('.') if filename.startswith(f\"exp{exp_id}\") and filename.endswith(\".csv\")]\n",
"filenames = [filename for filename in os.listdir('.') if filename.startswith(f\"exp{exp_id}\") and filename.endswith(\"
totallag
.csv\")]\n",
"for filename in filenames:\n",
"for filename in filenames:\n",
" #print(filename)\n",
" #print(filename)\n",
" run_params = filename[:-4].split(\"_\")\n",
" run_params = filename[:-4].split(\"_\")\n",
...
@@ -92,7 +68,8 @@
...
@@ -92,7 +68,8 @@
" instances = run_params[3]\n",
" instances = run_params[3]\n",
"\n",
"\n",
" df = pd.read_csv(filename)\n",
" df = pd.read_csv(filename)\n",
" input = df.loc[df['topic'] == \"input\"]\n",
" #input = df.loc[df['topic'] == \"input\"]\n",
" input = df\n",
" #print(input)\n",
" #print(input)\n",
" input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']\n",
" input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']\n",
" #print(input)\n",
" #print(input)\n",
...
@@ -116,8 +93,7 @@
...
@@ -116,8 +93,7 @@
" #print(row)\n",
" #print(row)\n",
" raw_runs.append(row)\n",
" raw_runs.append(row)\n",
"\n",
"\n",
"runs = pd.DataFrame(raw_runs)\n",
"runs = pd.DataFrame(raw_runs)\n"
""
]
]
},
},
{
{
...
@@ -176,5 +152,28 @@
...
@@ -176,5 +152,28 @@
"outputs": [],
"outputs": [],
"source": []
"source": []
}
}
]
],
"metadata": {
"language_info": {
"name": "python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"version": "3.7.0-final"
},
"orig_nbformat": 2,
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3,
"kernelspec": {
"name": "python37064bitvenvvenv469ea2e0a7854dc7b367eee45386afee",
"display_name": "Python 3.7.0 64-bit ('.venv': venv)"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
\ No newline at end of file
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
print("hello")
print("hello")
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
import os
import os
import requests
import requests
from datetime import datetime, timedelta, timezone
from datetime import datetime, timedelta, timezone
import pandas as pd
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
os.getcwd()
os.getcwd()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
exp_id =
35
exp_id =
159
warmup_sec = 60
warmup_sec = 60
threshold = 2000 #slope
threshold = 2000 #slope
```
```
%% Cell type:code id: tags:outputPrepend,outputPrepend
%% Cell type:code id: tags:outputPrepend,outputPrepend
```
```
#exp_id = 35
#exp_id = 35
#os.chdir("./results-new")
#os.chdir("./results-new")
raw_runs = []
raw_runs = []
filenames = [filename for filename in os.listdir('.') if filename.startswith(f"exp{exp_id}") and filename.endswith(".csv")]
filenames = [filename for filename in os.listdir('.') if filename.startswith(f"exp{exp_id}") and filename.endswith("
totallag
.csv")]
for filename in filenames:
for filename in filenames:
#print(filename)
#print(filename)
run_params = filename[:-4].split("_")
run_params = filename[:-4].split("_")
dim_value = run_params[2]
dim_value = run_params[2]
instances = run_params[3]
instances = run_params[3]
df = pd.read_csv(filename)
df = pd.read_csv(filename)
input = df.loc[df['topic'] == "input"]
#input = df.loc[df['topic'] == "input"]
input = df
#print(input)
#print(input)
input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']
input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']
#print(input)
#print(input)
#print(input.iloc[0, 'timestamp'])
#print(input.iloc[0, 'timestamp'])
regress = input.loc[input['sec_start'] >= warmup_sec] # Warm-Up
regress = input.loc[input['sec_start'] >= warmup_sec] # Warm-Up
#regress = input
#regress = input
#input.plot(kind='line',x='timestamp',y='value',color='red')
#input.plot(kind='line',x='timestamp',y='value',color='red')
#plt.show()
#plt.show()
X = regress.iloc[:, 2].values.reshape(-1, 1) # values converts it into a numpy array
X = regress.iloc[:, 2].values.reshape(-1, 1) # values converts it into a numpy array
Y = regress.iloc[:, 3].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column
Y = regress.iloc[:, 3].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column
linear_regressor = LinearRegression() # create object for the class
linear_regressor = LinearRegression() # create object for the class
linear_regressor.fit(X, Y) # perform linear regression
linear_regressor.fit(X, Y) # perform linear regression
Y_pred = linear_regressor.predict(X) # make predictions
Y_pred = linear_regressor.predict(X) # make predictions
trend_slope = linear_regressor.coef_[0][0]
trend_slope = linear_regressor.coef_[0][0]
#print(linear_regressor.coef_)
#print(linear_regressor.coef_)
row = {'dim_value': int(dim_value), 'instances': int(instances), 'trend_slope': trend_slope}
row = {'dim_value': int(dim_value), 'instances': int(instances), 'trend_slope': trend_slope}
#print(row)
#print(row)
raw_runs.append(row)
raw_runs.append(row)
runs = pd.DataFrame(raw_runs)
runs = pd.DataFrame(raw_runs)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
runs.head()
runs.head()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
#threshold = 1000
#threshold = 1000
# Set to true if the trend line has a slope less than
# Set to true if the trend line has a slope less than
runs["suitable"] = runs.apply(lambda row: row['trend_slope'] < threshold, axis=1)
runs["suitable"] = runs.apply(lambda row: row['trend_slope'] < threshold, axis=1)
runs.columns = runs.columns.str.strip()
runs.columns = runs.columns.str.strip()
runs.sort_values(by=["dim_value", "instances"])
runs.sort_values(by=["dim_value", "instances"])
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
filtered = runs[runs.apply(lambda x: x['suitable'], axis=1)]
filtered = runs[runs.apply(lambda x: x['suitable'], axis=1)]
grouped = filtered.groupby(['dim_value'])['instances'].min()
grouped = filtered.groupby(['dim_value'])['instances'].min()
min_suitable_instances = grouped.to_frame().reset_index()
min_suitable_instances = grouped.to_frame().reset_index()
min_suitable_instances
min_suitable_instances
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
min_suitable_instances.plot(kind='line',x='dim_value',y='instances')
min_suitable_instances.plot(kind='line',x='dim_value',y='instances')
plt.show()
plt.show()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment