Files
palemoon27/memory/replace/logalloc
roytam1 664ef9175d import changes from `dev' branch of rmottola/Arctic-Fox:
- enable shadow warnings (93e0fb3cf8)
- more bits of  Bug 1198334 (part 1) - Replace the opt-in FAIL_ON_WARNINGS (f07e6eca96)
- Bug 1111892 - Ensure gdk_ungrab_pointer is always called in the correct process r=jimm (8bf40d8add)
- Bug 1220344 - remote some of nsSystemInfo to make it e10s ready on Android r=nchen,froydnj (365e961dfb)
- bug 1190018 - External protocol handlers don't work in e10s r=mrbkap (ff4567d517)
- Bug 1225618 - Do not capture stacks for cycle collection timeline markers; r=vporof (d734ca9d26)
- Bug 1218315 - Replace NS_LITERAL_STRING(...).get() with MOZ_UTF16(...) on xpcom. r=nfroyd (5cff917319)
- Bug 1218315 - Use L"..." instead of MOZ_UTF16(...) for MSVS2015. r=nfroyd (9f8b88f428)
- Bug 1199592 - support TV device type in UA string. r=fabrice. (2eecf7f3b4)
- Bug 1215723 - Part 1: Make DataStorage a singleton for each file name; r=keeler (be2e5947f1)
- Bug 1167693 - Ensure device and vendor IDs are zero-padded. r=mstange (6e583cbf71)
- Bug 1186817 - Replace nsBaseHashtable::EnumerateRead() calls in security/ with iterators. r=keeler (4a14f547a7)
- Bug 1215723 - Part 2: Initialize DataStorage items in the content process from the data in the parent; r=keeler (3a4d3ec7d5)
- Bug 1215723 - Part 3: Propagate updates to DataStorage from the parent process to the content processes; r=keeler (2140b412eb)
- Bug 1215723 - Part 4: Make isSecureHost and isSecureURI usable from the content process; r=keeler (c8b786ca1b)
- Bug 1215723 - Part 5: Add an automated test; r=keeler (012e820385)
- Bug 1154184 - Don't use Linux sandbox gtest dir if not building tests. r=gps (2993e27d44)
- Bug 930258 - Part 1: The file broker, and unit tests for it. r=kang f=froydnj (d3e8cab30d)
- Bug 930258 - Part 2: seccomp-bpf integration. r=kang (a40ef5e566)
- Bug 930258 - Part 3: a file broker policy for the B2G emulator. r=kang (2c0c3d55cf)
- Bug 930258 - Part 4: the PContent changes that connect the broker to its sandboxed client. r=kang r=billm (1206c3a20c)
- Bug 1168251 - Do a partial recursion when doing make -C some/path compile. r=gps (a6733048fc)
- Bug 1194951 - Suppress warnings in third-party code: pocketsphinx and sphinxbase. r=kdavis (4f679d6a1e)
- Bug 1195186 - Build media/pocketsphinx in unified mode. r=kdavis (6e6bb419e0)
- Bug 1203005 - Remove all traces of -Wdeclaration-after-statement. r=glandium. (a66d7a4760)
- bits of  Bug 1211568, land NSS_3_21_RTM (6b81926cd3)
- Bug 947753 - Make sure nsChildView::ComputeShouldAccelerate returns true even if it's called before layout lets the window know about whether it's transparent. r=smichaud (0d2980b44f)
- Bug 1162649 - Don't call setOpaque:NO or setHasShadow:NO for non-popup windows;r=mstange (6353bd2e96)
- Backed out changeset 2e731191c692 (bug 1189565) for causing bug 1201053 a=backout (e4bc37c823)
- Bug 1174703 - Add GLContextEAGL and GLContextProviderEAGL as an OpenGL provider for iOS. r=jgilbert (64c6538d7d)
- Bug 1184402 - Reset format usage authority on context lose/restore. r=jgilbert (3df2278888)
- more dupes... hackish (f432375460)
- Bug 1007975 - div with display:table exposes table semantics r=surkov (f3b389dcce)
- Bug 1159034 - Test uninitialized buffer data. - r=dvander Bug 1147441 - Add SharedArrayBuffer support to WebGL and WebGL 2. r=jgilbert, r=bzbarsky (a151e77beb)
- Bug 1184402 - Part 1: Rename GetInfo() to GetUsage() for obtaining FormatUsageInfo. r=jgilbert (efbfe39a2e)
- Bug 1184402 - Part 2: Added luminance float effective formats (2cb792990d)
- Bug 1184402 - Part 3: Add WebGL1 formats when enabling extensions. r=jgilbert (aba6beb541)
- Bug 1184402 - Part 4: Use WebGLFormat for validation in RenderbufferStorage_base. r=jgilbert (704c86386f)
- Bug 1193070 - Implement GetFramebufferAttachmentParameter. r=jgilbert (ef51efdce1)
- Bug 1188195 - always initialize WebGL2 BlitFramebuffer src/dst formats to some value. r=jgilbert (694a4d87a1)
- Bug 1143876 - Treat invalidate-framebuffer as optional for WebGL2. - r=kamidphish (53d8ef5a3f)
- Bug 1170845 - Remove WebGL2() exclusion on instanced draw divisor check. r=jgilbert (cd8d1375b3)
- Bug 1192989 - Simplify handling by ifdefing in all.js. - r=kamidphish (32a26b46c8)
- Bug 1179556 - Only call EnsureColorAttachPoints with a color attachment. r=jgilbert (8791f2e34a)
- Bug 1170893 - Return null for invalid internal format. r=kamidphish (425657b6b6)
- Bug 1225782 - Removes GlobalPropertiesAreOwn(). r=bz (a6ca6fd503)
- Bug 1225381 - ensure mozCurrentTransform is finite. r=jmuizelaar (c009040dca)
- Bug 1223740 - enforce max surface size for DrawTargetSkia. r=bas (505fe7ac3b)
- Bug 1059014 (part 2) - Remove support for reflow on zoom event pending. r=dbaron. (be2ae37e94)
- Bug 1059014 (part 3) - Remove support for pausing and resuming painting. r=dbaron. (35979215f3)
2023-02-06 08:55:00 +08:00
..

Logalloc is a replace-malloc library for Firefox (see
memory/build/replace_malloc.h) that dumps a log of memory allocations to a
given file descriptor or file name. That log can then be replayed against
Firefox's default memory allocator independently or through another
replace-malloc library, allowing the testing of other allocators under the
exact same workload.

To get an allocation log the following environment variables need to be set
when starting Firefox:
- on Linux:
  LD_PRELOAD=/path/to/liblogalloc.so
- on Mac OSX:
  DYLD_INSERT_LIBRARIES=/path/to/liblogalloc.dylib
- on Windows:
  MOZ_REPLACE_MALLOC_LIB=/path/to/logalloc.dll
- on Android:
  MOZ_REPLACE_MALLOC_LIB=/path/to/liblogalloc.so
  (see https://wiki.mozilla.org/Mobile/Fennec/Android#Arguments_and_Environment_Variables
  for how to pass environment variables to Firefox for Android)

- on all platforms:
  MALLOC_LOG=/path/to/log-file
  or
  MALLOC_LOG=number

When MALLOC_LOG is a number below 10000, it is considered as a file
descriptor number that is fed to Firefox when it is started. Otherwise,
it is considered as a file name.

As those allocation logs can grow large quite quickly, it can be useful
to pipe the output to a compression tool.

MALLOC_LOG=1 would send to Firefox's stdout, MALLOC_LOG=2 would send to
its stderr. Since in both cases that could be mixed with other output
from Firefox, it is usually better to use another file descriptor
by shell redirections, such as:

  MALLOC_LOG=3 firefox 3>&1 1>&2 | gzip -c > log.gz

(3>&1 copies the `| gzip` pipe file descriptor to file descriptor #3, 1>&2
then copies stderr to stdout. This leads to: fd1 and fd2 sending to stderr
of the parent process (the shell), and fd3 sending to gzip.)

Each line of the allocations log is formatted as follows:
  <pid> <function>([<args>])[=<result>]
where <args> is a comma separated list of values. The number of <args> and
the presence of <result> depend on the <function>.

Example log:
  18545 malloc(32)=0x7f90495120e0
  18545 calloc(1,148)=0x7f9049537480
  18545 realloc(0x7f90495120e0,64)=0x7f9049536680
  18545 posix_memalign(256,240)=0x7f9049583300
  18545 jemalloc_stats()
  18545 free(0x7f9049536680)

This log can be replayed with the logalloc-replay tool in
memory/replace/logalloc/replay. However, as the goal of that tool is to
reproduce the recorded memory allocations, it needs to avoid as much as
possible doing its own allocations for bookkeeping. Reading the logs as
they are would require data structures and memory allocations. As a
consequence, the logs need to be preprocessed beforehand.

The logalloc_munge.py script is responsible for that preprocessing. It simply
takes a raw log on its stdin, and outputs the preprocessed log on its stdout.
It replaces pointer addresses with indexes the logalloc-replay tool can use
in a large (almost) linear array of allocation tracking slots (prefixed with
'#'). It also replaces the pids with numbers starting from 1 (such as the
first seen pid number is 1, the second is 2, etc.).

The above example log would become the following, once preprocessed:
  1 malloc(32)=#1
  1 calloc(1,148)=#2
  1 realloc(#1,64)=#1
  1 posix_memalign(256,240)=#3
  1 jemalloc_stats()
  1 free(#1)

The logalloc-replay tool then takes the preprocessed log on its stdin and
replays the allocations printed there, but will only replay those with the
same process id as the first line (which normally is 1).

As the log files are simple text files, though, it is easy to separate out
the different processes log with e.g. grep, and feed the separate processes
logs to logalloc-replay.

The logalloc-replay program won't output anything unless jemalloc_stats
records appears in the log. You can expect those to be recorded when going
to about:memory in Firefox, but they can also be added after preprocessing.

Here is an example of what one can do:

  gunzip -c log.gz | python logalloc_munge.py | \
  awk '$1 == "2" { print $0 } !(NR % 10000) { print "2 jemalloc_stats()" }' | \
    ./logalloc-replay

The above command replays the allocations of process #2, with some stats
output every 10000 records.

The logalloc-replay tool itself being hooked with replace-malloc, it is possible
to set LD_PRELOAD/DYLD_INSERT_LIBRARIES/MOZ_REPLACE_MALLOC_LIB and replay a log
through a different allocator. For example:

  LD_PRELOAD=libreplace_jemalloc.so logalloc-replay < log

Will replay the log against jemalloc3 (which is, as of writing, what
libreplace_jemalloc.so contains).