[Orca-dev] orcallator.se patch to dynamically count oracleconnections

Dmitry Berezin dberezin at surfside.rutgers.edu
Fri May 28 08:47:20 PDT 2004


> Will orcallator.se work with both this patch and the workload patch
> installed?

Yes. In fact, that is how I have it setup on the server where I am testing
it.

> Can this patch be integrated into the functionality of the
> other?

Well, it should be possible, but probably not very clean. Besides, the
purpose of this (oracle) patch is a bit different from the workload patch.
_Most_ of the functionality is already available in the workload patch; the
only difference is that this one is dynamic.
I would rather keep it separate, for the following reasons - 
  Choice of static or dynamic
  Can be used independently of workload (say, if one only wants to count
oracle connections and don't care about any workloads at all)
  Can be easily "turned on/off" with #define WATCH_ORACLE

> Please fit the lines to 80 characters.  I still use 6 80 character wide
> putty's :)

No problem. (I guess I've been using 126/40 for too long).

> It would be good to have all includes included once.  Right now proc.se
> and fcntl.se are already included.  It would be good to have a single
> test like this:
> 
> #if WATCH_CPU || WATCH_ORACLE || WATCH_WEB
> #include <proc.se>

Agreed.

> +  if (init_done == 0) {			// Initialize proc_class_t
> variable
> +    refresh$(pp);
> 
> Is there any point to calling refresh$(pp); here given that it is called
>    just after this if test?
> 
> +    init_done = 1;
> +  }
> +
> +  refresh$(pp);				// Get new snapshot of all
processes
> +  for (i=0; i<ndbs; i++) {		// Reset counters

Yes. Since pp is non-active variable, SE does not automatically call its
class method as an initialization step, so I have to do this manually, since
proc_call_t has to be initialized first.
After the first "refresh$(pp);" pp.index$ is initialized with -1, so I need
to make another "refresh$(pp);" call to begin traversing process tree.

If this makes it less confusing, instead of ...

if (init_done ==0) {
  refresh$(pp);
  init_done = 1;
}
refresh$(pp);
while (pp.index$ != -1) {
  <do some work>
  refresh$(pp);
}

I could change it to ...

if (init_done ==0) {
  refresh$(pp);
  init_done = 1;
}
for (;;) {
  refresh$(pp);
  if (pp.index$ == -1) {
    break;
  }
  <do some work>
}

Although I like the first one better, I have no problem changing it.

> +        for (i=ndbs++; i>0; i--) {	// Simple bubble sort to make orca
> happy
> 
> How about using the qsort that is in stdlib.se?

Well, that's where I originally started. But...
The problem with qsort is that I have to give it an address of the array to
be sorted, but array contains structures, so the address of the first
structure would have to be taken, but SE does not allow taking addresses of
the structures. Indeed, Rich P. pointed me to some example where this kind
of stuff is being done (converting array of structures to array of 'char's
and back, etc.), but since the array to be sorted is going to be very small,
and the sorting would only be done during the first run or when the new
oracle instances are started (_not_very_often_), I decided that the overhead
and added complexity of qsort were not worth it.
Again, AFAIK it is doable, but IMHO not practical.

Actually, sorting is somewhat bigger issue. I will send a separate post
about it shortly.


  -Dmitry.





More information about the Orca-dev mailing list