--0016e644d5045d56c20464b7246b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi,

Sample patch attached for discussion. There are style and best
practice issues with this patch due to my lack of ruby experience.
Please forgive and be so kind as to suggest improvements.

It is intended to highlight some of the areas that must be considered
when making the change to provide thread-safe profiling.

The patch alters the code to make the capture of the data thread-safe
AFAICT. There may be some issues with the data fields / calculations.
I wasn't completely clear what each field in the array was supposed to
be storing. The main issue unresolved by this patch is how best to
present the information.

I've opted for showing information per-thread and a summary as well.

* Should there be a version number outputted, in case downstream tools
are doing something with this information?
* Any comments on how the information is being presented??
* Should profiling be configurable, so that it may not show output per
thread, etc.

Cheers,

James

--0016e644d5045d56c20464b7246b
Content-Type: text/x-patch; charset=US-ASCII; name="1152-2009-03-09.patch"
Content-Disposition: attachment; filename="1152-2009-03-09.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fs3pxfgl0

SW5kZXg6IGxpYi9wcm9maWxlci5yYgo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBsaWIvcHJvZmlsZXIucmIJKHJl
dmlzaW9uIDIyODY2KQorKysgbGliL3Byb2ZpbGVyLnJiCSh3b3JraW5nIGNvcHkpCkBAIC0xLDI5
ICsxLDM0IEBACiBtb2R1bGUgUHJvZmlsZXJfXwogICAjIGludGVybmFsIHZhbHVlcwotICBAQHN0
YXJ0ID0gQEBzdGFjayA9IEBAbWFwID0gbmlsCisgIEBAc3RhcnQgPSBuaWwgIyB0aGUgc3RhcnQg
dGltZSB0aGF0IHByb2ZpbGluZyBiZWdhbgorICBAQHN0YWNrcyA9IG5pbCAjIHRoZSBtYXAgb2Yg
c3RhY2sgYXJyYXlzIGtleWVkIGJ5IHRocmVhZAorICBAQG1hcHMgPSBuaWwgIyB0aGUgbWFwIG9m
IG1hcCBvZiBjYWxsIGRhdGEga2V5ZWQgYnkgdGhyZWFkLCB0aGVuIGJ5IG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