-
1. Re: AccessController performance in Wildfly
jaikiran Oct 11, 2019 10:58 PM (in response to gbrown1)Is this with security manager enabled or disabled? Any screenshots/data that you can share which shows this 50x kind of change in performance, to help better narrow this down?
-
2. Re: AccessController performance in Wildfly
gbrown1 Oct 14, 2019 10:05 AM (in response to jaikiran)Security manager is not enabled. The following example can be used to reproduce the issue:
@Test
public void testAccessController() throws Exception
{
PrivilegedAction<Void> action = () -> {
System.out.print("");
return null;
};
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
AccessController.doPrivileged(action);
}
long end = System.currentTimeMillis();
log.info("Execution took {} millis", end - start);
}
When run in JBoss 4, each run takes ~24ms. In Wildfly 18, each run takes ~1300ms.
-
3. Re: AccessController performance in Wildfly
gbrown1 Oct 14, 2019 4:01 PM (in response to jaikiran)Update: When I calculate the time inside the action handler separately, it appears that the doPrivileged() plumbing accounts for about 20ms in both JBoss and Wildfly.
In JBoss, the action itself only takes about 1ms total (for all 100K invocations). In Wildfly, the action accounts for the bulk of the 1,300ms. So the question actually may be - why does System.out.println() take so much longer in Wildfly? Maybe this is indicative of an I/O-related performance issue?
-
4. Re: AccessController performance in Wildfly
gbrown1 Oct 18, 2019 11:20 AM (in response to gbrown1)Here's a little more information. We have observed a repeatable performance issue with the XMLEncoder class as well. The following test takes about 2.6 on my machine:
public class TestApplication {
public static void runTest(PrintWriter writer) throws IOException {
final int COUNT = 50000;
long start = System.currentTimeMillis();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try (XMLEncoder encoder = new XMLEncoder(byteArrayOutputStream)) {
for (int i = 0; i < COUNT; i++) {
encoder.writeObject(new Object[] {i, "abcdefghijklmnop"});
}
}
String xml = new String(byteArrayOutputStream.toByteArray());
try (StringReader reader = new StringReader(xml); XMLDecoder decoder = new XMLDecoder(new InputSource(reader))) {
for (int i = 0; i < COUNT; i++) {
decoder.readObject();
}
}
long end = System.currentTimeMillis();
writer.printf("Execution took %d millis\n", end - start);
}
public static void main(String[] args) throws IOException {
PrintWriter writer = new PrintWriter(System.out);
runTest(writer);
writer.flush();
}
}
However, when I run the same test in Wildfly (as a servlet), the test takes about 4.8 seconds:
@WebServlet(urlPatterns={"/*"}, loadOnStartup=1)
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 0;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
TestApplication.runTest(response.getWriter());
}
}