8318467: [jmh] tests concurrent.Queues and concurrent.ProducerConsumer hang with 101+ threads

Reviewed-by: alanb
This commit is contained in:
Viktor Klang 2023-10-31 11:14:08 +00:00 committed by Alan Bateman
parent d3c3f0e7c8
commit e05cafda78
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,6 +35,7 @@ import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.infra.ThreadParams;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@ -55,7 +56,7 @@ import java.util.concurrent.TimeUnit;
@Fork(3)
public class ProducerConsumer {
@Param("100")
@Param("100") // Will be expanded to at least the number of threads used
private int capacity;
@Param
@ -65,7 +66,9 @@ public class ProducerConsumer {
private Producer prod;
@Setup
public void prepare() {
public void prepare(ThreadParams params) {
capacity = Math.max(params.getThreadCount(), capacity);
switch (type) {
case ABQ_F:
q = new ArrayBlockingQueue<>(capacity, true);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,7 @@ import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.infra.ThreadParams;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@ -49,7 +50,7 @@ import java.util.concurrent.TimeUnit;
@Fork(3)
public class Queues {
@Param("100")
@Param("100") // Will be expanded to at least the number of threads used
private int capacity;
@Param
@ -65,7 +66,9 @@ public class Queues {
private BlockingQueue<Integer> q;
@Setup
public void setup() {
public void setup(ThreadParams params) {
capacity = Math.max(params.getThreadCount(), capacity);
switch (type) {
case ABQ_F:
q = new ArrayBlockingQueue<>(capacity, true);