Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion frameworks/Java/avaje-jex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.5</version>
<version>42.7.6</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.avaje.config.Config;
import io.avaje.inject.Bean;
import io.avaje.inject.Factory;
import java.util.concurrent.Executors;
import javax.sql.DataSource;

@Factory
Expand All @@ -22,8 +23,21 @@ DataSource dataSource() {
maxPoolSize = Config.getInt("postgresDefaultPoolSize");
}

var hikari = new HikariDataSource(new HikariConfig("hikari.properties"));
hikari.setMaximumPoolSize(maxPoolSize);
return hikari;
maxPoolSize = Math.max(maxPoolSize, Runtime.getRuntime().availableProcessors() * 2);
HikariConfig hikariConfig = new HikariConfig("hikari.properties");

var vtThreadFactory = Thread.ofVirtual().factory();
hikariConfig.setThreadFactory(vtThreadFactory);
hikariConfig.setScheduledExecutor(
Executors.newScheduledThreadPool(maxPoolSize, vtThreadFactory));

// data source properties
hikariConfig.addDataSourceProperty("cachePrepStmts", "true");
hikariConfig.addDataSourceProperty("prepStmtCacheSize", "250");
hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
hikariConfig.addDataSourceProperty("ssl", "false");
hikariConfig.addDataSourceProperty("tcpKeepAlive", "true");
hikariConfig.setMaximumPoolSize(maxPoolSize);
return new HikariDataSource(hikariConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public JDBCDbService(DataSource connectionFactory) {
}

@Override
public List<World> getWorld(int num) {
public List<World> getWorld(int num) throws SQLException {

String select = "select id, randomNumber from World where id = ?";
List<World> worldList = new ArrayList<>();
Expand All @@ -37,8 +37,6 @@ public List<World> getWorld(int num) {
worldList.add(new World(rs.getInt("id"), rs.getInt("randomNumber")));
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}

return worldList;
Expand All @@ -55,7 +53,7 @@ public List<Fortune> getFortune() throws SQLException {
ResultSet rs = pstm.executeQuery()) {

while (rs.next()) {
fortuneList.add(new Fortune(rs.getInt("id"), rs.getString("message")));
fortuneList.add(new Fortune(rs.getInt(1), rs.getString(2)));
}
fortuneList.add(new Fortune(defaultFortuneId, defaultFortuneMessage));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
physicalTag=Citrine
cloudTag=Azure

postgresPhysicalPoolSize=56
postgresPhysicalPoolSize=64
postgresCloudPoolSize=16
postgresDefaultPoolSize=10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
jdbcUrl=jdbc:postgresql://tfb-database:5432/hello_world
dataSource.serverName=tfb-database
dataSource.portNumber=5432
dataSource.user=benchmarkdbuser
Expand Down
Loading