[Vm-dev] Measuring allocations

Eliot Miranda eliot.miranda at gmail.com
Thu Jun 8 01:17:25 UTC 2017


Hi Jan,

On Thu, Jun 1, 2017 at 1:17 AM, Jan Vrany <jan.vrany at fit.cvut.cz> wrote:

>
> Hi folks,
>
> Having a Spur VM, I wonder how to measure heap allocations made
> by a process executing a particular block, from within the image.
> For example, let's have following block:
>
> [
>    | a |
>
>    100 timesRepeat: [
>       a := Array new: 100
>    ]
> ].
>
> When run, this block allocates - if I'm correct - some 100 * (<object
> header size> + 4*100) bytes.
>
> Note that:
>  * Ideally, I'd like to exclude allocations made by other threads
>    but having allocations made by all threads would be OK too.
>  * Block can span multiple scavenges even oldspace collects.
>  * As shown in the example above, I need to take garbage into
>    an account.
>
> How to best measure this?
>

I just committed the code for Spur, so as soon as the CI has built VMs you
should be able to do

initialAllocation := Smalltalk vmParameterAt: 34.
self doMyThing.
bytesAllocated := (Smalltalk vmParameterAt: 34) - initialAllocation

and/or

Smalltalk vmParameterAt: 34 put: 0.
self doMyThing.
bytesAllocated := Smalltalk vmParameterAt: 34

It needs testing.  Note that it measures bytes allocated at the lowest
level I can manage so it should include everything, including hidden
allocations in the GC's marked stack and remembered tables, and the class
tables.  I *think* the code is not confused by heap growth and shrinkage.
I'd love for anyone interested to review the code (see the
VMMaker.oscog-eem.2237 commit).

Thanks, Jan
>

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170607/2e437f8e/attachment.html>


More information about the Vm-dev mailing list