Skip to content

Commit

Permalink
Bug 1867190 - Add prefs for PHC probablities r=glandium
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D198652

UltraBlame original commit: ce5606473bf95f0899f69034525766ca9d0ed749
  • Loading branch information
marco-c committed Jan 25, 2024
1 parent c1c3bd8 commit 1e1744f
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 0 deletions.
160 changes: 160 additions & 0 deletions memory/build/PHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3678,7 +3678,10 @@ return
aRnd
&
(
uint64_t
(
aAvgDelay
)
*
2
-
Expand All @@ -3689,6 +3692,88 @@ aAvgDelay
1
;
}
constexpr
Delay
CheckProbability
(
int64_t
aProb
)
{
/
/
Limit
delays
calculated
from
prefs
to
0x80000000
this
is
the
largest
/
/
power
-
of
-
two
that
fits
in
a
Delay
since
it
is
a
uint32_t
.
/
/
The
minimum
is
2
that
way
not
every
allocation
goes
straight
to
PHC
.
return
RoundUpPow2
(
std
:
:
min
(
std
:
:
max
(
aProb
int64_t
(
2
)
)
int64_t
(
0x80000000
)
)
)
;
}
/
/
Maps
Expand Down Expand Up @@ -7234,6 +7319,48 @@ mPhcState
aState
;
}
void
SetProbabilities
(
int64_t
aAvgDelayFirst
int64_t
aAvgDelayNormal
int64_t
aAvgDelayPageReuse
)
{
MutexAutoLock
lock
(
GMut
:
:
sMutex
)
;
mAvgFirstAllocDelay
=
CheckProbability
(
aAvgDelayFirst
)
;
mAvgAllocDelay
=
CheckProbability
(
aAvgDelayNormal
)
;
mAvgPageReuseDelay
=
CheckProbability
(
aAvgDelayPageReuse
)
;
}
private
:
template
Expand Down Expand Up @@ -14770,6 +14897,39 @@ aState
)
;
}
void
SetPHCProbabilities
(
int64_t
aAvgDelayFirst
int64_t
aAvgDelayNormal
int64_t
aAvgDelayPageReuse
)
{
if
(
!
maybe_init
(
)
)
{
return
;
}
gMut
-
>
SetProbabilities
(
aAvgDelayFirst
aAvgDelayNormal
aAvgDelayPageReuse
)
;
}
}
/
/
Expand Down
12 changes: 12 additions & 0 deletions memory/build/PHC.h
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,18 @@ PHCState
aState
)
;
MOZ_JEMALLOC_API
void
SetPHCProbabilities
(
int64_t
aAvgDelayFirst
int64_t
aAvgDelayNormal
int64_t
aAvgDelayPageReuse
)
;
struct
MemoryUsage
{
Expand Down
57 changes: 57 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66759,6 +66759,63 @@ value
mirror
:
always
-
name
:
memory
.
phc
.
avg_delay
.
first
type
:
uint32_t
value
:
65536
mirror
:
always
-
name
:
memory
.
phc
.
avg_delay
.
normal
type
:
uint32_t
value
:
16384
mirror
:
always
-
name
:
memory
.
phc
.
avg_delay
.
page_reuse
type
:
uint32_t
value
:
262144
mirror
:
always
#
-
-
Expand Down
82 changes: 82 additions & 0 deletions toolkit/components/nimbus/FeatureManifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14349,6 +14349,88 @@ memory
phc
.
min_ram_mb
phcAvgDelayFirst
:
description
:
The
delay
before
the
first
PHC
allocation
type
:
int
setPref
:
branch
:
user
pref
:
memory
.
phc
.
avg_delay
.
first
phcAvgDelayNormal
:
description
:
The
delay
between
PHC
allocations
type
:
int
setPref
:
branch
:
user
pref
:
memory
.
phc
.
avg_delay
.
normal
phcAvgDelayPageReuse
:
description
:
The
delay
before
reusing
a
PHC
page
type
:
int
setPref
:
branch
:
user
pref
:
memory
.
phc
.
avg_delay
.
page_reuse
mailto
:
description
Expand Down
Loading

0 comments on commit 1e1744f

Please sign in to comment.