You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "James H. H. Lampert via users" <us...@tomcat.apache.org> on 2026/03/11 20:27:57 UTC
Run Priority -- Tomcat running on IBM Midrange boxes
I just happened to discover (while investigating an issue brought up by
a customer) that the standard catalina.sh shell script in Tomcat 9 has a
section, conditioned to only execute on IBM Midrange boxes, that sets
the run priority to 6.
if $os400; then
COMMAND='chgjob job('$JOBNAME') runpty(6)'
system $COMMAND
# Enable multi threading
export QIBM_MULTI_THREADED=Y
fi
When I discussed this on the Midrange Java List, it was pointed out that
this is an extremely high priority (low RUNPTY values have more priority
than high RUNPTY values). Terminal session jobs typically have a
priority of 20; batch jobs typically have a priority of 50, with certain
high-priority ones getting 35 or 25. Typically, only the most critical
jobs get 10 or better.
Is there some reason why this is the default for Tomcat?
--
James H. H. Lampert
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by Rainer Jung <ra...@kippdata.de>.
Am 13.03.26 um 21:32 schrieb James H. H. Lampert via users:
> On 3/13/26 12:32 PM, Christopher Schultz wrote:
> . . .
>> I *am* very curious whether this priority is taking effect, as it's
>> looking for an OS string that begins with "OS400". If you run "uname"
>> at your command prompt, what does it print? IIRC, you were running
>> Tomcat inside of a Linux VM because "it was easier" or something like
>> that. If that's the case, than the OS400-related stuff won't be
>> running at all.
> . . .
>
> Dear Christopher:
>
> Thanks for visiting my humble thread. Your knowledge of Tomcat is always
> welcome (especially given that you've saved my E.asinus more than once).
> That said, . . .
>
> Uh, "uname" is not a native command in whatever IBM is calling OS/400
> these days. If you were to type it on a native command line, you'd get
> an error message, "Command UNAME in library *LIBL not found." on your
> status line. (Note that the native file system is actually a DB2
> database, and object names are not case-sensitive.)
>
> If you start a QShell session, which is a *nix-like shell environment
> where Java runs (but definitely not an actual Linux VM), and you type
> uname, you get "OS400."
>
> And no, a Linux VM would not be easier. Short of setting up some sort of
> Linux LPAR on the box, I couldn't imagine how one would even do that.
> What I did to make it easier was to create a CL program (like a shell
> script for IBM Midrange boxes, except that CL programs are compiled)
> that looks for the most compatible JVM, sets parameters accordingly,
> then launches Tomcat. And another one that attempts to initiate a
> shutdown, waits for the job to go away, and if it fails to do so, abends
> it.
For the sake of completeness: the oldest commit adding runpty was in May
2003 (25 years ago!) applied to TC 4.1:
https://lists.apache.org/thread/d6flf7txlfxq8fz65fhz8jdr0hp6yqvl
The change goes back to the following mail thread starting a month earlier:
https://lists.apache.org/thread/nm6ptz8jl40wbygw6tzh4924sflwh2b9
but I couldn't find what code the OP Robert Upshall might have provided
passed along to Jean Frederic.
Best regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by Christopher Schultz <ch...@christopherschultz.net>.
James,
On 3/13/26 4:32 PM, James H. H. Lampert via users wrote:
> On 3/13/26 12:32 PM, Christopher Schultz wrote:
> . . .
>> I *am* very curious whether this priority is taking effect, as it's
>> looking for an OS string that begins with "OS400". If you run "uname"
>> at your command prompt, what does it print? IIRC, you were running
>> Tomcat inside of a Linux VM because "it was easier" or something like
>> that. If that's the case, than the OS400-related stuff won't be
>> running at all.
> . . .
>
> Dear Christopher:
>
> Thanks for visiting my humble thread. Your knowledge of Tomcat is always
> welcome (especially given that you've saved my E.asinus more than once).
> That said, . . .
>
> Uh, "uname" is not a native command in whatever IBM is calling OS/400
> these days. If you were to type it on a native command line, you'd get
> an error message, "Command UNAME in library *LIBL not found." on your
> status line. (Note that the native file system is actually a DB2
> database, and object names are not case-sensitive.)
This isn't surprising at all.
> If you start a QShell session, which is a *nix-like shell environment
> where Java runs (but definitely not an actual Linux VM), and you type
> uname, you get "OS400."
Okay, so if you launch Tomcat from a QShell session, then it *will* be
using that OS400-specific code in the shell script, and applying that
priority level...
But then both the change-in-priority and the JVM launch will happen in
that same shell. So what happens when you set the priority of a process
in this way through QShell? Does it give you an absolute priority (e.g.
0 - 100 maps directly to 0 - 100 system priority), or a relative one
(e.g. 0 - 100 maps to [current process priority + requested priority],
or something else?
> And no, a Linux VM would not be easier. Short of setting up some sort of
> Linux LPAR on the box, I couldn't imagine how one would even do that.
> What I did to make it easier was to create a CL program (like a shell
> script for IBM Midrange boxes, except that CL programs are compiled)
> that looks for the most compatible JVM, sets parameters accordingly,
> then launches Tomcat. And another one that attempts to initiate a
> shutdown, waits for the job to go away, and if it fails to do so, abends
> it.
Okay, forget the Linux VM thing, then. I think maybe I was remembering
you using QShell to get a POSIX-style shell.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by "James H. H. Lampert via users" <us...@tomcat.apache.org>.
On 3/13/26 12:32 PM, Christopher Schultz wrote:
. . .
> I *am* very curious whether this priority is taking effect, as it's
> looking for an OS string that begins with "OS400". If you run "uname" at
> your command prompt, what does it print? IIRC, you were running Tomcat
> inside of a Linux VM because "it was easier" or something like that. If
> that's the case, than the OS400-related stuff won't be running at all.
. . .
Dear Christopher:
Thanks for visiting my humble thread. Your knowledge of Tomcat is always
welcome (especially given that you've saved my E.asinus more than once).
That said, . . .
Uh, "uname" is not a native command in whatever IBM is calling OS/400
these days. If you were to type it on a native command line, you'd get
an error message, "Command UNAME in library *LIBL not found." on your
status line. (Note that the native file system is actually a DB2
database, and object names are not case-sensitive.)
If you start a QShell session, which is a *nix-like shell environment
where Java runs (but definitely not an actual Linux VM), and you type
uname, you get "OS400."
And no, a Linux VM would not be easier. Short of setting up some sort of
Linux LPAR on the box, I couldn't imagine how one would even do that.
What I did to make it easier was to create a CL program (like a shell
script for IBM Midrange boxes, except that CL programs are compiled)
that looks for the most compatible JVM, sets parameters accordingly,
then launches Tomcat. And another one that attempts to initiate a
shutdown, waits for the job to go away, and if it fails to do so, abends it.
--
JHHL
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by Christopher Schultz <ch...@christopherschultz.net>.
James,
On 3/11/26 7:14 PM, James H. H. Lampert via users wrote:
> On 3/11/26 3:53 PM, Konstantin Kolinko wrote:
> . . .
>> # Set job priority to standard for interactive (interactive - 6) by
>> using
>> # the interactive priority - 6, the helper threads that respond to
>> requests
>> # will be running at the same priority as interactive jobs.
>> COMMAND='chgjob job('$JOBNAME') runpty(6)'
> . . .
>
> Thanks. I saw the comment in the code, but omitted it when quoting, to
> avoid risking having the long comment lines wrap, obscuring the meaning
> of the excerpt.
>
> And I have no idea how to go about finding the commit that put that
> block into the code, so thank you VERY MUCH for doing that.
>
> It sounds like whoever did commit 421604 didn't understand how run
> priority (RUNPTY) works on IBM Midrange boxes. The range is from 1
> (highest priority, preempts everything) to 99 (lowest priority,
> preempted by everything) As I said, most terminal sessions run at
> RUNPTY(20), while most batch jobs run at RUNPTY(50). It's considered
> extremely unusual (I've been working with IBM Midrange boxes for 3
> decades now, and only just now was made aware of it) for anything other
> than the console to run at priority 10 or better.
>
> It's entirely possible that only that individual would be able to
> explain what the CHGJOB RUNPTY(6) is doing there.
>
> And I'm not entirely sure how that interacts with threadPriority in
> Java, either. Nobody has complained about the JVM job on their Tomcat
> server going "runaway" with that RUNPTY(6).
I agree that this was probably originally written by someone who didn't
understand how priorities work on OS400.
I *am* very curious whether this priority is taking effect, as it's
looking for an OS string that begins with "OS400". If you run "uname" at
your command prompt, what does it print? IIRC, you were running Tomcat
inside of a Linux VM because "it was easier" or something like that. If
that's the case, than the OS400-related stuff won't be running at all.
Run priority 6 for an IBM i Series server does seem quite high. It
should probably be 10 or higher (i.e. lower), but it really depends upon
the expected use.
If it's one of 10,000 processes running on the server, then yeah lower
priority probably makes sense. If you have a thin application and most
of the application is really hidden elsewhere (e.g. inside a database)
then priority doesn't matter much: most of the time spent in Tomcat code
will just be waiting on I/O, so the priority is irrelevant. And, if
nobody has noticed for a long time, maybe it doesn't matter?
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by "James H. H. Lampert via users" <us...@tomcat.apache.org>.
On 3/11/26 3:53 PM, Konstantin Kolinko wrote:
. . .
> # Set job priority to standard for interactive (interactive - 6) by using
> # the interactive priority - 6, the helper threads that respond to requests
> # will be running at the same priority as interactive jobs.
> COMMAND='chgjob job('$JOBNAME') runpty(6)'
. . .
Thanks. I saw the comment in the code, but omitted it when quoting, to
avoid risking having the long comment lines wrap, obscuring the meaning
of the excerpt.
And I have no idea how to go about finding the commit that put that
block into the code, so thank you VERY MUCH for doing that.
It sounds like whoever did commit 421604 didn't understand how run
priority (RUNPTY) works on IBM Midrange boxes. The range is from 1
(highest priority, preempts everything) to 99 (lowest priority,
preempted by everything) As I said, most terminal sessions run at
RUNPTY(20), while most batch jobs run at RUNPTY(50). It's considered
extremely unusual (I've been working with IBM Midrange boxes for 3
decades now, and only just now was made aware of it) for anything other
than the console to run at priority 10 or better.
It's entirely possible that only that individual would be able to
explain what the CHGJOB RUNPTY(6) is doing there.
And I'm not entirely sure how that interacts with threadPriority in
Java, either. Nobody has complained about the JVM job on their Tomcat
server going "runaway" with that RUNPTY(6).
--
James H. H. Lampert
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Run Priority -- Tomcat running on IBM Midrange boxes
Posted by Konstantin Kolinko <kn...@gmail.com>.
ср, 11 мар. 2026 г. в 23:28, James H. H. Lampert via users
<us...@tomcat.apache.org>:
>
> I just happened to discover (while investigating an issue brought up by
> a customer) that the standard catalina.sh shell script in Tomcat 9 has a
> section, conditioned to only execute on IBM Midrange boxes, that sets
> the run priority to 6.
>
> if $os400; then
> COMMAND='chgjob job('$JOBNAME') runpty(6)'
> system $COMMAND
> # Enable multi threading
> export QIBM_MULTI_THREADED=Y
> fi
>
> When I discussed this on the Midrange Java List, it was pointed out that
> this is an extremely high priority (low RUNPTY values have more priority
> than high RUNPTY values). Terminal session jobs typically have a
> priority of 20; batch jobs typically have a priority of 50, with certain
> high-priority ones getting 35 or 25. Typically, only the most critical
> jobs get 10 or better.
>
> Is there some reason why this is the default for Tomcat?
A trivial answer is that
1. That block is accompanied by a comment that you missed in your quote:
# Set job priority to standard for interactive (interactive - 6) by using
# the interactive priority - 6, the helper threads that respond to requests
# will be running at the same priority as interactive jobs.
COMMAND='chgjob job('$JOBNAME') runpty(6)'
2. A blame output shows that this fragment is there from
commit 421604 (2006-07-13), "Add the set of scripts",
initial commit for the file. So I guess the origins are in Tomcat 5 or earlier.
3. For threads that matter, nowadays you can configure the priority
via configuration:
For the acceptor thread (that handles incoming connection attempts)
via "acceptorThreadPriority" on a <Connector>
https://tomcat.apache.org/tomcat-9.0-doc/config/http.html#Standard_Implementation
For request processing threads via "threadPriority" on an Executor
(preferred), or
on the Connector (if you have not configured an Executor).
https://tomcat.apache.org/tomcat-9.0-doc/config/executor.html#Standard_Implementation
Both values are documented to default to"5" (the value of
java.lang.Thread.NORM_PRIORITY).
I wonder whether the value in the shell file has any effect. Between
- the value configured in the shell file and
- the default value (5) and
- an explicitly configured Thread priority value (if one edits the
configuration)
which one wins?
The main java thread (that actually listens for the "SHUTDOWN" command
and does nothing else)
certainly does not need a high priority.
An explanation may be that either those configuration options were not
available,
or java.lang.Thread API had limitations on your OS,
20 years ago in 2006.
BTW, the same "runpty" call is present in tool-wrapper.sh
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org