【发布时间】:2018-08-14 11:33:46
【问题描述】:
今天我遇到了一个行为相当奇怪的java程序。
在 cmd shell 中测试运行 java 程序会导致执行速度非常快(约 0.5 秒)。使用 PHP 脚本通过 IIS 访问相同的 java 会导致每个请求的等待时间为 5.5 秒。
我在 java 调用中添加了 -Xprof 以查看它的行为,并发现了这样的重复模式:
Flat profile of 0.25 secs (24 total ticks): SeedGenerator Thread
Thread-local ticks:
100.0% 24 Blocked (of total)
最后我们得到以下时间结果:
Thread-local ticks:
91.4% 448 Blocked (of total)
2.4% 1 Unknown: no last frame
lat profile of 5.04 secs (452 total ticks): SeedGenerator Thread
Interpreted + native Method
0.2% 0 + 1 java.lang.Object.notifyAll
0.2% 0 + 1 Total interpreted
Compiled + native Method
99.6% 27 + 423 sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run
99.6% 27 + 423 Total compiled
Stub + native Method
0.2% 0 + 1 java.lang.System.currentTimeMillis
0.2% 0 + 1 Total stub
Global summary of 5.55 seconds:
100.0% 492 Received ticks
1.8% 9 Compilation
0.2% 1 Other VM operations
0.6% 3 Unknown code
代码在 SeedGenerator 中花费了 5s,在此期间 java.exe 消耗了一个完整的 cpu 线程。 我试过在模拟打开或关闭的情况下运行 FastCGI,它不会改变结果。
【问题讨论】:
标签: java php performance iis