Commit f660c202 authored by Oliver Kennedy's avatar Oliver Kennedy

Merge branch 'master' of gitlab.odin.cse.buffalo.edu:sqlite-benchmark/core

parents 036f9bbf 4e77f4bb
......@@ -160,7 +160,7 @@ task :loadStats do
attr_name1, attr_name2, attr_value = $1.to_i, $2.to_i, $3.to_f
field_value[attr_name1] = Hash.new unless field_value.has_key? attr_name1;
field_value[attr_name1][attr_name2] = attr_value
when / +\| *([^ ]+) +-> *([^ ]+)/
when / +\| *(.+) +-> *([^ ]+)/
attr_name, attr_value = $1, $2.to_f
field_value[attr_name] = attr_value
when / +\| *class ([^ ]+) +-> *([^ ]+)/
......@@ -180,7 +180,7 @@ end
["SELECT", "DELETE", "UPDATE"].each do |segment|
plot "graphs/#{segment.downcase}_breakdown_by_width" => :loadStats do |graph|
pretty_plot(graph, logy: true, fontsize: 13)
pretty_plot(graph, logy: true, fontsize: 13, border: [:all], bordercolor: 'rgb "#000000"')
graph.yrange '[0.1:100000000]'
......@@ -192,11 +192,34 @@ plot "graphs/#{segment.downcase}_breakdown_by_width" => :loadStats do |graph|
sort { |a,b| a[0] <=> b[0] }.
unzip
draw_bar_plot(graph, data: qcounts, labels: counts, box_style: lambda { |i| "boxes fill solid lc rgb \"#A00000\""})
draw_bar_plot(graph,
data: qcounts,
labels: counts,
box_style: lambda { |i| "boxes fill solid lc rgb \"#A00000\""},
bar_width: 15
)
end
task :graphs => "graphs/#{segment.downcase}_breakdown_by_width"
end
plot "graphs/update_target_cols" => :loadStats do |graph|
pretty_plot(graph, logy: true, sizex: 8, fontsize: 13, border: [:all], bordercolor: 'rgb "#000000"', gridcolor: 'rgb "#000000"')
graph.xlabel 'Number of Columns Updated'
graph.ylabel 'Number of UPDATE Statements'
graph.format 'y "%1.1f'
counts, qcounts =
$stats["UPDATE"]["Update Target Columns"].to_a.
sort { |a,b| a[0] <=> b[0] }.
unzip
draw_bar_plot(graph, data: qcounts, labels: counts, box_style: lambda { |i| "boxes fill solid lc rgb \"#A00000\""})
end
task :graphs => "graphs/update_target_cols"
plot "graphs/spj_breakdown_by_width" => :loadStats do |graph|
pretty_plot(graph, :logy => true)
......@@ -219,7 +242,7 @@ task :graphs => "graphs/spj_breakdown_by_width"
["SELECT", "UPDATE"].each do |segment|
plot "graphs/#{segment.downcase}_breakdown_by_nesting" => :loadStats do |graph|
pretty_plot(graph, logy: true, fontsize: 13)
pretty_plot(graph, logy: true, fontsize: 13, border: [:all], bordercolor: 'rgb "#000000"')
graph.yrange '[1:100000000]'
......@@ -232,12 +255,173 @@ plot "graphs/#{segment.downcase}_breakdown_by_nesting" => :loadStats do |graph|
unzip
draw_bar_plot(graph, data: qcounts, labels: counts, box_style: lambda { |i| "boxes fill solid lc rgb \"#A00000\""})
draw_bar_plot(graph,
data: qcounts,
labels: counts,
box_style: lambda { |i| "boxes fill solid lc rgb \"#A00000\""},
bar_width: 15
)
end
task :graphs => "graphs/#{segment.downcase}_breakdown_by_nesting"
end
line_plot "graphs/select_count_cdf_by_app" => :loadStats do |graph|
pretty_plot(graph, logx: true, fontsize: 12, border: [:all], bordercolor: 'rgb "#000000"')
graph.key 'off'
graph.grid 'front'
graph.unset 'grid'
graph.format 'x "10^%T"'
graph.format 'y "%1.1f'
# puts "#{$stats["SELECT"]["Select queries by app"]["???"].to_i} queries (#{($stats["SELECT"]["Select queries by app"]["???"].to_f / $stats["SELECT"]["Total Queries"].to_f * 100).round(2)}%) can not be associated with an app"
graph.ylabel "CDF"
graph.xlabel "Number of SELECT Queries Issued"
{
:data =>
$stats["SELECT"]["Query Counts by App"].
to_a.
delete_if { |name,cnt| name == "???" }.
sort { |a,b| a[1] <=> b[1] }.
map { |name, cnt| cnt.to_i }.
cdf,
:with => [ "lines lc 'blue' lw 1.5" ]
}
end
task :graphs => "graphs/select_count_cdf_by_app"
line_plot "graphs/select_percent_simple_cdf_by_app" => :loadStats do |graph|
pretty_plot(graph, logy: false, fontsize: 12, border: [:all], bordercolor: 'rgb "#000000"')
graph.key 'off'
graph.grid 'front'
graph.unset 'grid'
graph.format 'x "%g%%"'
graph.format 'y "%1.1f'
graph.ylabel "CDF"
graph.xlabel "% of SELECT Queries That Are Key-Value Queries"
simple = $stats["SELECT"]["Simple Select queries by app"]
all = $stats["SELECT"]["Query Counts by App"]
trivial_apps = all.keys.clone.delete_if { |k| all[k].to_i != simple[k].to_i }
puts "#{trivial_apps.size} out of #{all.size} apps (#{(trivial_apps.size.to_f / all.size.to_f * 100).round(2)}%) do not pose complex queries"
puts trivial_apps.sort.join(", ")
{
:data =>
all.to_a.
delete_if { |name,cnt| name == "???" }.
map { |name, cnt| (simple[name].to_f / cnt.to_f)*100 }.
sort.
cdf,
:with => [ "lines lc 'blue' lw 1.5" ]
}
end
task :graphs => "graphs/select_percent_simple_cdf_by_app"
line_plot "graphs/data_mod_ops_cdf_by_app" => :loadStats do |graph|
pretty_plot(graph, logx: true, fontsize: 12, border: [:all], bordercolor: 'rgb "#000000"')
graph.key 'off'
graph.grid 'front'
graph.unset 'grid'
graph.format 'x "10^%T"'
graph.format 'y "%1.1f'
graph.ylabel "CDF"
graph.xlabel "Number of Data Manipulation Statements"
# graph.yrange "[0.9:1]"
all = $stats["Global"]["Query Counts by App"]
select = $stats["SELECT"]["Query Counts by App"]
{
:data =>
all.keys.clone.
map { |k| all[k].to_i - select.fetch(k, 0).to_i unless k == "???" }.
compact.
sort.
cdf,
:with => [ "lines lc 'blue' lw 1.5" ]
}
end
task :graphs => "graphs/data_mod_ops_cdf_by_app"
line_plot "graphs/read_write_ratio_cdf_by_app" => :loadStats do |graph|
pretty_plot(graph, logy: false, fontsize: 12, border: [:all], bordercolor: 'rgb "#000000"')
graph.key 'off'
graph.grid 'front'
graph.unset 'grid'
graph.format 'x "%g%%"'
graph.format 'y "%1.1f'
graph.ylabel "CDF"
graph.xlabel "Read/Write Ratio (100% = All Reads)"
all = $stats["Global"]["Query Counts by App"]
select = $stats["SELECT"]["Query Counts by App"]
ratios =
all.keys.clone.
map { |k| [k, (select.fetch(k, 0).to_f / all[k].to_f) * 100] unless k == "???" }.
compact.
sort { |a,b| a[1] <=> b[1] }
{
:data => ratios.map { |k,ratio| ratio }.cdf,
:with => [ "lines lc 'blue' lw 1.5" ]
}
end
task :rw_stats => :loadStats do
all = $stats["Global"]["Query Counts by App"]
select = $stats["SELECT"]["Query Counts by App"]
ratios =
all.keys.clone.
map { |k| [k, (select.fetch(k, 0).to_f / all[k].to_f) * 100] unless k == "???" }.
compact.
sort { |a,b| a[1] <=> b[1] }
read_only_apps = ratios.map { |k, ratio| k if ratio >= 100.0 }.compact
puts "#{read_only_apps.length} read only apps (#{(read_only_apps.length.to_f / all.keys.length.to_f * 100).round(2)}%), performing #{read_only_apps.map { |k| all[k] }.sum.to_i} ops"
puts read_only_apps.sort.join(", ")
write_only_apps = ratios.map { |k, ratio| k if ratio <= 0.0 }.compact
puts "#{write_only_apps.length} write only apps (#{(write_only_apps.length.to_f / all.keys.length.to_f * 100).round(2)}%)"
puts write_only_apps.join(", ")
end
["Global", "SELECT"].each do |segment|
task "#{segment.downcase}_top" => :loadStats do
all = $stats[segment]["Query Counts by App"].to_a.clone.delete_if { |name, cnt| name == "???" }.sort { |a, b| b[1] <=> a[1] }
puts "---- TOP 10 ----"
puts all[0..10].map { |name,cnt| "#{name} (#{cnt.to_i})" }.join("\n")
puts "---- BOTTOM 10 ----"
puts all[-10..-1].map { |name,cnt| "#{name} (#{cnt.to_i})" }.join("\n")
end
task "#{segment.downcase}_top_all" => :loadStats do
all = $stats[segment]["Query Counts by App"].to_a.clone.delete_if { |name, cnt| name == "???" }.sort { |a, b| b[1] <=> a[1] }
all.each.with_index { |x, i| puts "#{i}: #{x[0]}"}
end
end
class Numeric
def to_delim_s(delim = ",")
to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1'+delim).reverse
......@@ -258,7 +442,9 @@ end
class LatexTableWriter
def initialize(schema, args = {})
@data = ""
line = args.fetch(:overline, true)
@box = args.fetch(:box, true)
line = args.fetch(:overline, @box)
@row_lines = args.fetch(:row_lines, true)
put("\\begin{tabular}{#{schema}}#{if line then "\\hline" else "" end}\n")
@firstcell = true;
end
......@@ -277,7 +463,7 @@ class LatexTableWriter
cell "\\multicolumn{#{cols}}{#{schema}}{#{data}}"
end
def endrow(line = true)
def endrow(line = @row_lines)
put "\\\\#{if line then "\\hline" else "" end}\n"
@firstcell = true;
end
......@@ -286,7 +472,7 @@ class LatexTableWriter
row.each { |d| cell(d) }
end
def row(row, line = true)
def row(row, line = @row_lines)
partial_row(row)
endrow(line)
end
......@@ -376,17 +562,17 @@ $condition_types =
"NOT-net.sf.jsqlparser.expression.operators.arithmetic.BitwiseAnd"
],
"Expr \\& Expr", "Bitwise AND"],
]
].map { |label, example, descriptor| [label, "\\texttt{#{example}}", descriptor]}
file "graphs/sp_trivial_condition_breakdown.tex" => :loadStats do
breakdown =
$stats["SELECT"]["SP[+Sort] With Lone Where Clause by Clause Type"]
table = LatexTableWriter.new("|c|c|c|");
table = LatexTableWriter.new("c|c|c", box: false, row_lines: false);
table.row [
latex_bold("Expression Type"),
latex_bold("Expression Form"),
latex_bold("Query Count")
]
latex_bold("Count")
], true
known_cols = $condition_types.map { |ks, e, d| ks }.flatten;
......@@ -406,16 +592,16 @@ file "graphs/sp_trivial_condition_breakdown.tex" => :loadStats do
end
task :tables => "graphs/sp_trivial_condition_breakdown.tex"
["SELECT", "DELETE"].each do |segment|
["SELECT", "DELETE", "UPDATE"].each do |segment|
file "graphs/#{segment.downcase}_condition_breakdown.tex" => :loadStats do
breakdown =
$stats[segment]["Query Counts by Use of Each Where Clause Type"]
table = LatexTableWriter.new("|c|c|c|");
table = LatexTableWriter.new("c|c|c", box: false, row_lines: false);
table.row [
latex_bold("Expression Type"),
latex_bold("Expression Form"),
latex_bold("Query Count")
]
latex_bold("Count")
], true
known_cols = $condition_types.map { |ks, e, d| ks }.flatten;
......
\begin{tabular}{|c|c|c|}\hline
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Query Count}\\\hline
Exact Lookups & Const $=$ Expr & \ \ 926,042\ \ \\\hline
Other Inequality & Expr $\theta$ Expr & \ \ 527,517\ \ \\\hline
Membership Test & Expr [NOT] IN (List or Query) & \ \ 190,695\ \ \\\hline
Disjunction & [NOT] Expr $\vee$ Expr & \ \ 48,534\ \ \\\hline
Inequality on 1 constant & Const $\theta$ Expr & \ \ 31,128\ \ \\\hline
Other Equality & Expr $=$ Expr & \ \ 10,037\ \ \\\hline
Subquery Membership & [NOT] EXISTS (Query) & \ \ 9,079\ \ \\\hline
Boolean Column Cast & [NOT] Column & \ \ 6,490\ \ \\\hline
Patterned String Lookup & Expr [NOT] LIKE Pattern & \ \ 6,109\ \ \\\hline
Validity Test & Expr IS [NOT] NULL & \ \ 2,693\ \ \\\hline
Functional If-Then-Else & CASE WHEN \ldots & \ \ 390\ \ \\\hline
No-op Clause & Const or (Const = Const) & \ \ 249\ \ \\\hline
Range Test & Expr BETWEEN Const AND Const & \ \ 18\ \ \\\hline
\begin{tabular}{c|c|c}
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Count}\\\hline
Exact Lookups & \texttt{Const $=$ Expr} & \ \ 926,042\ \ \\
Other Inequality & \texttt{Expr $\theta$ Expr} & \ \ 527,517\ \ \\
Membership Test & \texttt{Expr [NOT] IN (List or Query)} & \ \ 190,695\ \ \\
Disjunction & \texttt{[NOT] Expr $\vee$ Expr} & \ \ 48,534\ \ \\
Inequality on 1 constant & \texttt{Const $\theta$ Expr} & \ \ 31,128\ \ \\
Other Equality & \texttt{Expr $=$ Expr} & \ \ 10,037\ \ \\
Subquery Membership & \texttt{[NOT] EXISTS (Query)} & \ \ 9,079\ \ \\
Boolean Column Cast & \texttt{[NOT] Column} & \ \ 6,490\ \ \\
Patterned String Lookup & \texttt{Expr [NOT] LIKE Pattern} & \ \ 6,109\ \ \\
Validity Test & \texttt{Expr IS [NOT] NULL} & \ \ 2,693\ \ \\
Functional If-Then-Else & \texttt{CASE WHEN \ldots} & \ \ 390\ \ \\
No-op Clause & \texttt{Const or (Const = Const)} & \ \ 249\ \ \\
Range Test & \texttt{Expr BETWEEN Const AND Const} & \ \ 18\ \ \\
\end{tabular}
\begin{tabular}{|r|c|c|c|c|c|c|}\hline
\ \ \textbf{Operation}\ \ & \texttt{SELECT} & \texttt{INSERT} & \texttt{UPSERT} & \texttt{UPDATE} & \texttt{DELETE} & \textbf{Total}\\\hline
\ \ \textbf{Operation}\ \ & \texttt{SELECT} & \texttt{INSERT} & \texttt{UPSERT} & \texttt{UPDATE} & \texttt{DELETE} & \textbf{Total}\\\hline
\textbf{\ \ Count } & \ \ 33,470,310\ \ & \ \ 1,953,279\ \ & \ \ 7,376,648\ \ & \ \ 1,041,967\ \ & \ \ 1,248,594\ \ & \ \ 45,090,798\ \ \\\hline
\textbf{\ \ Runtime (ms) } & \ \ 1.13\ \ & \ \ 2.31\ \ & \ \ 0.93\ \ & \ \ 6.59\ \ & \ \ 3.78\ \ & \\\hline
\multicolumn{7}{|c|}{\textbf{Features Used}}\\\hline
......
\begin{tabular}{|c|c|c|}\hline
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Query Count}\\\hline
Exact Lookups & Const $=$ Expr & \ \ 30,974,814\ \ \\\hline
Other Equality & Expr $=$ Expr & \ \ 1,621,556\ \ \\\hline
Membership Test & Expr [NOT] IN (List or Query) & \ \ 1,041,611\ \ \\\hline
Inequality on 1 constant & Const $\theta$ Expr & \ \ 677,259\ \ \\\hline
Disjunction & [NOT] Expr $\vee$ Expr & \ \ 631,404\ \ \\\hline
Bitwise AND & Expr \& Expr & \ \ 480,921\ \ \\\hline
Other Inequality & Expr $\theta$ Expr & \ \ 442,164\ \ \\\hline
Boolean Column Cast & [NOT] Column & \ \ 302,014\ \ \\\hline
No-op Clause & Const or (Const = Const) & \ \ 229,247\ \ \\\hline
Patterned String Lookup & Expr [NOT] LIKE Pattern & \ \ 156,309\ \ \\\hline
Validity Test & Expr IS [NOT] NULL & \ \ 87,873\ \ \\\hline
Functional If-Then-Else & CASE WHEN \ldots & \ \ 2,428\ \ \\\hline
Range Test & Expr BETWEEN Const AND Const & \ \ 2,393\ \ \\\hline
Function Call & Function(Expr) & \ \ 1,965\ \ \\\hline
Subquery Membership & [NOT] EXISTS (Query) & \ \ 1,584\ \ \\\hline
\begin{tabular}{c|c|c}
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Count}\\\hline
Exact Lookups & \texttt{Const $=$ Expr} & \ \ 30,974,814\ \ \\
Other Equality & \texttt{Expr $=$ Expr} & \ \ 1,621,556\ \ \\
Membership Test & \texttt{Expr [NOT] IN (List or Query)} & \ \ 1,041,611\ \ \\
Inequality on 1 constant & \texttt{Const $\theta$ Expr} & \ \ 677,259\ \ \\
Disjunction & \texttt{[NOT] Expr $\vee$ Expr} & \ \ 631,404\ \ \\
Bitwise AND & \texttt{Expr \& Expr} & \ \ 480,921\ \ \\
Other Inequality & \texttt{Expr $\theta$ Expr} & \ \ 442,164\ \ \\
Boolean Column Cast & \texttt{[NOT] Column} & \ \ 302,014\ \ \\
No-op Clause & \texttt{Const or (Const = Const)} & \ \ 229,247\ \ \\
Patterned String Lookup & \texttt{Expr [NOT] LIKE Pattern} & \ \ 156,309\ \ \\
Validity Test & \texttt{Expr IS [NOT] NULL} & \ \ 87,873\ \ \\
Functional If-Then-Else & \texttt{CASE WHEN \ldots} & \ \ 2,428\ \ \\
Range Test & \texttt{Expr BETWEEN Const AND Const} & \ \ 2,393\ \ \\
Function Call & \texttt{Function(Expr)} & \ \ 1,965\ \ \\
Subquery Membership & \texttt{[NOT] EXISTS (Query)} & \ \ 1,584\ \ \\
\end{tabular}
\begin{tabular}{|c|c|c|}\hline
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Query Count}\\\hline
Exact Lookups & Const $=$ Expr & \ \ 26,303,579\ \ \\\hline
Membership Test & Expr [NOT] IN (List) & \ \ 331,788\ \ \\\hline
Inequality on 1 constant & Const $\theta$ Expr & \ \ 93,816\ \ \\\hline
Patterned String Lookup & Expr [NOT] LIKE Pattern & \ \ 72,289\ \ \\\hline
Disjunction & [NOT] Expr $\vee$ Expr & \ \ 61,541\ \ \\\hline
Other Inequality & Expr $\theta$ Expr & \ \ 38,714\ \ \\\hline
Validity Test & Expr IS [NOT] NULL & \ \ 17,305\ \ \\\hline
No-op Clause & Const or (Const = Const) & \ \ 6,710\ \ \\\hline
Boolean Column Cast & [NOT] Column & \ \ 5,358\ \ \\\hline
Other Equality & Expr $=$ Expr & \ \ 1,471\ \ \\\hline
Function Call & Function(Expr) & \ \ 43\ \ \\\hline
Range Test & Expr BETWEEN Const AND Const & \ \ 18\ \ \\\hline
\begin{tabular}{c|c|c}
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Count}\\\hline
Exact Lookups & \texttt{Const $=$ Expr} & \ \ 26,303,579\ \ \\
Membership Test & \texttt{Expr [NOT] IN (List)} & \ \ 331,788\ \ \\
Inequality on 1 constant & \texttt{Const $\theta$ Expr} & \ \ 93,816\ \ \\
Patterned String Lookup & \texttt{Expr [NOT] LIKE Pattern} & \ \ 72,289\ \ \\
Disjunction & \texttt{[NOT] Expr $\vee$ Expr} & \ \ 61,541\ \ \\
Other Inequality & \texttt{Expr $\theta$ Expr} & \ \ 38,714\ \ \\
Validity Test & \texttt{Expr IS [NOT] NULL} & \ \ 17,305\ \ \\
No-op Clause & \texttt{Const or (Const = Const)} & \ \ 6,710\ \ \\
Boolean Column Cast & \texttt{[NOT] Column} & \ \ 5,358\ \ \\
Other Equality & \texttt{Expr $=$ Expr} & \ \ 1,471\ \ \\
Function Call & \texttt{Function(Expr)} & \ \ 43\ \ \\
Range Test & \texttt{Expr BETWEEN Const AND Const} & \ \ 18\ \ \\
\end{tabular}
\begin{tabular}{c|c|c}
\textbf{Expression Type} & \textbf{Expression Form} & \textbf{Count}\\\hline
Exact Lookups & \texttt{Const $=$ Expr} & \ \ 1,013,697\ \ \\
Disjunction & \texttt{[NOT] Expr $\vee$ Expr} & \ \ 84,937\ \ \\
Inequality on 1 constant & \texttt{Const $\theta$ Expr} & \ \ 18,146\ \ \\
Membership Test & \texttt{Expr [NOT] IN (List or Query)} & \ \ 14,146\ \ \\
Other Inequality & \texttt{Expr $\theta$ Expr} & \ \ 9,443\ \ \\
Boolean Column Cast & \texttt{[NOT] Column} & \ \ 1,640\ \ \\
Validity Test & \texttt{Expr IS [NOT] NULL} & \ \ 1,517\ \ \\
Other Equality & \texttt{Expr $=$ Expr} & \ \ 221\ \ \\
Patterned String Lookup & \texttt{Expr [NOT] LIKE Pattern} & \ \ 59\ \ \\
\end{tabular}
......@@ -75,6 +75,7 @@ def pretty_plot(plot, opts = {})
when :left then 2
when :top then 4
when :right then 8
when :all then 1+2+4+8
else raise "Invalid border type : #{b}"
end
end.sum
......
......@@ -276,6 +276,15 @@ class Array
tot = 0;
map { |x| tot += x }
end
def apply_to_nth(i)
self[i] = yield self[i]
self
end
def cdf
self.map.with_index.map{ |x, i| [ x, i.to_f / length.to_f] }.to_a
end
end
class Hash
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment