Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/2024 07 additional benchmarks #257

Merged
merged 60 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3b36502
Replace package to connector
takapi327 Jul 21, 2024
8a91fde
Added connector dependsOn
takapi327 Jul 21, 2024
a384290
Create benchmark sql
takapi327 Jul 21, 2024
1542c80
Change use Cats Effect Resorce
takapi327 Jul 21, 2024
a577ea8
Create my.conf settings
takapi327 Jul 21, 2024
22ed7a6
Update MySQL version
takapi327 Jul 21, 2024
08294b8
Create ldbc Insert benchmark
takapi327 Jul 21, 2024
2467d7f
Fixed batchN Benchmark
takapi327 Jul 22, 2024
128a22f
Action sbt scalafmtAll
takapi327 Jul 22, 2024
1e84e0a
Added batchN benchmark test for ldbc
takapi327 Jul 22, 2024
ad791e2
Fixed test
takapi327 Jul 22, 2024
642c486
Correction of version differences
takapi327 Jul 22, 2024
61c3480
Fixed test
takapi327 Jul 22, 2024
8e6b1f2
Fixed jdbc Select benchmark
takapi327 Jul 23, 2024
a9ca0a7
Create Select benchmark for ldbc
takapi327 Jul 23, 2024
27032e2
Action sbt scalafmtAll
takapi327 Jul 23, 2024
2132106
Merge branch 'master' of github.com:takapi327/ldbc into enhancement/2…
takapi327 Jul 24, 2024
1efb9b7
Added setRewriteBatchedStatements
takapi327 Jul 25, 2024
a1dcb97
Added .gitignore target file
takapi327 Jul 25, 2024
5ac3133
Create requirements.txt
takapi327 Jul 25, 2024
a3514bc
Create plot_benchmark.py
takapi327 Jul 25, 2024
d4745f7
Create Dockerfile
takapi327 Jul 25, 2024
f75cfda
Fixed benchmark table
takapi327 Jul 27, 2024
7be4f15
Added .gitignore target file
takapi327 Jul 27, 2024
ca73999
Fixed Dockerfile
takapi327 Jul 27, 2024
cddff52
Create docker-build-python.sh
takapi327 Jul 27, 2024
a5a2463
Create visualize.py
takapi327 Jul 27, 2024
d33515f
Create visualize.sh
takapi327 Jul 27, 2024
225174b
Create connector benchmark test
takapi327 Jul 27, 2024
ce03f9d
Added .gitignore target file
takapi327 Jul 27, 2024
0c44292
Action sbt scalafmtAll
takapi327 Jul 27, 2024
de1af8f
Added target
takapi327 Jul 27, 2024
ae9cd55
Create benchmark.sh
takapi327 Jul 27, 2024
fd59bd9
Added benchmark result image
takapi327 Jul 27, 2024
db814dd
Fixed connector insert benchmark
takapi327 Jul 28, 2024
d0ae7ba
Added table for benchmark
takapi327 Jul 28, 2024
964268b
Fixed visualize.py
takapi327 Jul 28, 2024
f380a89
Change Insert.svg
takapi327 Jul 28, 2024
90d0fe7
Delete unused
takapi327 Jul 28, 2024
e1c4d6e
Merge branch 'master' of github.com:takapi327/ldbc into enhancement/2…
takapi327 Jul 31, 2024
4c22ea8
Fixed conflict
takapi327 Aug 4, 2024
8e80be1
Action sbt scalafmtAll
takapi327 Aug 5, 2024
1338e86
Action sbt scalafmtAll
takapi327 Aug 5, 2024
98d42c3
Delete unused
takapi327 Aug 5, 2024
02af7ec
Delete unused comment out code
takapi327 Aug 5, 2024
ea6d2d8
Action sbt scalafmtAll
takapi327 Aug 5, 2024
6c3b501
Delete measure debug code
takapi327 Aug 12, 2024
ecebd14
Merge branch 'master' of github.com:takapi327/ldbc into enhancement/2…
takapi327 Aug 12, 2024
0595685
Fixed Benchmark Param
takapi327 Aug 13, 2024
2d59619
Added formatter PASCAL settings
takapi327 Aug 13, 2024
ca22369
Added additionalSettings in benchmark project
takapi327 Aug 13, 2024
72fd73c
Create wrapper benchmark code
takapi327 Aug 13, 2024
9c08512
Added TYPES settings
takapi327 Aug 13, 2024
0fe70e2
Added target_names
takapi327 Aug 13, 2024
22698d0
Delete unused
takapi327 Aug 13, 2024
27d6e93
Create wrapper Insert Benchmark
takapi327 Aug 13, 2024
0b89912
Renam TYPE -> KIND
takapi327 Aug 14, 2024
0ad2cc3
Added insertN benchmark
takapi327 Aug 14, 2024
878c2f1
Added docs image
takapi327 Aug 14, 2024
8c8bc61
Action sbt scalafmtAll
takapi327 Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ target/
.vscode/
metals.sbt

**/benchmark/**/*.json
**/benchmark/**/*.svg
3 changes: 3 additions & 0 deletions benchmark/src/main/scala/benchmark/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
package benchmark

import ldbc.query.builder.Table
import ldbc.query.builder.formatter.Naming

given Naming = Naming.PASCAL

case class Model1(
c1: Int
Expand Down

This file was deleted.

101 changes: 0 additions & 101 deletions benchmark/src/main/scala/benchmark/caseclass/RuntimeCreate.scala

This file was deleted.

91 changes: 91 additions & 0 deletions benchmark/src/main/scala/benchmark/connector/jdbc/Batch.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* Copyright (c) 2023-2024 by Takahiko Tominaga
* This software is licensed under the MIT License (MIT).
* For more information see LICENSE or https://opensource.org/licenses/MIT
*/

package benchmark.connector.jdbc

import java.util.concurrent.TimeUnit

import scala.compiletime.uninitialized

import com.mysql.cj.jdbc.MysqlDataSource

import org.openjdk.jmh.annotations.*

import cats.effect.*
import cats.effect.unsafe.implicits.global

import ldbc.sql.Connection

@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
class Batch:

@volatile
var connection: Resource[IO, Connection[IO]] = uninitialized

@volatile
var values: String = uninitialized

@volatile
var records: List[(Int, String)] = List.empty

@Setup
def setupDataSource(): Unit =
val ds = new MysqlDataSource()
ds.setServerName("127.0.0.1")
ds.setPortNumber(13306)
ds.setDatabaseName("benchmark")
ds.setUser("ldbc")
ds.setPassword("password")
ds.setRewriteBatchedStatements(true)

val datasource = jdbc.connector.MysqlDataSource[IO](ds)

connection = Resource.make(datasource.getConnection)(_.close())

values = (1 to len).map(_ => "(?, ?)").mkString(",")

records = (1 to len).map(num => (num, s"record$num")).toList

@Param(Array("10", "100", "1000", "2000", "4000"))
var len: Int = uninitialized

@Benchmark
def statement(): Unit =
connection
.use { conn =>
for
statement <- conn.createStatement()
_ <- records.foldLeft(IO.unit) {
case (acc, (id, value)) =>
acc *>
statement.addBatch(s"INSERT INTO jdbc_statement_test (c1, c2) VALUES ${ records
.map { case (v1, v2) => s"($v1, '$v2')" }
.mkString(", ") }")
}
_ <- statement.executeBatch()
yield ()
}
.unsafeRunSync()

@Benchmark
def prepareStatement(): Unit =
connection
.use { conn =>
for
statement <- conn.prepareStatement(s"INSERT INTO jdbc_prepare_statement_test (c1, c2) VALUES (?, ?)")
_ <- records.foldLeft(IO.unit) {
case (acc, (id, value)) =>
acc *>
statement.setInt(1, id) *>
statement.setString(2, value) *>
statement.addBatch()
}
_ <- statement.executeBatch()
yield ()
}
.unsafeRunSync()
146 changes: 146 additions & 0 deletions benchmark/src/main/scala/benchmark/connector/jdbc/Insert.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* Copyright (c) 2023-2024 by Takahiko Tominaga
* This software is licensed under the MIT License (MIT).
* For more information see LICENSE or https://opensource.org/licenses/MIT
*/

package benchmark.connector.jdbc

import java.util.concurrent.TimeUnit
import java.time.*

import scala.compiletime.uninitialized

import com.mysql.cj.jdbc.MysqlDataSource

import org.openjdk.jmh.annotations.*

import cats.effect.*
import cats.effect.unsafe.implicits.global

import ldbc.sql.Connection

@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
class Insert:

@volatile
var connection: Resource[IO, Connection[IO]] = uninitialized

@volatile
var values: String = uninitialized

@volatile
var records: List[
(
Short,
Int,
Int,
Int,
Long,
Float,
Double,
BigDecimal,
String,
String,
Boolean,
LocalDate,
LocalTime,
LocalDateTime,
LocalDateTime
)
] = List.empty

@Setup
def setupDataSource(): Unit =
val ds = new MysqlDataSource()
ds.setServerName("127.0.0.1")
ds.setPortNumber(13306)
ds.setDatabaseName("benchmark")
ds.setUser("ldbc")
ds.setPassword("password")

val datasource = jdbc.connector.MysqlDataSource[IO](ds)

connection = Resource.make(datasource.getConnection)(_.close())

values = (1 to len).map(_ => "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").mkString(",")

records = (1 to len)
.map(num =>
(
1.toShort,
1,
1,
1,
1L,
1.1f,
1.1,
BigDecimal.decimal(1.1),
s"varchar $num",
s"text $num",
true,
LocalDate.now(),
LocalTime.now(),
LocalDateTime.now(),
LocalDateTime.now()
)
)
.toList

@Param(Array("10", "100", "1000", "2000", "4000"))
var len: Int = uninitialized

@Benchmark
def statement(): Unit =
connection
.use { conn =>
for
statement <- conn.createStatement()
_ <-
statement.executeUpdate(
s"INSERT INTO jdbc_statement_test (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) VALUES ${ records
.map {
case (v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) =>
s"($v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, '$v9', '$v10', $v11, '$v12', '$v13', '${ v14.toString
.replace("T", " ") }', '${ v15.toString.replace("T", " ") }')"
}
.mkString(",") }"
)
yield ()
}
.unsafeRunSync()

@Benchmark
def prepareStatement(): Unit =
connection
.use { conn =>
for
statement <-
conn.prepareStatement(
s"INSERT INTO jdbc_prepare_statement_test (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) VALUES $values"
)
_ <- records.zipWithIndex.foldLeft(IO.unit) {
case (acc, ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15), index)) =>
acc *>
statement.setShort(index * 15 + 1, v1) *>
statement.setInt(index * 15 + 2, v2) *>
statement.setInt(index * 15 + 3, v3) *>
statement.setInt(index * 15 + 4, v4) *>
statement.setLong(index * 15 + 5, v5) *>
statement.setFloat(index * 15 + 6, v6) *>
statement.setDouble(index * 15 + 7, v7) *>
statement.setBigDecimal(index * 15 + 8, v8.bigDecimal) *>
statement.setString(index * 15 + 9, v9) *>
statement.setString(index * 15 + 10, v10) *>
statement.setBoolean(index * 15 + 11, v11) *>
statement.setDate(index * 15 + 12, v12) *>
statement.setTime(index * 15 + 13, v13) *>
statement.setTimestamp(index * 15 + 14, v14) *>
statement.setTimestamp(index * 15 + 15, v15)
}
_ <- statement.executeUpdate()
yield ()
}
.unsafeRunSync()
Loading