如何从Hudson CI API获得更好的性能? [英] How to get a better performance from Hudson CI API?

查看:156
本文介绍了如何从Hudson CI API获得更好的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为自己编写一个与Hudson构建服务器集成的小工具.我遇到的当前障碍是性能.我想做一个简单的事情,例如列出所有工作和上一次成功构建的时间. hudson API提供了此信息,但我要么必须查询depth=2的所有内容,要么要单独查询每个作业(当前有150个).即使使用exclude,这两种方法也要花费半分钟以上的时间.对于应该快速的UI,这是不可接受的.我需要这个时间小于1秒,最好小于0.5秒.

I'm trying to write a little tool for myself that would integrate with Hudson build server. The current roadblock that I've hit is performance. I'd like to do a simple thing like have a list of all jobs and the times of last successful build. The hudson API provides this information, but I either have to query everything at depth=2 or query each job individually (there's 150 of them currently). Even with exclude either approach takes over half a minute. This is unacceptable for a UI that should be snappy. I'd need this time to be below 1s, preferably below 0.5s.

我想出的当前解决方案是在客户端进行大量缓存.构建数据不会更改,因此使事情变得容易得多.但这仍然是很多编码.

The current solution that I've come up with is doing some heavy caching on client side. Build data doesn't change, so that makes things a lot easier. But it's still a lot of coding.

是否存在另一种快速获取此信息的方法?也许有一个可以缓存所有数据并提高API速度的插件?请注意,该工具通常将无权访问HUDSON_HOME.

Is there perhaps another way to fetch this info quickly? Perhaps there is a plugin which caches all data and enhances API speed? Note that the tool will normally NOT have access to HUDSON_HOME.

推荐答案

使用tree查询参数比在depth=2查询要快得多.根据Hudson内置的API文档(请参见 http://下的控制您提取的数据量 hudson/api/),因为服务器不生成然后丢弃数据,所以tree的效率要比排除效率高.

Using the tree query parameter is much, much faster than querying at depth=2. According to the Hudson built-in API documentation (see Controlling the amount of data you fetch under http://hudson/api/), tree is more efficient than exclude because the server doesn't generate and then discard data.

我认为以下网址可用于您所查询的问题:

I think the following URL will work for the query in your question:

http://hudson/api/xml?tree=jobs[name,lastSuccessfulBuild[number,url,timestamp]]

在具有40个工作岗位的系统上:

On my system with 40-ish jobs:

$ time curl "http://hudson/api/xml?tree=jobs\[name,lastSuccessfulBuild\[number,url,timestamp\]\]"

<hudson><job><name>Example Windows build</name>
   <lastSuccessfulBuild><number>7</number>
   <timestamp>1264806194000</timestamp>
...lots of unformatted XML...

real    0m0.166s
user    0m0.062s
sys     0m0.093s

这篇关于如何从Hudson CI API获得更好的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆