-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import tree #2751
Merged
Merged
Import tree #2751
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
janmasrovira
force-pushed
the
module-dependencies
branch
10 times, most recently
from
April 29, 2024 15:18
e9fdf36
to
e4edd58
Compare
janmasrovira
force-pushed
the
module-dependencies
branch
2 times, most recently
from
April 30, 2024 14:22
5f578fb
to
6bf20bf
Compare
paulcadman
force-pushed
the
module-dependencies
branch
from
May 3, 2024 09:05
bbf0a29
to
ab431ba
Compare
janmasrovira
force-pushed
the
module-dependencies
branch
from
May 3, 2024 11:44
04761f7
to
066a83c
Compare
janmasrovira
force-pushed
the
module-dependencies
branch
from
May 3, 2024 16:42
4642763
to
512f972
Compare
janmasrovira
force-pushed
the
module-dependencies
branch
from
May 3, 2024 17:00
512f972
to
e88d3ab
Compare
paulcadman
previously approved these changes
May 13, 2024
janmasrovira
force-pushed
the
module-dependencies
branch
from
May 13, 2024 18:26
fade869
to
9789769
Compare
paulcadman
approved these changes
May 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New commands:
dev import-tree scan FILE
. Scans a single file and lists all the imports in it.dev import-tree print
. Scans all files in the package and its dependencies. Builds an import dependency tree and prints it to stdin. If the--stats
flag is given, it reports the number of scanned modules, the number of unique imports, and the length of the longest import chain.Example: this is the truncated output of
juvix dev import-tree print --stats
in thejuvix-stdlib
directory.Bot commands support the
--scan-strategy
flag, which determines which parser we use to scan the imports. The possible values are:flatparse
. It uses the low-level FlatParse parsing library. This parser is made specifically to only parse imports and ignores the rest. So we expect this to have a much better performance. It does not have error messages.megaparsec
. It uses the normal juvix parser and we simply collect the imports from it.flatparse-megaparsec
(default). It uses the flatparse backend and fallbacks to megaparsec if it fails.Internal changes
Megaparsec Parser (
Concrete.FromSource
)In order to be able to run the parser during the scanning phase, I've adjusted some of the effects used in the parser:
NameIdGen
andFiles
constraints, which were unused.Reader EntryPoint
. It was used to get theModuleId
. Now theModuleId
is generated during scoping.PathResolver
by theTopModuleNameChecker
effect. This new effect, as the name suggests, only checks the name of the module (same rules as we had in thePathResolver
before). It is also possible to ignore the effect, which is needed if we want to use this parser without an entrypoint.PathResolver
effet refactorWithPath
command has been removed.ResolvePath :: ImportScan -> PathResolver m (PackageInfo, FileExt)
. Useful for resolving imports during scanning phase.WithResolverRoot :: Path Abs Dir -> m a -> PathResolver m a
. Useful for switching package context.GetPackageInfos :: PathResolver m (HashMap (Path Abs Dir) PackageInfo)
, which returns a table with all packages. Useful to scan all dependencies.The
Package.PathResolver
has been refactored to be more like to normalPathResolver
. We've discussed with @paulcadman the possibility to try to unify both implementations in the near future.Misc
Package.juvix
no longer ends up inPackageInfo.packageRelativeFiles
.--
,{-
and-}
..juvix.md
was detected as an invalid extension.LazyHashMap
to the prelude. I've also addedordSet
to create ordered Sets,ordMap
for ordered maps, etc.Benchmarks
I've profiled
juvix dev import-tree --scan-strategy [megaparsec | flatparse] --stats
with optimization enabled.In the images below we see that in the megaparsec case, the scanning takes 54.8% of the total time, whereas in the flatparse case it only takes 9.6% of the total time.
Megaparsec
Flatparse
Hyperfine
In order to compare (almost) only the parsing, I've forced the scanning of each file to be performed 50 times (so that the cost of other parts get swallowed). Here are the results: