Skip to content

Commit

Permalink
refactor(rts): do not generate event types
Browse files Browse the repository at this point in the history
There is little value in generating a C array from a Python list.
  • Loading branch information
andreabedini committed Jan 30, 2025
1 parent 515616b commit 01e5a91
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 240 deletions.
30 changes: 4 additions & 26 deletions Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ cabalProgram = simpleProgram "cabal"
gitProgram :: Program
gitProgram = simpleProgram "git"

pythonProgram :: Program
pythonProgram = simpleProgram "python"

defaultProgramDb :: ProgramDb
defaultProgramDb =
addKnownPrograms
Expand Down Expand Up @@ -108,7 +105,7 @@ buildGhcStage1 verbosity progdb opts dst = do
notice verbosity $ "Bootstrapping GHC version: " ++ show (programVersion ghc0)

let src = dst </> "src"
prepareGhcSources verbosity progdb opts src
prepareGhcSources verbosity opts src

let builddir = dst </> "cabal"
createDirectoryIfMissing True builddir
Expand Down Expand Up @@ -222,12 +219,11 @@ buildGhcStage1 verbosity progdb opts dst = do

-- TODO:
-- - headers shared between different packages should be a common dependency
-- - event types should be generated by Setup.hs
-- package versions: do they need to be all the same?

-- | Prepare GHC sources in the given directory
prepareGhcSources :: Verbosity -> MVar ProgramDb -> GhcBuildOptions -> FilePath -> IO ()
prepareGhcSources verbosity progdb opts dst = do
prepareGhcSources :: Verbosity -> GhcBuildOptions -> FilePath -> IO ()
prepareGhcSources verbosity opts dst = do
notice verbosity $ " - Preparing sources in " ++ dst ++ "..."
createDirectoryIfMissing True dst

Expand Down Expand Up @@ -255,24 +251,6 @@ prepareGhcSources verbosity progdb opts dst = do
cp verbosity "utils/fs/fs.c" (dst </> "utils/unlit/")
cp verbosity "utils/fs/fs.h" (dst </> "utils/unlit/")

python <- requireProgram' verbosity progdb pythonProgram

runProgram
verbosity
python
[ "rts/gen_event_types.py"
, "--event-types-defines"
, dst </> "libraries/rts/include/rts/EventLogConstants.h"
]

runProgram
verbosity
python
[ "rts/gen_event_types.py"
, "--event-types-array"
, dst </> "libraries/rts/include/rts/EventTypes.h"
]

-- substitute variables in files
let subst fin fout rs = do
t <- Text.readFile fin
Expand Down Expand Up @@ -415,7 +393,7 @@ buildBootLibraries verbosity progdb opts dst = do
genprimop <- requireProgram' verbosity progdb (simpleProgram "stage1-genprimopcode")

src <- makeAbsolute (dst </> "src")
prepareGhcSources verbosity progdb opts src
prepareGhcSources verbosity opts src

-- Build the RTS
src_rts <- makeAbsolute (src </> "libraries/rts")
Expand Down
214 changes: 0 additions & 214 deletions rts/gen_event_types.py

This file was deleted.

82 changes: 82 additions & 0 deletions rts/include/rts/EventLogConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#pragma once

// When adding a new event type used by GHC you should also update
// NUM_GHC_EVENT_TAGS in include/rts/EventLogFormat.h.

#define EVENT_CREATE_THREAD 0
#define EVENT_RUN_THREAD 1
#define EVENT_STOP_THREAD 2
#define EVENT_THREAD_RUNNABLE 3
#define EVENT_MIGRATE_THREAD 4
#define EVENT_THREAD_WAKEUP 8
#define EVENT_GC_START 9
#define EVENT_GC_END 10
#define EVENT_REQUEST_SEQ_GC 11
#define EVENT_REQUEST_PAR_GC 12
#define EVENT_CREATE_SPARK_THREAD 15
#define EVENT_LOG_MSG 16
#define EVENT_BLOCK_MARKER 18
#define EVENT_USER_MSG 19
#define EVENT_GC_IDLE 20
#define EVENT_GC_WORK 21
#define EVENT_GC_DONE 22
#define EVENT_CAPSET_CREATE 25
#define EVENT_CAPSET_DELETE 26
#define EVENT_CAPSET_ASSIGN_CAP 27
#define EVENT_CAPSET_REMOVE_CAP 28
#define EVENT_RTS_IDENTIFIER 29
#define EVENT_PROGRAM_ARGS 30
#define EVENT_PROGRAM_ENV 31
#define EVENT_OSPROCESS_PID 32
#define EVENT_OSPROCESS_PPID 33
#define EVENT_SPARK_COUNTERS 34
#define EVENT_SPARK_CREATE 35
#define EVENT_SPARK_DUD 36
#define EVENT_SPARK_OVERFLOW 37
#define EVENT_SPARK_RUN 38
#define EVENT_SPARK_STEAL 39
#define EVENT_SPARK_FIZZLE 40
#define EVENT_SPARK_GC 41
#define EVENT_INTERN_STRING 42
#define EVENT_WALL_CLOCK_TIME 43
#define EVENT_THREAD_LABEL 44
#define EVENT_CAP_CREATE 45
#define EVENT_CAP_DELETE 46
#define EVENT_CAP_DISABLE 47
#define EVENT_CAP_ENABLE 48
#define EVENT_HEAP_ALLOCATED 49
#define EVENT_HEAP_SIZE 50
#define EVENT_HEAP_LIVE 51
#define EVENT_HEAP_INFO_GHC 52
#define EVENT_GC_STATS_GHC 53
#define EVENT_GC_GLOBAL_SYNC 54
#define EVENT_TASK_CREATE 55
#define EVENT_TASK_MIGRATE 56
#define EVENT_TASK_DELETE 57
#define EVENT_USER_MARKER 58
#define EVENT_HACK_BUG_T9003 59
#define EVENT_MEM_RETURN 90
#define EVENT_BLOCKS_SIZE 91
#define EVENT_HEAP_PROF_BEGIN 160
#define EVENT_HEAP_PROF_COST_CENTRE 161
#define EVENT_HEAP_PROF_SAMPLE_BEGIN 162
#define EVENT_HEAP_PROF_SAMPLE_COST_CENTRE 163
#define EVENT_HEAP_PROF_SAMPLE_STRING 164
#define EVENT_HEAP_PROF_SAMPLE_END 165
#define EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN 166
#define EVENT_PROF_SAMPLE_COST_CENTRE 167
#define EVENT_PROF_BEGIN 168
#define EVENT_IPE 169
#define EVENT_USER_BINARY_MSG 181
#define EVENT_CONC_MARK_BEGIN 200
#define EVENT_CONC_MARK_END 201
#define EVENT_CONC_SYNC_BEGIN 202
#define EVENT_CONC_SYNC_END 203
#define EVENT_CONC_SWEEP_BEGIN 204
#define EVENT_CONC_SWEEP_END 205
#define EVENT_CONC_UPD_REM_SET_FLUSH 206
#define EVENT_NONMOVING_HEAP_CENSUS 207
#define EVENT_NONMOVING_PRUNED_SEGMENTS 208
#define EVENT_TICKY_COUNTER_DEF 210
#define EVENT_TICKY_COUNTER_SAMPLE 211
#define EVENT_TICKY_COUNTER_BEGIN_SAMPLE 212
Loading

0 comments on commit 01e5a91

Please sign in to comment.