This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: array sorting checked in


hunt wrote:

> [...] I checked in several new functions to the runtime.
> _stp_map_sort(MAP map, int keynum, int dir) [...]

OK.  It seems to me that the most straightforward way to expose this
in the language would be as a modifier for the "foreach" statement,
something like:

        foreach ([x,y] in sort(array)) {
          do_something_with (array[x,y])
          if (i++ > 10) break
        }

A related modifier could serve as an iteration count limiter, which
would presumably save sorting time.  Given the implementation's likely
performance, it would be wise to penalize sorting by an extra
actioncount, to represent its cost.

Adding a plain "sort <array>" operation would be of only limited
applicability, considering the possibility of concurrent/subsequent
modifications, invalidating the sorted property.  foreach should holds
a lock (but see bug #1275) on the array during iteration, which if
finagled properly, would protect the sorted property for the duration
of iteration.


- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]