Closed Bug 1867191 Opened 2 years ago Closed 10 months ago

Set the PHC memory area size from a pref

Categories

(Core :: Memory Allocator, task)

task

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox145 --- fixed

People

(Reporter: pbone, Assigned: pbone)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 4 obsolete files)

No description provided.
Depends on: 1967689

To allow the PHC arena size to be dynamic the reserved memory range may
be larger than the actual memory allocated by PHC. To keep the fast-path
as fast as possible this patch replaces the initial PtrKind() query with a
bounds check. The bounds check can be done without a lock. A later
step will determine the PtrKind.

  • Use a bounds check on the hot path for free, realloc and other
    functions that take a pointer, before calling the corresponding PHC::
    methods.

  • The PHC method must assume it has a pointer that is in-bounds, but it
    can determine the kind of the pointer with GetPtrKind().

  • Remove the Nothing PtrKind since it previously represented
    out-of-bounds pointers.

  • Add branch annotations on the hot paths.

PHC's metadata size is defined at compile-time. To relax this to
runtime we need to use a different array implementation that stores the
size in a member variable, rather than a template parameter.

Refactor how metadata size is calculated since it must capture the size
of this array. Separate methods like FragmentationBytes() and
AllocationBytes() have been merged to get a consistent read by taking
the lock only once.

The size of PHC's allocation area is now set when the metadata is
created. The kNumAllocPages symbol is removed, instead a new
NumAllocPages() function will return the length of the AllocInfo array.

The array is protected by the PHC lock so now getting the true size
of the PHC area (rather than the virtual memory reservation that it's
inside) can only be done while holding the lock. Checking the index of
an allocation during free() against the upper bound is now down after
taking the lock.

PHC uses dynamic memory allocation* and so initialising it after
mozjemalloc makes sense, the easiest way to do this is to call it late
in mozjemalloc's initialisation.

*: it always has used dynamic memory, these patches add one additional
allocation. So this change isn't really necessary.

Attachment #9496913 - Attachment description: WIP: Bug 1867191 - pt 5. Set PHC size from PHCManager → WIP: Bug 1867191 - pt 5. Add support for growing PHC's storage

This allows expanding the size of memory area used by PHC, but not
shrinking it.

Depends on: 1845655
Blocks: 1974931
Attachment #9496681 - Attachment description: WIP: Bug 1867191 - pt 2. Use a custom array implementation for PHC's metadata → Bug 1867191 - pt 2. Use a custom array implementation for PHC's metadata r=glandium
Attachment #9496682 - Attachment description: WIP: Bug 1867191 - pt 3. PHC's size is no-longer fixed at compile time → Bug 1867191 - pt 3. PHC's size is no-longer fixed at compile time r=glandium
Attachment #9496913 - Attachment description: WIP: Bug 1867191 - pt 5. Add support for growing PHC's storage → Bug 1867191 - pt 4. Add support for growing PHC's storage r=glandium
Attachment #9497597 - Attachment description: WIP: Bug 1867191 - pt 6. Control PHC's size from a pref → Bug 1867191 - pt 5. Control PHC's size from a pref r=glandium
Attachment #9497598 - Attachment description: WIP: Bug 1867191 - pt 7. Remove an unused function in PHC → Bug 1867191 - pt 6. Remove an unused function in PHC r=glandium
Attachment #9497599 - Attachment description: WIP: Bug 1867191 - pt 8. Fix a misspelt function name → Bug 1867191 - pt 7. Fix a misspelt variable name r=glandium
Attachment #9497600 - Attachment description: WIP: Bug 1867191 - pt 9. Also support shrinking the PHC area → Bug 1867191 - pt 8. Also support shrinking the PHC area r=glandium

Comment on attachment 9496683 [details]
WIP: Bug 1867191 - pt 4. Initialise PHC from mozjemalloc

Revision D254945 was moved to bug 1974931. Setting attachment 9496683 [details] to obsolete.

Attachment #9496683 - Attachment is obsolete: true
Attachment #9497598 - Attachment is obsolete: true
Attachment #9497600 - Attachment description: Bug 1867191 - pt 8. Also support shrinking the PHC area r=glandium → Bug 1867191 - pt 8. Also support shrinking the PHC area

Comment on attachment 9497599 [details]
Bug 1867191 - pt 7. Fix a misspelt variable name r=glandium

Revision D255489 was moved to bug 1975689. Setting attachment 9497599 [details] to obsolete.

Attachment #9497599 - Attachment is obsolete: true
Blocks: 1975906
No longer blocks: PHC2023
Blocks: 1976162
Attachment #9497600 - Attachment description: Bug 1867191 - pt 8. Also support shrinking the PHC area → Bug 1867191 - pt 6. Also support shrinking the PHC area
Attachment #9497600 - Attachment is obsolete: true
Regressions: 1993227
QA Whiteboard: [qa-triage-done-c146/b145]
Regressions: 1969856
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: