Shopify / mruby-engine

MRuby engine is a sandboxed scripting engine.
MIT License
80 stars 18 forks source link

Moar logging about memory #8

Closed alexsnaps closed 8 years ago

alexsnaps commented 8 years ago

Adds logging about arena size (should be 4MB in our case) and hblkhd (i.e. space in mmapped regions). From dlmalloc:

      nm.arena    = sum;
      nm.ordblks  = nfree;
      nm.hblkhd   = m->footprint - sum;
      nm.usmblks  = m->max_footprint;
      nm.uordblks = m->footprint - mfree;
      nm.fordblks = mfree;
      nm.keepcost = m->topsize;
    }

Where .memory is uordblks which we've seen huge values of (~16 exabytes!), ... so that now m->footprint is hblkhd + arena

[SCRIPTS] Script.Engine.instructions=5308
[SCRIPTS] Script.Engine.memory=496960
[SCRIPTS] Script.Engine.memory_arena=4194304
[SCRIPTS] Script.Engine.memory_hblkhd=0
[SCRIPTS] Script.Engine.memory_fordblks=3697344

these last three keys are new.

singpolyma-shopify commented 8 years ago

I guess that works instead of adding a log for footprint directly? (assuming that hblkhd isn't crazy like uordblks is)

Can we also log fordblks ("mfree")?

alexsnaps commented 8 years ago

nm.uordblks = m->footprint - mfree; we have two of these...

singpolyma-shopify commented 8 years ago

@alexsnaps right, that expression is what we're trying to debug, correct? So, seeing footprint and mfree would be the goal. mfree is in fordblks

alexsnaps commented 8 years ago

I can add it explicitly, but we now have all that's needed to just do the math... Anyhow, let me add it.

singpolyma-shopify commented 8 years ago

@alexsnaps wouldn't always trust "just do the math" in this case, since we're specifically debugging a possible overflow, that's all :)

alexsnaps commented 8 years ago

ping @sgnr @singpolyma-shopify

singpolyma-shopify commented 8 years ago

:+1: