Commit Graph

1745 Commits

Author SHA1 Message Date
Andrew McCreight
68868f579a Bug 1904685 - Output the addresses in dmd.py, when present. r=pbone
With heap scan mode, the DMD log includes the address of every block.
This patch includes the addresses in the output, if they are present.
This is useful when no cycle collected objects are leaked.

Differential Revision: https://phabricator.services.mozilla.com/D214880
2024-06-26 23:25:15 +00:00
Iulian Moraru
6c7b88f2f5 Backed out changeset 55f412f509f8 (bug 1904685) for causing xpcshell failures on test_dmd.js. CLOSED TREE 2024-06-27 01:02:57 +03:00
Andrew McCreight
6848b826e0 Bug 1904685 - Output the addresses in dmd.py, when present. r=pbone
With heap scan mode, the DMD log includes the address of every block.
This patch includes the addresses in the output, if they are present.
This is useful when no cycle collected objects are leaked.

Differential Revision: https://phabricator.services.mozilla.com/D214880
2024-06-26 18:10:29 +00:00
Paul Bone
065f8db2ee Bug 1874022 - pt 14. Seperate arena and non-arena code paths in PHC r=glandium
The Arena ID is wrapped in a Maybe, the construction of Nothing() shows up
in profiles.  By testing the maybe we show the compiler that it can optimise
away the construction of Nothing when inlining this code.

Differential Revision: https://phabricator.services.mozilla.com/D207680
2024-06-26 02:06:42 +00:00
Paul Bone
29a4b0695d Bug 1874022 - pt 13. Inline the hot path for free r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D214778
2024-06-26 02:06:42 +00:00
Paul Bone
f35b220ed9 Bug 1874022 - pt 12. Inline the hot path from MaybePageAlloc r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D207678
2024-06-26 02:06:41 +00:00
Paul Bone
7c1ac112d0 Bug 1874022 - pt 11. Improve cache locality r=glandium
+ Move sNow into the PHC class and put it next to mMutex, they're
   frequently modified together.

 + Reorganise PHC fields to place frequently-updated-together fields
   together, and separate them from the seldom-updated fields.

 + The only static fields remaining are write-once.

Differential Revision: https://phabricator.services.mozilla.com/D210468
2024-06-26 02:06:41 +00:00
Paul Bone
064646e2bb Bug 1874022 - pt 10. maybe_init() uses a single memory access r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D207677
2024-06-26 02:06:40 +00:00
Paul Bone
9374059263 Bug 1874022 - pt 9. Reduce the cost of updating sAllocDelay r=glandium
This change optimises the PHC hot path by reducing updates to sAllocDelay
and sNow:
 * tlsAllocDelay has been created to create thread-local allocation delays,
   when they expire then the shared sAllocDelay is checked.
 * sNow is updated only when not executing the fast path.

This change also:
 * Previously the thread that saw sAllocDelay == 0 would be the one to make
   the allocation, the ReleaseAquire semantics ensured that exactly one
   thread would see this.  Now all threads that see sAllocDelay <= 0 will
   attempt a PHC allocation, this is later checked by atomically resetting
   sAllocDelay.
 * Removes the logic that checks if the delay has wrapped
   while PHC was disabled on the current thread.  This isn't needed anymore
   because we now make PHC allocations for all sAllocDelay < 0, assuming
   that threads are disabled for less than UINT32_MAX/2 allocations.
 * Moves ShouldMakeNewAllocations out of the hot-path.

Differential Revision: https://phabricator.services.mozilla.com/D206469
2024-06-26 02:06:39 +00:00
Paul Bone
12f59050ca Bug 1874022 - pt 8. Add a proof of lock argument to ResetRNG r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D210467
2024-06-26 02:06:39 +00:00
Paul Bone
e8e18ea583 Bug 1874022 - pt 7. Move the mutex to a member variable r=glandium
This patch co-locates mMutex with the data it protects and is accessed
together.  It was previously located with global write-once data and updates
to `sMutex` were caused cache misses for `sPHC`.

Making `mMutex` a member variable also makes sense conceptually.

Differential Revision: https://phabricator.services.mozilla.com/D210466
2024-06-26 02:06:39 +00:00
Paul Bone
2778c556e1 Bug 1874022 - pt 6. Rename the GConst structure and move gConst r=glandium
Rename this structure to PHCRegion and move its instance into PHC.

Differential Revision: https://phabricator.services.mozilla.com/D210465
2024-06-26 02:06:38 +00:00
Paul Bone
2194e7b0de Bug 1874022 - pt 5. Fix some outdated comments r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D210464
2024-06-26 02:06:38 +00:00
Paul Bone
1a8ed74a5b Bug 1874022 - pt 4. Rename the GMut structure and move gMut to a static member r=glandium
I know this and some of the other refactoring patches are going to make
things more verbose (eg PHC::sPHC-> prefixing everything).  I intend to
follow up later and move more of PHC's code into the PHC class which will
then reduce the need for those pointers and scopes.

Differential Revision: https://phabricator.services.mozilla.com/D210463
2024-06-26 02:06:37 +00:00
Paul Bone
9f2d458e61 Bug 1874022 - pt 3. Move sAllocDelay into GMut r=glandium
This and the refactoring changes to follow are moving more of PHC's data
into one class.  From within there we can group it by how its accessed and
control which data is nearby other data to control cache line sharing.

sAllocDelay is always initialised by the GMut() constructor.  It is later
re-initialised from SetState() but that could be after PHC is already
active.

Differential Revision: https://phabricator.services.mozilla.com/D206468
2024-06-26 02:06:37 +00:00
Paul Bone
ea6f3a98ad Bug 1874022 - pt 2. Move sNow into GMut r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D206467
2024-06-26 02:06:36 +00:00
Paul Bone
cec1e05f90 Bug 1874022 - pt 1. Remove the GTls structure r=glandium
Currently we have 3 structures containing mutable data seperated by their
lock-safe behaviour (locked, atomic and TLS). I'd prefer to associate
structures by what they mean. This patch moves the `tlsIsDisabled`
variable, the only one in `GTls` into `GMutable` and removes the `GTls`
class.

Differential Revision: https://phabricator.services.mozilla.com/D206466
2024-06-26 02:06:35 +00:00
Sandor Molnar
10e7fbf7a5 Backed out 4 changesets (bug 1875768) for causing cppunittest-1proc failures CLOSED TREE
Backed out changeset add6151e17ee (bug 1875768)
Backed out changeset 01fa7e793e87 (bug 1875768)
Backed out changeset 99f0bce25b22 (bug 1875768)
Backed out changeset f6847957c1cc (bug 1875768)
2024-06-07 08:18:50 +03:00
Paul Bone
4c3610fd24 Bug 1875768 - Call the appropriate postfork handler on MacOS r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D212231
2024-06-07 01:34:58 +00:00
Paul Bone
e56ae17ca5 Bug 1875768 - Clear mMainThreadId after a fork in the child r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D212230
2024-06-07 01:34:58 +00:00
Paul Bone
0d9bba0bc3 Bug 1875768 - Run PostForkMainThread before iterating the arenas r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D212229
2024-06-07 01:34:58 +00:00
Paul Bone
680843ba36 Bug 1875768 - Use pthread_equal in IsOnMainThread and MaybeMutex r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D212228
2024-06-07 01:34:57 +00:00
Otto Länd
b246c3b467 Bug 1760256: apply code formatting via Lando
# ignore-this-changeset
2024-06-06 05:04:19 +00:00
Paul Bone
b1be58f031 Bug 1760256 - Update a comment to help clarify meaning r=glandium DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D142311
2024-06-06 05:01:39 +00:00
Paul Bone
3d75744945 Bug 1760256 - Update out-of-date comment r=glandium DONTBUILD
This comment refers to a definition that has moved.  Update it to point to
the new location.

Differential Revision: https://phabricator.services.mozilla.com/D139803
2024-06-06 05:01:39 +00:00
Mike Hommey
3aa9a0a780 Bug 1872320 - Fix --enable-project=memory build. r=pbone
Differential Revision: https://phabricator.services.mozilla.com/D211796
2024-05-28 01:13:59 +00:00
serge-sans-paille
ae07881baa Bug 1883940 - Replace MOZ_CXX11 autoconf macro by a moz.configure check r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D203781
2024-05-18 07:10:57 +00:00
Mike Hommey
b0fb715ec7 Bug 1895579 - Better distinguish between MaybePageRealloc return values. r=pbone
Allowing caller to distinguish between PHC not handling the realloc, and
OOM.

Differential Revision: https://phabricator.services.mozilla.com/D209764
2024-05-16 02:22:13 +00:00
serge-sans-paille
b9f78f0cc2 Bug 1883615 - Move libdl checks to moz.configure and make libdl dependencies explicit r=glandium
The -ldl flag was previously set globally, it's now set for the libs
that use it.

Also rationalize the difference between HAVE_DLOPEN and HAVE_DLFCN_H.

Differential Revision: https://phabricator.services.mozilla.com/D203594
2024-05-15 20:29:07 +00:00
Tamas Szentpeteri
22c92af506 Backed out 3 changesets (bug 1883720, bug 1883719, bug 1883615) for causing multiple failures. CLOSED TREE
Backed out changeset 495b9e84ba9d (bug 1883720)
Backed out changeset 5a89cbc54dd2 (bug 1883615)
Backed out changeset 9d075e352b0e (bug 1883719)
2024-05-15 13:30:17 +03:00
serge-sans-paille
863475a670 Bug 1883615 - Move libdl checks to moz.configure and make libdl dependencies explicit r=glandium
The -ldl flag was previously set globally, it's now set for the libs
that use it.

Also rationalize the difference between HAVE_DLOPEN and HAVE_DLFCN_H.

Differential Revision: https://phabricator.services.mozilla.com/D203594
2024-05-15 07:47:55 +00:00
Joel Maher
64e5693772 Bug 1894551 - remove old win/aarch64 references in gtest moz.build files. r=RyanVM,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D209182
2024-05-02 12:17:06 +00:00
Paul Bone
fe67a785a1 Bug 1891918 - Update mozjemalloc's kCacheLineSize for Apple Silicon r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D207675
2024-04-18 05:13:15 +00:00
Tamas Szentpeteri
a86fd1fb23 Backed out changeset 4309f75eaa90 (bug 1883615) for causing build bustages related to check_symbol_in_libs. CLOSED TREE 2024-04-17 12:57:02 +03:00
serge-sans-paille
469e6b7b31 Bug 1885334 - Change the signature of FdPrintf to use a platform-dependently-sized argument type r=glandium
That way we avoid some spurious casts

Differential Revision: https://phabricator.services.mozilla.com/D204648
2024-04-17 09:36:13 +00:00
serge-sans-paille
78ac6a6ccf Bug 1883615 - Move libdl checks to moz.configure and make libdl dependencies explicit r=glandium
The -ldl flag was previously set globally, it's now set for the libs
that use it.

Also rationalize the difference between HAVE_DLOPEN and HAVE_DLFCN_H.

Differential Revision: https://phabricator.services.mozilla.com/D203594
2024-04-17 09:33:00 +00:00
Paul Bone
c37988e025 Bug 1888326 - Advance the chunk index after committing pages r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D205971
2024-04-04 00:03:27 +00:00
Mike Hommey
8b7fc2dba5 Bug 1884054 - Stop wrapping HeapAlloc-family of functions. r=pbone
The functions were wrapped in bug 1280578 mainly for rust, which used
these functions for its global allocator. However, that use case went
away with bug 1514122, where we've set up our own global allocator for
rust that calls the malloc-family of functions directly instead.

Back in that bug, we left the HeapAlloc wrapping for other use cases,
but there are few of them left, but we're now hitting another problem,
where we actually do want to be able to HeapFree pointers that might
have been allocated by system libraries, and the wrapping is getting
on the way of this actually working.

Differential Revision: https://phabricator.services.mozilla.com/D205788
2024-03-28 04:02:03 +00:00
Paul Bone
2edc0f7892 Bug 1885466 - Rename jemalloc_stats::page_cache to pages_dirty r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D204724
2024-03-28 02:41:09 +00:00
Paul Bone
d1cccd9945 Bug 1857841 - pt 10. Tighten an assertion r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D203573
2024-03-19 01:42:44 +00:00
Paul Bone
a0f64f2204 Bug 1857841 - pt 8. Use CHUNK_MAP_FRESH for double-purged pages r=glandium
Using CHUNK_MAP_FRESH for double purged pages is better than overloading
the CHUNK_MAP_DECOMMITTED bit with two different semantics.  It also allows
us to simplify some code.

Differential Revision: https://phabricator.services.mozilla.com/D203571
2024-03-19 01:42:44 +00:00
Paul Bone
02fb924e9b Bug 1857841 - pt 9. Count fresh and madvised memory separately r=glandium
This memory was previously measured as part of committed memory.  However
depending on the OS it will often not be committed.  It's more accurate to
count it separately as part of mozjemalloc's cache of unused pages.

This patch adds counters for both fresh and madvised memory and no-longer
counts either as "committed" as it previously did.

This has the side effect of changing decisions based on the size of this
cache such as when to purge memory.

Differential Revision: https://phabricator.services.mozilla.com/D200415
2024-03-19 01:42:43 +00:00
Paul Bone
709bdf9e73 Bug 1857841 - pt 7. Also amortise VirtualAlloc in SplitRun() r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D195515
2024-03-19 01:42:43 +00:00
Paul Bone
2e587031ab Bug 1857841 - pt 6. Commit more pages than necessary to amortise costs r=glandium
This breaks the old invariant that there are no committed pages that aren't
either allocated or dirty.  There is now also new code in DeallocChunk that
counts the number of "fresh" committed pages and adjusts mStats.committed.

Differential Revision: https://phabricator.services.mozilla.com/D195514
2024-03-19 01:42:42 +00:00
Paul Bone
bc4ccb1adf Bug 1857841 - pt 5. Simplify decommit logic in SplitRun() r=glandium
The decommit logic is now only used when MALLOC_DECOMMIT is defined.  The other
page bits ( CHUNK_MAP_MADVISED and CHUNK_MAP_FRESH) are cleared when the page
is initialised.  This avoids leaving the chunk map in an inconsistent state if
pages_commit should fail.

These changes will make some following patches simpler.

Differential Revision: https://phabricator.services.mozilla.com/D200414
2024-03-19 01:42:42 +00:00
Paul Bone
2568695793 Bug 1857841 - pt 4. Don't decommit then recommit pages in InitChunk r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D195513
2024-03-19 01:42:41 +00:00
Paul Bone
71f4a9c395 Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
Also re-write the descriptions of the page kinds.

Differential Revision: https://phabricator.services.mozilla.com/D203570
2024-03-19 01:42:41 +00:00
Paul Bone
4ca2947b0f Bug 1857841 - pt 2. Remove obsolete comment r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D200413
2024-03-19 01:42:41 +00:00
Paul Bone
4189799792 Bug 1857841 - pt 1. Modernise variable declarations in SplitRun r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D195511
2024-03-19 01:42:40 +00:00
Paul Bone
6f61852dcb Bug 1884996 - Avoid reenterant malloc in PHC's RNG r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D204575
2024-03-15 00:53:17 +00:00