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

Hikari pool implementation in perfservice #109

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Hikari pool implementation in perfservice #109

wants to merge 14 commits into from

Conversation

shaharuk-yb
Copy link

Flag based hikari pool support in benchbase.

Use flag use_hikari_pool: true/false in input yaml or xml. Default value is false

Optionally, you can set max pool size for hikari through property max_pool_size: <pool_size>. Default max pool size = terminals

Example yaml:

type: YUGABYTE
driver: com.yugabyte.Driver
url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=disable&ApplicationName=featurebench&reWriteBatchedInserts=true&load-balance=false
username: yugabyte
password:
use_hikari_pool: true
max_pool_size: 10

batchsize: 128
isolation: TRANSACTION_REPEATABLE_READ
loaderthreads: 1
terminals: 1
collect_pg_stat_statements: true
use_dist_in_explain : true

works:
    work:
        time_secs: 5
        active_terminals: 1
        rate: unlimited
        warmup: 0
microbenchmark:
    class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBDefaultMicroBenchmark
    properties:
        setAutoCommit: true
        create:
            - DROP TABLE IF EXISTS pkey_rangescan_for_INclause_tbl_1;
            - CREATE TABLE pkey_rangescan_for_INclause_tbl_1(col_bigint_id_1 bigint, col_bigint_1 bigint, col_bigint_2 bigint, col_bigint_3 bigint, col_bigint_4 bigint, col_bigint_5 bigint, col_float2_1 float(2), col_float2_2 float(2), col_float5_1 float(5), col_float5_2 float(5), col_boolean_1 boolean, col_varchar10_1 varchar(10), col_varchar100_1 varchar(100), col_varchar100_2 varchar(100), col_varchar500_1 varchar(500), PRIMARY KEY(col_bigint_id_1 ASC));
        cleanup:
            - DROP TABLE IF EXISTS pkey_rangescan_for_INclause_tbl_1;
        loadRules:
            - table: pkey_rangescan_for_INclause_tbl_
              count: 1
              rows: 1000
              columns:
                  - name: col_bigint_id_
                    count: 1
                    util: PrimaryIntGen
                    params: [1, 1000]
                  - name: col_bigint_
                    count: 5
                    util: RandomNumber
                    params: [1, 1000]
                  - name: col_float2_
                    count: 2
                    util: RandomNoWithDecimalPoints
                    params: [1, 1000, 2]
                  - name: col_float5_
                    count: 2
                    util: RandomNoWithDecimalPoints
                    params: [1, 1000, 5]
                  - name: col_boolean_
                    count: 1
                    util: RandomBoolean
                  - name: col_varchar10_
                    count: 1
                    util: RandomAString
                    params: [10, 10]
                  - name: col_varchar100_
                    count: 2
                    util: RandomAString
                    params: [100, 100]
                  - name: col_varchar500_
                    count: 1
                    util: RandomAString
                    params: [500, 500]
        executeRules:
            - workload: scanG4_pkey_INclause_rangescan_increasing_rows_1row
              run:
                  - name: pkey_INclause_rangescan_increasing_rows_1row_test
                    weight: 100
                    queries:
                        - query: select col_bigint_id_1 from pkey_rangescan_for_INclause_tbl_1 where col_bigint_id_1 IN (?)
                          bindings:
                              count: 1
                              util: RandomNumber
                              params: [ 1, 1000 ]

@shaharuk-yb shaharuk-yb requested a review from hbhanawat October 3, 2023 05:37
if(!usingHikari)
conn.close();
else {
this.conn = this.getBenchmark().makeConnection();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to create a connection and then close it? I think we shouldn't be doing anything in the teardown for hikari.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -73,15 +75,24 @@ public abstract class BenchmarkModule {
public BenchmarkModule(WorkloadConfiguration workConf) {
this.workConf = workConf;
this.dialects = new StatementDialects(workConf);
if (workConf.getXmlConfig().getBoolean("use_hikari_pool", false)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since worker inherits from benchmarkmodule are we creating one hikari pool per worker?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though worker inherits from benchmarkmodule, the datasource is created in benchmarkmodule's constructor which is called only once. Hence, there is only one hikari pool.

private HikariDataSource hikariDataSource;

public void createDataSource() {
HikariConfig config = new HikariConfig();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should shutdown the dataSource and its associated pool after the test is done. You can call datasource.close for the same.


Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented closeDataSource() method which will close it in ThreadBench finalizeWorkers()

@shaharuk-yb shaharuk-yb requested a review from hbhanawat October 3, 2023 06:49
@shaharuk-yb
Copy link
Author

@hbhanawat - Getting following error after closedatasource implementation.

HikariDataSource HikariDataSource (HikariPool-1) has been closed.
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96)
	at com.oltpbenchmark.api.BenchmarkModule.makeConnection(BenchmarkModule.java:94)
	at com.oltpbenchmark.api.BenchmarkModule.refreshCatalog(BenchmarkModule.java:242)
	at com.oltpbenchmark.DBWorkload.main(DBWorkload.java:618)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants