Skip to content

Commit

Permalink
Improve compilation progress log (#2969)
Browse files Browse the repository at this point in the history
- Closes #2797 

Changes:

1. The global flag `--dev-show-thread-ids` is now properly being passed.
Before it was ignored.
3. The progress log has been refactored out of the `ParallelTemplate`
into the `Pipeline.Driver`. With the extra information available, I've
improved how we display the progress log:
1. We show `Compiling`, `Recompiling`, `Loading` to tell if the module
is compiled for the first time (the jvo is missing), or it needs to be
recompiled (with the reason displayed in parentheses), or is loaded from
a jvo file. In the latter case, the message is only showed with
`--log-level verbose|debug`.
2. The modules in other packages are displayed as dependencies with
their own progress counter.
2. When using `-N 1` and compiling a whole project we also get progress
log.

Example screencast:


https://github.com/user-attachments/assets/7cc43cd4-9b23-4ad5-a863-832abacc1b6c
  • Loading branch information
janmasrovira authored Aug 29, 2024
1 parent a4f3704 commit eb00fa4
Show file tree
Hide file tree
Showing 26 changed files with 564 additions and 229 deletions.
3 changes: 2 additions & 1 deletion app/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ runPipelineOptions m = do
g <- askGlobalOptions
let opt =
defaultPipelineOptions
{ _pipelineNumThreads = g ^. globalNumThreads
{ _pipelineNumThreads = g ^. globalNumThreads,
_pipelineShowThreadId = g ^. globalDevShowThreadIds
}
runReader opt m

Expand Down
28 changes: 13 additions & 15 deletions app/Commands/Dev/ImportTree/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ import Juvix.Compiler.Pipeline.Loader.PathResolver
import Juvix.Compiler.Pipeline.Loader.PathResolver.ImportTree

runCommand :: (Members AppEffects r) => PrintOptions -> Sem r ()
runCommand PrintOptions {..} = runReader opts . runPipelineSetup $ do
tree <- case _printInputFile of
Nothing -> ask
Just appInputFile -> do
inputFile <- fromAppPathFile appInputFile
mkImportTree (Just inputFile)
renderStdOut (ppOutDefaultNoComments tree)
when _printStats $ do
let stats = mkImportTreeStats tree
renderStdOut (ppOutDefaultNoComments stats)
where
opts =
defaultPipelineOptions
{ _pipelineImportStrategy = _printScanStrategy
}
runCommand PrintOptions {..} = runPipelineOptions
. local (set pipelineImportStrategy _printScanStrategy)
. runPipelineSetup
$ do
tree <- case _printInputFile of
Nothing -> ask
Just appInputFile -> do
inputFile <- fromAppPathFile appInputFile
mkImportTree (Just inputFile)
renderStdOut (ppOutDefaultNoComments tree)
when _printStats $ do
let stats = mkImportTreeStats tree
renderStdOut (ppOutDefaultNoComments stats)
2 changes: 1 addition & 1 deletion app/Commands/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import Commands.Typecheck.Options
runCommand :: (Members AppEffects r) => TypecheckOptions -> Sem r ()
runCommand localOpts = do
case localOpts ^. typecheckInputFile of
Just _inputFile -> void (runPipelineNoOptions (localOpts ^. typecheckInputFile) upToCoreTypecheck)
Just inputFile -> void (runPipelineNoOptions (Just inputFile) upToCoreTypecheck)
Nothing -> void (runPipelineOptions . runPipelineSetup $ processProject)
logInfo "Well done! It type checks"
2 changes: 0 additions & 2 deletions app/CommonOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module CommonOptions
( module CommonOptions,
module Juvix.Prelude,
module Juvix.Prelude.Pretty,
module Parallel.ProgressLog,
module Options.Applicative,
module Prettyprinter.Render.Terminal,
)
Expand All @@ -28,7 +27,6 @@ import Juvix.Prelude.Parsing qualified as P
import Juvix.Prelude.Pretty hiding (group, list)
import Options.Applicative hiding (helpDoc)
import Options.Applicative qualified as Opt
import Parallel.ProgressLog
import Prettyprinter.Render.Terminal hiding (renderIO, renderStrict)
import System.Process
import Text.Read (readMaybe)
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Asm/Interpreter/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Juvix.Compiler.Asm.Interpreter.Base
)
where

import Juvix.Compiler.Asm.Language
import Juvix.Compiler.Asm.Language hiding (logMessage)
import Juvix.Compiler.Tree.Language.Value hiding (Value)
import Juvix.Compiler.Tree.Language.Value qualified as Tree

Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Concrete/Print/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ instance PrettyPrint KeywordRef where
$ p
)

docNoCommentsDefault :: (PrettyPrint c) => c -> Doc Ann
docNoCommentsDefault = docHelper Nothing defaultOptions

docNoComments :: (PrettyPrint c) => Options -> c -> Doc Ann
docNoComments = docHelper Nothing

Expand Down
6 changes: 2 additions & 4 deletions src/Juvix/Compiler/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ import Juvix.Compiler.Tree qualified as Tree
import Juvix.Data.Effect.Git
import Juvix.Data.Effect.Process
import Juvix.Data.Field
import Parallel.ProgressLog (ProgressLog)
import Parallel.ProgressLog

type PipelineAppEffects = '[TaggedLock, Reader PipelineOptions, Logger, EmbedIO]

type PipelineLocalEff =
'[ ModuleInfoCache,
ProgressLog,
JvoCache,
Reader ImportTree,
Reader ImportScanStrategy,
Expand All @@ -74,7 +75,6 @@ type PipelineLocalEff =
Error GitProcessError,
Process,
Log,
ProgressLog,
Reader EntryPoint,
Files,
Error JuvixError,
Expand All @@ -93,8 +93,6 @@ type PipelineEff r =
]
++ PipelineEff' r

makeLenses ''PipelineOptions

--------------------------------------------------------------------------------
-- Workflows from source
--------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit eb00fa4

Please sign in to comment.