[Messaging, JMS & JBossMQ] - Re: excess UIL2 threads
by oglueck
If you want to monitor thread death, deploy this mbean and watch the log:
public class ThreadCoroner extends ServiceMBeanSupport implements ThreadCoronerMBean {
| private ThreadMXBean mbean;
| private Map<Long, ThreadInfo> last;
| private Timer timer;
| private int interval = 60;
|
|
| public int getInterval() {
| return interval;
| }
| public void setInterval(int interval) {
| this.interval = interval;
| }
|
| @Override
| protected void startService() throws Exception {
| mbean = ManagementFactory.getThreadMXBean();
|
| timer = new Timer("ThreadCoroner-Timer", true);
| TimerTask task = new TimerTask() {
| @Override
| public void run() {
| logDeadThreads();
| }
| };
| timer.schedule(task, new Date(), interval * 1000L);
| }
|
| @Override
| protected void stopService() throws Exception {
| timer.cancel();
| mbean = null;
| last = null;
| }
|
| private void logDeadThreads() {
| Map<Long, ThreadInfo> current = getAllThreads();
| if (last != null) {
| Set<ThreadInfo> dead = new HashSet<ThreadInfo>();
| for (Map.Entry<Long, ThreadInfo> entry : last.entrySet()) {
| if (!current.containsKey(entry.getKey())) {
| dead.add(entry.getValue());
| }
| }
|
| for (ThreadInfo ti : dead) {
| log.debug(ti.getThreadName());
| }
| }
| last = current;
| }
|
| private Map<Long, ThreadInfo> getAllThreads() {
| long myId = Thread.currentThread().getId();
| long[] ids = mbean.getAllThreadIds();
| ThreadInfo[] infos = mbean.getThreadInfo(ids);
| Map<Long, ThreadInfo> map = new HashMap<Long, ThreadInfo>(infos.length);
| for (ThreadInfo info : infos) {
| if (info.getThreadId() == myId) continue;
| map.put(new Long(info.getThreadId()), info);
| }
| return map;
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059224#4059224
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4059224
17Â years, 5Â months
[Messaging, JMS & JBossMQ] - Re: excess UIL2 threads
by oglueck
A big problem is this code in SocketManager
| // TODO: Check the validity of this config
| pool = new PooledExecutor(5);
| pool.setMinimumPoolSize(1);
| pool.setKeepAliveTime(1000 * 60);
| pool.runWhenBlocked();
| String id = "SocketManager.MsgPool@"+
| Integer.toHexString(System.identityHashCode(this))
| + " client=" + ipAddress;
| pool.setThreadFactory(new UILThreadFactory(id));
|
This causes a thread-death every minute per connection and side. On our system we see around 5000 new threads every hour just because of that! And we can not change it, because it's hardcoded. This pool config makes the use of a thread pool absurd in terms of resource consumption.
Actually having this extra pool is a bit of an overkill in the first place, I think. It should be enough to have the Read task execute the message synchronously in general. On the server side this is an inject into a queue I guess, which is fast. On the client side this is passing the message to an MDB thread (or is it just passed to an instance? - I haven't checked), which is fast as well.
If this pooled is created, it should be fully configurable.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059223#4059223
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4059223
17Â years, 5Â months