Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,268
Issues
4,268
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
408
Merge Requests
408
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
e1d4140b
Commit
e1d4140b
authored
Jan 18, 2018
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Improve accuracy of get/setAllocationCounter"
This reverts commit
a1a689dd
.
parent
8bb150df
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
34 additions
and
74 deletions
+34
-74
compiler/codeGen/StgCmmForeign.hs
compiler/codeGen/StgCmmForeign.hs
+2
-2
compiler/prelude/primops.txt.pp
compiler/prelude/primops.txt.pp
+0
-14
includes/rts/Threads.h
includes/rts/Threads.h
+2
-0
includes/stg/MiscClosures.h
includes/stg/MiscClosures.h
+0
-3
libraries/base/GHC/Conc/Sync.hs
libraries/base/GHC/Conc/Sync.hs
+16
-5
rts/PrimOps.cmm
rts/PrimOps.cmm
+0
-20
rts/RtsSymbols.c
rts/RtsSymbols.c
+2
-2
rts/Threads.c
rts/Threads.c
+12
-1
testsuite/tests/rts/all.T
testsuite/tests/rts/all.T
+0
-7
testsuite/tests/rts/alloccounter1.hs
testsuite/tests/rts/alloccounter1.hs
+0
-19
testsuite/tests/rts/alloccounter1.stdout
testsuite/tests/rts/alloccounter1.stdout
+0
-1
No files found.
compiler/codeGen/StgCmmForeign.hs
View file @
e1d4140b
...
...
@@ -408,8 +408,8 @@ Opening the nursery corresponds to the following code:
@
tso = CurrentTSO;
cn = CurrentNursery;
bdfree = CurrentNur
se
ry->free;
bdstart = CurrentNur
se
ry->start;
bdfree = CurrentNur
es
ry->free;
bdstart = CurrentNur
es
ry->start;
// We *add* the currently occupied portion of the nursery block to
// the allocation limit, because we will subtract it again in
...
...
compiler/prelude/primops.txt.pp
View file @
e1d4140b
...
...
@@ -2921,20 +2921,6 @@ primop TraceMarkerOp "traceMarker#" GenPrimOp
has_side_effects = True
out_of_line = True
primop GetThreadAllocationCounter "getThreadAllocationCounter#" GenPrimOp
State# RealWorld -> (# State# RealWorld, INT64 #)
{ Retrieves the allocation counter for the current thread. }
with
has_side_effects = True
out_of_line = True
primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp
INT64 -> State# RealWorld -> State# RealWorld
{ Sets the allocation counter for the current thread to the given value. }
with
has_side_effects = True
out_of_line = True
------------------------------------------------------------------------
section "Safe coercions"
------------------------------------------------------------------------
...
...
includes/rts/Threads.h
View file @
e1d4140b
...
...
@@ -43,6 +43,8 @@ StgRegTable * resumeThread (void *);
//
int
cmp_thread
(
StgPtr
tso1
,
StgPtr
tso2
);
int
rts_getThreadId
(
StgPtr
tso
);
HsInt64
rts_getThreadAllocationCounter
(
StgPtr
tso
);
void
rts_setThreadAllocationCounter
(
StgPtr
tso
,
HsInt64
i
);
void
rts_enableThreadAllocationLimit
(
StgPtr
tso
);
void
rts_disableThreadAllocationLimit
(
StgPtr
tso
);
...
...
includes/stg/MiscClosures.h
View file @
e1d4140b
...
...
@@ -468,9 +468,6 @@ RTS_FUN_DECL(stg_traceCcszh);
RTS_FUN_DECL
(
stg_clearCCSzh
);
RTS_FUN_DECL
(
stg_traceEventzh
);
RTS_FUN_DECL
(
stg_traceMarkerzh
);
RTS_FUN_DECL
(
stg_getThreadAllocationCounterzh
);
RTS_FUN_DECL
(
stg_setThreadAllocationCounterzh
);
/* Other misc stuff */
// See wiki:Commentary/Compiler/Backends/PprC#Prototypes
...
...
libraries/base/GHC/Conc/Sync.hs
View file @
e1d4140b
...
...
@@ -105,7 +105,6 @@ import Data.Maybe
import
GHC.Base
import
{-#
SOURCE
#-
}
GHC
.
IO
.
Handle
(
hFlush
)
import
{-#
SOURCE
#-
}
GHC
.
IO
.
Handle
.
FD
(
stdout
)
import
GHC.Int
import
GHC.IO
import
GHC.IO.Encoding.UTF8
import
GHC.IO.Exception
...
...
@@ -195,16 +194,18 @@ instance Ord ThreadId where
--
-- @since 4.8.0.0
setAllocationCounter
::
Int64
->
IO
()
setAllocationCounter
(
I64
#
i
)
=
IO
$
\
s
->
case
setThreadAllocationCounter
#
i
s
of
s'
->
(
#
s'
,
()
#
)
setAllocationCounter
i
=
do
ThreadId
t
<-
myThreadId
rts_setThreadAllocationCounter
t
i
-- | Return the current value of the allocation counter for the
-- current thread.
--
-- @since 4.8.0.0
getAllocationCounter
::
IO
Int64
getAllocationCounter
=
IO
$
\
s
->
case
getThreadAllocationCounter
#
s
of
(
#
s'
,
ctr
#
)
->
(
#
s'
,
I64
#
ctr
#
)
getAllocationCounter
=
do
ThreadId
t
<-
myThreadId
rts_getThreadAllocationCounter
t
-- | Enables the allocation counter to be treated as a limit for the
-- current thread. When the allocation limit is enabled, if the
...
...
@@ -241,6 +242,16 @@ disableAllocationLimit = do
ThreadId
t
<-
myThreadId
rts_disableThreadAllocationLimit
t
-- We cannot do these operations safely on another thread, because on
-- a 32-bit machine we cannot do atomic operations on a 64-bit value.
-- Therefore, we only expose APIs that allow getting and setting the
-- limit of the current thread.
foreign
import
ccall
unsafe
"rts_setThreadAllocationCounter"
rts_setThreadAllocationCounter
::
ThreadId
#
->
Int64
->
IO
()
foreign
import
ccall
unsafe
"rts_getThreadAllocationCounter"
rts_getThreadAllocationCounter
::
ThreadId
#
->
IO
Int64
foreign
import
ccall
unsafe
"rts_enableThreadAllocationLimit"
rts_enableThreadAllocationLimit
::
ThreadId
#
->
IO
()
...
...
rts/PrimOps.cmm
View file @
e1d4140b
...
...
@@ -2495,23 +2495,3 @@ stg_traceMarkerzh ( W_ msg )
return
();
}
stg_getThreadAllocationCounterzh
()
{
// Account for the allocation in the current block
W_
offset
;
offset
=
Hp
-
bdescr_start
(
CurrentNursery
);
return
(
StgTSO_alloc_limit
(
CurrentTSO
)
-
offset
);
}
stg_setThreadAllocationCounterzh
(
I64
counter
)
{
// Allocation in the current block will be subtracted by
// getThreadAllocationCounter#, so we have to offset any existing
// allocation here. See also openNursery/closeNursery in
// compiler/codeGen/StgCmmForeign.hs.
W_
offset
;
offset
=
Hp
-
bdescr_start
(
CurrentNursery
);
StgTSO_alloc_limit
(
CurrentTSO
)
=
counter
+
offset
;
return
();
}
rts/RtsSymbols.c
View file @
e1d4140b
...
...
@@ -744,6 +744,8 @@
SymI_HasProto(rts_isProfiled) \
SymI_HasProto(rts_isDynamic) \
SymI_HasProto(rts_setInCallCapability) \
SymI_HasProto(rts_getThreadAllocationCounter) \
SymI_HasProto(rts_setThreadAllocationCounter) \
SymI_HasProto(rts_enableThreadAllocationLimit) \
SymI_HasProto(rts_disableThreadAllocationLimit) \
SymI_HasProto(rts_setMainThread) \
...
...
@@ -894,8 +896,6 @@
SymI_HasProto(stg_traceCcszh) \
SymI_HasProto(stg_traceEventzh) \
SymI_HasProto(stg_traceMarkerzh) \
SymI_HasProto(stg_getThreadAllocationCounterzh) \
SymI_HasProto(stg_setThreadAllocationCounterzh) \
SymI_HasProto(getMonotonicNSec) \
SymI_HasProto(lockFile) \
SymI_HasProto(unlockFile) \
...
...
rts/Threads.c
View file @
e1d4140b
...
...
@@ -165,8 +165,19 @@ rts_getThreadId(StgPtr tso)
}
/* ---------------------------------------------------------------------------
*
Enabling and disabl
ing the thread allocation limit
*
Getting & sett
ing the thread allocation limit
* ------------------------------------------------------------------------ */
HsInt64
rts_getThreadAllocationCounter
(
StgPtr
tso
)
{
// NB. doesn't take into account allocation in the current nursery
// block, so it might be off by up to 4k.
return
PK_Int64
((
W_
*
)
&
(((
StgTSO
*
)
tso
)
->
alloc_limit
));
}
void
rts_setThreadAllocationCounter
(
StgPtr
tso
,
HsInt64
i
)
{
ASSIGN_Int64
((
W_
*
)
&
(((
StgTSO
*
)
tso
)
->
alloc_limit
),
i
);
}
void
rts_enableThreadAllocationLimit
(
StgPtr
tso
)
{
...
...
testsuite/tests/rts/all.T
View file @
e1d4140b
...
...
@@ -382,10 +382,3 @@ test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
test
('
T13832
',
exit_code
(
1
),
compile_and_run
,
['
-threaded
'])
test
('
T13894
',
normal
,
compile_and_run
,
[''])
test
('
T14497
',
normal
,
compile_and_run
,
['
-O
'])
test
('
alloccounter1
',
normal
,
compile_and_run
,
[
# avoid allocating stack chunks, which counts as
# allocation and messes up the results:
'
-with-rtsopts=-k1m
'
])
testsuite/tests/rts/alloccounter1.hs
deleted
100644 → 0
View file @
8bb150df
module
Main
where
import
Control.Exception
import
Control.Monad
import
Data.List
import
System.Mem
main
=
do
let
testAlloc
n
=
do
let
start
=
999999
setAllocationCounter
start
evaluate
(
last
[
1
..
n
])
c
<-
getAllocationCounter
-- print (start - c)
return
(
start
-
c
)
results
<-
forM
[
1
..
1000
]
testAlloc
print
(
sort
results
==
results
)
-- results better be in ascending order
testsuite/tests/rts/alloccounter1.stdout
deleted
100644 → 0
View file @
8bb150df
True
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment