summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-02-18jemalloc: always assume overcommitting memoryPark Ju Hyung
Minor optimization Change-Id: I5be07492bad39e8b358cb6f820d5c580d560c829 Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
2022-02-18jemalloc: remove THP supportPark Ju Hyung
This is not explored on Android properly and no one should use it until proper scientific testing. Moreover, THP is broken with all recent Qualcomm devices due to speculative page faults. Change-Id: I1c1e4f296c7895f5288cdb816f42340ea85826b4 Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
2022-02-18jemalloc: disable config parsing altogetherPark Ju Hyung
This is never used on Android. Remove it for faster initialization and lighter libc.so. Change-Id: Ifa54266b3d488f0b4a6301274ff114431fbe4112 Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
2021-10-11Update Android extension functions for jemalloc 5.2.1Danny Lin
malloc_iterate and mallinfo need to be updated to accomodate upstream changes. Change-Id: Iae187f1ca442e0f8c3041ed67474d7d979085b0b
2021-10-11Merge tag '5.2.1' into HEADDanny Lin
Release Change-Id: I269b861cb81499b78f13dc2e88827f13ef5a207d
2019-11-08Change je_iterate to je_malloc_iterate.Christopher Ferris
Match the name that bionic expects. Test: Compiles. Change-Id: I2ad4a6e7ee6c2831cc4b1c5b834c2d5334164d3b
2019-08-01Sanity check on prof dump buffer size.Qi Wang
2019-07-30Quick fix for prof log printingYinan Zhang
The emitter APIs used were incorrect, a side effect of which was extra lines being printed.
2019-07-29Limit to exact fit on Windows with retain off.Qi Wang
W/o retain, split and merge are disallowed on Windows. Avoid doing first-fit which needs splitting almost always. Instead, try exact fit only and bail out early.
2019-07-29Revert "Refactor prof log"Qi Wang
This reverts commit 7618b0b8e458d9c0db6e4b05ccbe6c6308952890.
2019-07-29Revert "Refactor profiling"Qi Wang
This reverts commit 0b462407ae84a62b3c097f0e9f18df487a47d9a7.
2019-07-29Refactor profilingYinan Zhang
Refactored core profiling codebase into two logical parts: (a) `prof_data.c`: core internal data structure managing & dumping; (b) `prof.c`: mutexes & outward-facing APIs. Some internal functions had to be exposed out, but there are not that many of them if the modularization is (hopefully) clean enough.
2019-07-29Refactor prof logYinan Zhang
`prof.c` is growing too long, so trying to modularize it. There are a few internal functions that had to be exposed but I think it is a fair trade-off.
2019-07-25Add indent to individual options for confirm_conf.Qi Wang
2019-07-24Invoke arena_dalloc_promoted() properly w/o tcache.Qi Wang
When tcache was disabled, the dalloc promoted case was missing.
2019-07-24Optimize max_active_fit in first_fit.Qi Wang
Stop scanning once reached the first max_active_fit size.
2019-07-24Track the leaked VM space via the abandoned_vm counter.Qi Wang
The counter is 0 unless metadata allocation failed (indicates OOM), and is mainly for sanity checking.
2019-07-23extent_dalloc instead of leak when register fails.Qi Wang
extent_register may only fail if the underlying extent and region got stolen / coalesced before we lock. Avoid doing extent_leak (which purges the region) since we don't really own the region.
2019-07-23Avoid leaking extents / VM when split is not supported.Qi Wang
This can only happen on Windows and with opt.retain disabled (which isn't the default). The solution is suboptimal, however not a common case as retain is the long term plan for all platforms anyway.
2019-07-23Implement retain on Windows.Qi Wang
The VirtualAlloc and VirtualFree APIs are different because MEM_DECOMMIT cannot be used across multiple VirtualAlloc regions. To properly support decommit, only allow merge / split within the same region -- this is done by tracking the "is_head" state of extents and not merging cross-region. Add a new state is_head (only relevant for retain && !maps_coalesce), which is true for the first extent in each VirtualAlloc region. Determine if two extents can be merged based on the head state, and use serial numbers for sanity checks.
2019-07-18Fix posix_memalign with input size 0.Qi Wang
Return a valid pointer instead of failed assertion.
2019-07-16Fix a bug in prof_dump_writeYinan Zhang
The original logic can be disastrous if `PROF_DUMP_BUFSIZE` is less than `slen` -- `prof_dump_buf_end + slen <= PROF_DUMP_BUFSIZE` would always be `false`, so `memcpy` would always try to copy `PROF_DUMP_BUFSIZE - prof_dump_buf_end` chars, which can be dangerous: in the last round of the `while` loop it would not only illegally read the memory beyond `s` (which might not always be disastrous), but it would also illegally overwrite the memory beyond `prof_dump_buf` (which can be pretty disastrous). `slen` probably has never gone beyond `PROF_DUMP_BUFSIZE` so we were just lucky.
2019-07-16Fix logic in printingYinan Zhang
`cbopaque` can now be overriden without overriding `write_cb` in the first place. (Otherwise there would be no need to have the `cbopaque` parameter in `malloc_message`.)
2019-05-22Avoid blocking on background thread lock for stats.Qi Wang
Background threads may run for a long time, especially when the # of dirty pages is high. Avoid blocking stats calls because of this (which may cause latency spikes).
2019-05-22Add experimental.arenas.i.pactivep.Qi Wang
The new experimental mallctl exposes the arena pactive counter to applications, which allows fast read w/o going through the mallctl / epoch steps. This is particularly useful when frequent balancing is required, e.g. when having multiple manual arenas, and threads are multiplexed to them based on usage.
2019-05-22Add confirm_conf optionYinan Zhang
If the confirm_conf option is set, when the program starts, each of the four malloc_conf strings will be printed, and each option will be printed when being set.
2019-05-21Improve memory utilization testsYinan Zhang
Added tests for large size classes and expanded the tests to cover wider range of allocation sizes.
2019-05-21Fix GCC-9.1 warning with macro GET_ARG_NUMERICVaibhav Jain
GCC-9.1 reports following error when trying to compile file src/malloc_io.c and with CFLAGS='-Werror' : src/malloc_io.c: In function ‘malloc_vsnprintf’: src/malloc_io.c:369:2: error: case label value exceeds maximum value for type [-Werror] 369 | case '?' | 0x80: \ | ^~~~ src/malloc_io.c:581:5: note: in expansion of macro ‘GET_ARG_NUMERIC’ 581 | GET_ARG_NUMERIC(val, 'p'); | ^~~~~~~~~~~~~~~ ... <snip> cc1: all warnings being treated as errors make: *** [Makefile:388: src/malloc_io.sym.o] Error 1 The warning is reported as by default the type 'char' is 'signed char' and or-ing 0x80 will turn the case label char negative which will be beyond the printable ascii range (0 - 127). The patch fixes this by explicitly casting the 'len' variable as unsigned char' inside the 'switch' statement so that value of expression " '?' | 0x80 " falls within the legal values of the variable 'len'.
2019-05-15Track nfills and nflushes for arenas.i.small / large.Qi Wang
Small is added purely for convenience. Large flushes wasn't tracked before and can be useful in analysis. Large fill simply reports nmalloc, since there is no batch fill for large currently.
2019-05-15Fix assert in free fastpathYinan Zhang
rtree_szind_slab_read_fast() may have not initialized alloc_ctx.szind, unless after confirming the return is true.
2019-05-08Improve macro readability in malloc_conf_initYinan Zhang
Define more readable macros than yes and no.
2019-05-08Remove best fitDave Watson
This option saves a few CPU cycles, but potentially adds a lot of fragmentation - so much so that there are workarounds like max_active. Instead, let's just drop it entirely. It only made a difference in one service I tested (.3% cpu regression), while many services saw a memory win (also small, less than 1% mem P99)
2019-05-08Add max_active_fit to first_fitDave Watson
The max_active_fit check is currently only on the best_fit path, add it to the first_fit path also.
2019-05-02Fix miscalculating large memory allocations.Christopher Ferris
Bug: 131864803 Test: New bionic unit test to make sure that mallinfo and malloc_info match. Change-Id: Id2fd0c38106fa0150ff6baae538ecaea356296ec
2019-05-01Remove unused stats from cache structure.Christopher Ferris
Removing the stats make the whole cache structure fit in a single page. Bug: 131362671 Test: Verified that all bionic malloc benchmarks are still the same. Test: It turns out that the malloc_sql benchmarks seem to get faster. Test: Verified that after this change, it saves about 2K PSS per thread. Change-Id: I4dcd633543f05f1a9d47db175f9977ddb42188a9 (cherry picked from commit a8b52518654725e64def5ebbd0ed472100e5a522)
2019-04-29Add nonfull_slabs to bin_stats_t.Doron Roberts-Kedes
When config_stats is enabled track the size of bin->slabs_nonfull in the new nonfull_slabs counter in bin_stats_t. This metric should be useful for establishing an upper ceiling on the savings possible by meshing.
2019-04-16Enforce TLS_MODEL attribute.Qi Wang
Caught by @zoulasc in #1460. The attribute needs to be added in the headers as well.
2019-04-15Safety checks: Add a redzoning feature.David Goldblatt
2019-04-15Safety checks: Indirect through a function.David Goldblatt
This will let us share code on failure pathways.pathways
2019-04-15Safety checks: Expose config value via mallctl and stats.David Goldblatt
2019-04-15Move extra size checks behind a config flag.David Goldblatt
This will let us turn that flag into a generic "turn on runtime checks" flag that guards other functionality we have planned.
2019-04-10Separate tests for extent utilization APIYinan Zhang
As title.
2019-04-08remove compare and branch in fast path for c++ operator delete[]mgrice
Summary: sdallocx is checking a flag that will never be set (at least in the provided C++ destructor implementation). This branch will probably only rarely be mispredicted however it removes two instructions in sdallocx and one at the callsite (to zero out flags).
2019-04-04Ensure page alignment on extent_alloc.Qi Wang
This is discovered and suggested by @jasone in #1468. When custom extent hooks are in use, we should ensure page alignment on the extent alloc path, instead of relying on the user hooks to do so.
2019-04-04Add memory utilization analytics to mallctlYinan Zhang
The analytics tool is put under experimental.utilization namespace in mallctl. Input is one pointer or an array of pointers and the output is a list of memory utilization statistics.
2019-04-02Use iallocztm instead of ialloc in prof_log functions.Qi Wang
Explicitly use iallocztm for internal allocations. ialloc could trigger arena creation, which may cause lock order reversal (narenas_mtx and log_mtx).
2019-03-29Avoid check_min for opt_lg_extent_max_active_fit.Qi Wang
This fixes a compiler warning.
2019-03-29Add the missing unlock in the error path of extent_register.Qi Wang
2019-03-29Allow low values of oversize_threshold to disable the feature.Qi Wang
We should allow a way to easily disable the feature (e.g. not reserving the arena id at all).
2019-03-29Output message before aborting on tcache size-matching check.Qi Wang