Generational ZGC regression with H2 database
Stefan Karlsson
stefan.karlsson at oracle.com
Thu Oct 20 08:18:57 UTC 2022
Hi Brian,
Thanks for posting your results and the way to reproduce it. This makes
it much easier for us to see if there's anything we can do w.r.t. to gap
in the performance difference and why the allocation stalls happen.
Thanks,
StefanK
On 2022-10-19 17:33, Brian S O'Neill wrote:
> I created a simple test which stresses a fresh H2 database by
> inserting a bunch of random rows into a simple key-value table. The H2
> cache size is set to 4GB, and the max Java heap size is 12GB.
>
> I ran the test using JDK-19 ZGC for 30 minutes, and the average
> throughput was 23,075 inserts per second. With generational ZGC, the
> average throughput dropped to 20,284 inserts per second, and 11
> allocation stalls were observed. The longest one lasted 724
> milliseconds. Note that no allocation stalls were observed with
> non-generational ZGC.
>
> Here's the code:
>
> import java.sql.*;
> import java.util.*;
>
> public class H2Perf {
> public static void main(String[] args) throws Exception {
> String path = args[0];
>
> long numToInsert = 100_000_000L;
> long maxDurationMillis = 30L * 60 * 1000;
>
> Class.forName("org.h2.Driver");
> String conString = "jdbc:h2:" + path + ";CACHE_SIZE=4000000";
>
> Connection con = DriverManager.getConnection(conString, "sa",
> "");
>
> try (Statement st = con.createStatement()) {
> st.execute("create table test_tab (" +
> "name varchar(30) primary key," +
> "val varchar(30) )");
> }
>
> PreparedStatement ps = con.prepareStatement
> ("insert into test_tab (name, val) values (?,?)");
>
> var rnd = new Random(234234);
> int total = 0;
> long durationMillis = 0;
> long start = System.currentTimeMillis();
>
> do {
> long n = rnd.nextLong();
> ps.setString(1, "key-" + n);
> ps.setString(2, "value-" + n);
> ps.execute();
>
> total++;
>
> if (total % 100_000 == 0) {
> durationMillis = (System.currentTimeMillis() - start);
> float rate = (float) ((total / (double)
> durationMillis) * 1000.0);
> System.out.println("inserted: " + total + " @ " + rate
> + " per second");
> }
> } while (total < numToInsert && durationMillis <
> maxDurationMillis);
> }
> }
More information about the zgc-dev
mailing list