简体   繁体   English

Jenkins 作业窗口批处理执行比在 cmd.exe 中执行慢 20 倍

[英]Jenkins job windows batch execution 20 times slower than executing in cmd.exe

I just installed Jenkins 2.46.2 on a Windows 2012 Server \o/.我刚刚在 Windows 2012 Server \o/ 上安装了 Jenkins 2.46.2。 It runs as a system service.它作为系统服务运行。

I created a job that execute a windows batch (.bat) script to build a code project.我创建了一个执行 Windows 批处理 (.bat) 脚本来构建代码项目的作业。 This batch results in executing 2 mingw32-make.exe commands to clean and then build a full binary from source code.此批处理导致执行 2 个 mingw32-make.exe 命令来清理然后从源代码构建完整的二进制文件。 Executing the batch manually on the machine, located on the same filesystem (same workspace as used by the Jenkins' job, local disk - not network disk), the clean-build takes ~50 seconds.在机器上手动执行批处理,位于同一文件系统(与 Jenkins 的作业使用的工作空间相同,本地磁盘 - 不是网络磁盘),干净构建大约需要 50 秒。

But when executed by Jenkins, the job takes more than 20x more time longer!但是当由 Jenkins 执行时,这项工作需要的时间要长 20 倍以上! (~19 minutes). (约 19 分钟)。 It terminates succesfully with the same behavior as executed manually in cmd.exe.它以与在 cmd.exe 中手动执行的相同行为成功终止。

I changed the launch arguments for the jvm in the jenkins.xml file with "-Xmx1024m -XX:MaxPermSize=512m" options as I have read in the documentation to improve performance.我在文档中阅读了“-Xmx1024m -XX:MaxPermSize=512m”选项以提高性能,我在 jenkins.xml 文件中更改了 jvm 的启动参数。 But it does not fix anything :-(但它不能解决任何问题:-(

Also when I monitors the CPU/disk/RAM usages they all stay very very low while building, so I deduce that brute performances of the machine are not in cause.此外,当我监控 CPU/磁盘/RAM 使用情况时,它们在构建时都保持非常低的水平,因此我推断机器的粗暴性能不是原因。

Whether I invoke the batch with call statement in the Jenkins job build step or not does not change anything : the job always last 19 minutes.无论我是否在 Jenkins 作业构建步骤中使用 call 语句调用批处理都不会改变任何内容:作业总是持续 19 分钟。

Can anybody help me to investigate why so slowness ?谁能帮我调查一下为什么这么慢?

Thanks in advance :)提前致谢 :)

I had a similar problem.我有一个类似的问题。 I noticed that .bat files with echo Hello World ran fast and with no problem.我注意到带有echo Hello World的 .bat 文件运行得很快并且没有问题。

But once I tried to launch any grep.exe from a batch script, it took 24 seconds (in my case) to run even with no input files.但是,一旦我尝试从批处理脚本启动任何 grep.exe,即使没有输入文件,也需要 24 秒(在我的情况下)才能运行。 If launched manually it finishes in no time.如果手动启动,它会立即完成。

I used grep.exe version 2.5.4 from MSys 1.0 distribution.我使用了 MSys 1.0 发行版中的 grep.exe 2.5.4 版。

The solution in my case was rather unexpected - I updated grep to version 2.24, and now, being launched from Jenkins, it takes less than one second to process over 1 MB log file.在我的情况下,解决方案相当出乎意料 - 我将 grep 更新到 2.24 版,现在,从 Jenkins 启动,处理超过 1 MB 的日志文件只需不到一秒的时间。

For a couple of day investigation, I finally find the cause.经过几天的调查,我终于找到了原因。

In my case, it is the reason of Jenkins agent.就我而言,这是 Jenkins 代理的原因。

When I install Jenkins agent as a windows service in the slave agent, the consuming time is so huge,but when I try to start Jenkins agent via windows command line, the consuming time is as normal as executing the batch file manually.当我在从属代理中将Jenkins代理安装为Windows服务时,消耗时间非常巨大,但是当我尝试通过Windows命令行启动Jenkins代理时,消耗时间与手动执行批处理文件一样正常。

My env:我的环境:

  • master: CentOS7主控:CentOS7
  • slave agent: win 7奴隶特工:赢7

And I also test this case in a slave agent of win 10 for comparison.并且我也在win 10的一个slave agent上测试了这个案例进行对比。 The time executing via Jenkins is approximately the same as executing the batch file manually on the agent machine.通过 Jenkins 执行的时间与在代理机器上手动执行批处理文件的时间大致相同。

So I guess this is the compatibility issue between win 7 and Jenkins.所以我猜这是win 7和Jenkins之间的兼容性问题。 But for that the Jenkins official said that Jenkins not support win 7 anymore (Microsoft does not support Windows 7), we temporarily put it aside.但是对于Jenkins官方说Jenkins不再支持win 7(微软不支持Windows 7),我们暂时搁置了。

Anyway we find a way to conquer this.无论如何,我们找到了克服这一点的方法。 Hope this will help you for similar scenario.希望这对您类似的情况有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM