How to get a better performance from Hudson CI API?
Asked Answered
H

1

2

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.

Hegel answered 18/1, 2011 at 9:16 Comment(0)
R
3

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
Reproduce answered 19/1, 2011 at 18:18 Comment(3)
Thanks! Apparently it's in a later version than we have at work, that's why I missed it. I'll have to talk about an upgrade.Hegel
@Vilx yup, according to the Hudson changelog, tree was introduced in 1.367. There were also some important security fixes in Hudson around that time -- just in case you more reasons to upgrade :)Reproduce
Heh, I asked, and they upgraded! And, yes, the tree parameter is ideal! Much thanks!Hegel

© 2022 - 2024 — McMap. All rights reserved.