VMware Cloud Community
weigon
Contributor
Contributor

src/os/solaris/kstats.c -> sigar_get_kstats()

sigar_get_kstats() from http://github.com/hyperic/sigar/blob/master/src/os/solaris/kstats.c has a few problems:

* it iterates through the kstat-structures with kstat_lookup with itself traverses through the kstat-list. This leads to a O(n^2) complexity, instead of walking the list ourself once O(n).

* it may go into a infinite loop if
* a CPU is enabled between kstat_chain_update() and the "ncpu = sysconf(_SC_NPROCESSORS_CONF)" in sigar_get_kstats() which can happen if zones are used and processors are added to the zone.

I'm working on a patch to solve this with a single linear walk over the whole kstat-chain to find all our instances that we really have in there.
0 Kudos
2 Replies
dougm_hyperic
VMware Employee
VMware Employee

Hi Jan,

Sounds good, looking forward to your patch! Let me know if I can help at all.

Thanks,
-Doug
0 Kudos
weigon
Contributor
Contributor

just wrote a little kstat walker that just prints the whole chain and looks like the CPU data here ends up at the end of the chain:

...
[408] cpu_info::misc.cpu_info0[0]
...
[654] caps::project_caps.lockedmem_project_10[0] (last entry)

For each of the kstat_lookup traverse the list again and again. My current test program does 1 run through the full list to get the full list of cpu_info's and a 2nd to copy out all the ptr's to kstat_t's. That's 2 runs no matter how many CPUs there are O(1) compared to O(n^2).
0 Kudos