unison-runtime-0.0.0
Safe HaskellNone
LanguageHaskell2010

Unison.Runtime.JIT.Config

Description

Settings for the JIT, read from the environment by readConfig when ucm starts, and carried in the JIT handle from then on (see JIT.hs). The mode also has a command-line option, --jit, which overrides the variable. How to use these is in development.md next to this module.

Synopsis

Documentation

data Mode Source #

Constructors

Off

never compile

On

compile what gets hot, in the background (LLVM is loaded at startup)

Eager

compile everything as it is loaded (for testing)

Instances

Instances details
Show Mode Source # 
Instance details

Defined in Unison.Runtime.JIT.Config

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

Eq Mode Source # 
Instance details

Defined in Unison.Runtime.JIT.Config

Methods

(==) :: Mode -> Mode -> Bool #

(/=) :: Mode -> Mode -> Bool #

data Replacements Source #

Which of the Haskell replacements of base library definitions (Unison.Runtime.Foreign.Function.functionReplacementList) the runtime applies when it loads code.

Constructors

AllReplacements

every entry of the list

TaggedReplacements

the entries tagged Always; the ones tagged InterpreterOnly are left as the Unison code they would replace, for the JIT to compile

NoReplacements

none (for measuring an Always entry against native code)

Instances

Instances details
Show Replacements Source # 
Instance details

Defined in Unison.Runtime.JIT.Config

Eq Replacements Source # 
Instance details

Defined in Unison.Runtime.JIT.Config

data ReplacementUse Source #

The tag on an entry of the replacement list: whether it is applied under TaggedReplacements, the JIT's default.

Constructors

Always 
InterpreterOnly 

data Config Source #

Constructors

Config 

Fields

  • mode :: Mode
     
  • threshold :: Int

    with On: interpreted calls before a definition is compiled (UNISON_JIT_THRESHOLD)

  • batch :: Int

    with On: the most definitions compiled together as one module (UNISON_JIT_BATCH)

  • batchGate :: Int

    with On: the estimated calls between a definition and the batch being formed that make it join the batch (UNISON_JIT_BATCH_GATE; a quarter of the threshold by default). See JIT.formBatch.

  • sizeUnit :: Int

    with On: the size of a typical definition, in units of its frame size times its call sites (the generated code grows with both). A candidate's estimated calls are divided by its size in these units, so that a large definition needs proportionally more calls across its edges to join a batch (UNISON_JIT_SIZE_UNIT). See JIT.formBatch.

  • passes :: String

    the LLVM pass pipeline a module is optimized with (UNISON_JIT_PASSES; the empty string runs none). The default is defaultPasses, the parts of defaultO2 that matter for our code; defaultO2 itself and UNISON_JIT_CODEGEN_LEVEL (which jit_llvm.c reads itself) are there for comparison.

  • exitCall :: Bool

    exits and unwinds write the frame back through one call to the C routine unison_jit_exit_frame per site, the live slots as its arguments, rather than through generated write-back blocks (UNISON_JIT_EXITS=call, the default, or blocks). See Codegen.joinShared.

  • copyBound :: Double

    with On: a compiled callee of a definition being compiled is compiled again as a private copy in the new module, so that calls to it are direct and LLVM can inline it, when the callee's estimated work per call (JIT.Estimate's saving) is at most this (UNISON_JIT_COPY; 0 turns copies off)

  • reentryWait :: Int

    with On: milliseconds the compile thread waits for more re-entry function requests before compiling the ones it holds as one module (UNISON_JIT_REENTRY_WAIT; 0 compiles each at once)

  • reentryAdHoc :: Int

    with On: how many re-entry functions a group may get because of exits the code didn't cause, the poll and stack growth (UNISON_JIT_REENTRY_ADHOC; see JIT.noteAdHocExit)

  • exitCost :: Double

    what leaving native code and coming back costs, in units of the interpreter's overhead for one simple instruction: a function is left interpreted when its certain exits times this exceed what compiling it saves (UNISON_JIT_EXIT_COST; 0 compiles everything). See JIT.Estimate.

  • entryCost :: Double

    what entering native code from the interpreter costs, in the same units: a compiled function that saves less than this per call is still interpreted when the interpreter calls it (UNISON_JIT_ENTRY_COST; 0 always enters)

  • logging :: Bool

    log each compiled module to stderr

  • dumpIR :: Maybe FilePath

    directory to write each module's IR into, with the MCode of each function as a comment; - prints it to stderr instead

  • dumpMCode :: Bool

    print the MCode of every loaded definition to stderr

  • trace :: Bool

    log every transition between native code and the interpreter

  • stats :: Bool

    print exit counts after each evaluation (UNISON_JIT_STATS)

  • statsEach :: Bool

    with stats: print the exits taken since the last time whenever the program writes output, and start counting again (UNISON_JIT_STATS=each), so that a program that prints a line per phase gets its exits listed per phase

  • statsEvery :: Int

    with stats: also print the counts every this many exits (for evaluations that never finish)

  • stressPoll :: Int

    fire the entry poll every N entries (stress mode poll=N)

  • stressStack :: Maybe Int

    initial Unison stack size in slots (stress mode ustack=N)

  • stressCallee :: Int

    treat every Nth callee as not compiled (stress mode callee=N)

  • stressCStack :: Int

    C stack budget for native calls, in bytes (stress mode cstack=N)

  • stressAlloc :: Int

    allocation budget between polls, in words (stress mode alloc=N)

  • stressInstall :: Int

    milliseconds to sleep between installing each function of a module (stress mode install=N)

  • stressPool :: Maybe Int

    size of the constant pool before it has to grow (stress mode pool=N)

  • stressLists :: Int

    random operations to run through the list helpers at startup, each checked against the interpreter's (stress mode lists=N)

  • stressTexts :: Int

    the same for the text helpers (stress mode texts=N)

  • stressBytes :: Int

    and for the bytes helpers (stress mode bytes=N)

  • disabled :: [String]

    features turned off for debugging, from UNISON_JIT_DISABLE (comma separated): app (closure calls), apply (the interpreter entering native code for a closure), ref, array, cmp (universal comparison), list, text, bytes (the C helpers for those), callout (call-outs become resumes), direct (calls within a module go through cells), worker (no workers with register arguments), copy (no private copies of compiled callees), hash (the murmur hash), irhelpers (the helpers compiled from IR: generated code calls the C copies instead), requests (ability requests and the affine handler instructions: every request exits), ptr (the FFI pointer reads and writes), records (the record instructions: every one exits)

Instances

Instances details
Show Config Source # 
Instance details

Defined in Unison.Runtime.JIT.Config

replacements :: Replacements Source #

Which replacements apply, decided once. This is the one setting that is not carried in the JIT handle: it decides how a Map value is represented, which the value decoder (Stack.hs) and the foreign function table (Foreign.Function) have to agree on, and neither has a handle in reach. It is a property of the process, so a single decision is right. A compiled program chooses it before any code loads, from the mode it was compiled under (setReplacements; the file carries it, since its MCode has the replacements of that mode baked in); otherwise the environment decides: UNISON_REPLACEMENTS if set, else it follows UNISON_JIT.

setReplacements :: Replacements -> IO () Source #

Chooses the setting, for a compiled program from the mode stored in its file. It has to happen before any code has used the setting (before the cache is restored): code already loaded under another mode can't be redone, so a late choice that differs is an error.

replacementActive :: ReplacementUse -> Bool Source #

Whether an entry with this tag is applied under the current settings.

readConfig :: IO Config Source #

Reads the settings from the environment. Called once, by ucm at startup, after the --jit options have been put in the environment.

jitDump :: String -> IO () Source #

Writes diagnostic text to stderr, unconditionally.