| Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
* Increase trace entry to 64-bytes.
The following patch increases the trace entry to 64-bytes, still a
proper multiple of the shared memory window size. While we have doubled
the entry size the on-disk format is still smaller than the ASCII
version. In the future we may wish to add variable sized records, but
for now the simplicity of this method works well.
With the extra bytes we are going to:
- Record internal size information for incoming (free) and outgoing
chunks (malloc, calloc, realloc, etc).
- Simplifies accounting of RSS usage and provides an extra cross check
between malloc<->free based on internal chunk sizes.
- Record alignment information for memalign, and posix_memalign.
- Continues to extend the tracer to the full API.
- Leave 128-bits of padding for future path uses.
- Useful for more path information.
Additionally __MTB_TYPE_POSIX_MEMALIGN is added for the sole purpose of
recording the trace only so that we can hard-fail in the workload
converter when we see such an entry.
Lastly C_MEMALIGN, C_VALLOC, C_PVALLOC, and C_POSIX_MEMALIGN are added
for workload entries for the sake of completeness.
Builds on x86_64, capture looks good and it works.
* Teach trace_dump about the new entries.
The following patch teaches trace_dump about the new posix_memalign
entry. It also teaches trace_dump about the new size2 and size3 fields.
Tested by tracing a program that uses malloc, free, and memalign and
verifying that the extra fields show the expected chunk sizes, and
alignments dumped with trace_dump.
Tested on x86_64 with no apparently problems.
* Teach trace2wl and trace_run about new entries
(a) trace2wl changes:
The following patch teaches trace2wl how to output entries for valloc
and pvalloc, it does so exactly the same way it does for malloc, since
from the perspective of the API they are identical.
Additionally trace2wl is taught how to output an event for memalign,
storing alignment and size in the event record.
Lastly posix_memalign is detected and the converter aborted if it's
seen. It is my opinion that we should not ignore this data during
conversion. If we see a need for it we should implement it later.
(b) trace_run changes:
Some cosmetic cleanup in printing 'pthread_t' which is always an address
of the struct pthread structure in memory, so to make debugging easier
we should print the value as a hex pointer.
Teach the simulator how to run memalign. With the newly recorded
alignment information we double check that the resulting memory is
correctly aligned.
We do not implement valloc and pvalloc, they will abort the simulator.
This is incremental progress.
Tested on x86_64 by converting and running a multithreaded test
application that calls calloc, malloc, free, and memalign.
* Disable recursive traces and save new data.
(a) Adds support for disabling recurisvely recorded traces e.g. realloc
calling malloc no longer produces a realloc and malloc trace event. We
solve this by using a per-thread variable to disable new trace creation,
but allow path bits to be set. This lets us record the code paths
taken, but only record one public API event.
(b) Save internal chunk size information into trace events for all APIs.
The most important is free where we record the free size, this allows
easier tooling to compute running idea RSS values.
Tested on x86_64 with some small applications and test programs.
|
|
In order to not lose records, or need to guess ahead of time how
many records you need, this switches to a mmap'd file for the trace
buffer, and grows it as needed.
The trace2dat perl script is replaced with a trace2wl C++ program
that runs a lot faster and can handle the binary format.
|
|
Expand the comments in mtrace-ctl.c to better explain how to use
this tracing controller. The new docs assume the SO is built
and installed.
Build fixed for trace_run.c
Additional build pedantry to let trace_run.c be built with more
warnings/errors turned on.
Build/install trace_run and trace2dat
trace2dat takes dump files from mtrace-ctl.so and turns them into
mmap'able data files for trace_run, which "plays back" the logged
calls.
32-bit compatibility
Redesign tcache macros to account for differences between 64 and
32 bit systems.
|
|
Core algorithm changes:
* Per-thread cache is refilled from existing fastbins and smallbins
instead of always needing a bigger chunk.
* Caches are linked, and cache is cleaned up when the thread exits
(incomplete for now, needed framework for chunk scanner).
* Fixes to mutex placement - needed to sync chunk headers across
threads.
Enabling the per-thread cache (tcache) gives about a 20-30% speedup at
a 20-30% memory cost (due to fragmentation). Still working on that :-)
Debugging helpers (temporary):
* __malloc_scan_chunks() calls back to the app for each chunk in each
heap.
* _m_printf() helper for "safe" printing within malloc
* Lots of calls to the above, commented out, in case you need them.
* trace_run scans leftover chunks too.
|
|
|
|
Add hooks to pvalloc and calloc
Add path flag for when a call is handled via a hook function
|
|
Change head pointer to be total calls; adjust users to modulo after
incrementing.
Use mmap() instead of sbrk().
Split environment variables so count and file can be specified.
Export trace hooks so mtrace-ctl can be built against libc.so.
Allow NULL to be passed to __mtrace_get_trace_buffer.
Add some error handling to mtrace-ctl.
|
|
First attempt at a low-overhead tracing feature. To enable, you
build mtrace-ctl.c into a .so and LD_PRELOAD it. That uses a
private API to set up a trace buffer, and calls to malloc et all
fill in records in the trace buffer. At program exit, mtrace-ctl
reads the buffer and stores the data on disk.
Internally, the only contention point is the atomic update of the
buffer head pointer. Once aquired, each thread fills in its
record without needing locks.
|