如何从 Hudson CI API 获得更好的性能?

发布于 2024-10-12 10:01:14 字数 396 浏览 4 评论 0原文

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

我目前提出的解决方案是在客户端进行一些大量的缓存。构建数据不会改变,因此事情变得更加容易。但这仍然需要大量编码。

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

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掐死时间 2024-10-19 10:01:14

使用tree查询参数比在深度=2查询快得多。根据 Hudson 内置 API 文档(请参阅 http:// 下的控制获取的数据量 hudson/api/),tree 比exclusion更高效,因为服务器不会生成然后丢弃数据。

我认为以下 URL 适用于您问题中的查询:

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

在我的系统上有 40 个左右的作业:

$ 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

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]]

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文