Skip to content
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

Memoise module paths #799

Merged
merged 4 commits into from
Dec 15, 2021
Merged

Conversation

jonludlam
Copy link
Member

The aim here is to reduce the amount of memory used when compiling long chains of aliases, which currently causes problems.

This also fixes a problem with verifying lookups that caused this
test to blow the stack.
The idea here is to ensure maximal sharing, so paths that contain
a lot of repetitive paths remain small in absolute memory usage
Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be a global memo ? There's a lot of empty () so potentially a lot of memos that aren't shared.

match Tools.resolve_type_path env cp with
| Ok p' -> `Resolved (Cpath.resolved_type_path_of_cpath p')
| Ok p' -> `Resolved Lang_of.(Path.resolved_type (empty ()) p')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had two ways to convert from Cpath.* to Path.* - I deleted the ones in Cpath and added the memoisation to the other (in Lang_of).

@jonludlam
Copy link
Member Author

I considered a global memo, but it's all quite contextual - so converting from the same Lang.* -> Component.* will often give different results - whereas the reverse, Component.* -> Lang.* will likely cause a lot of leakage from memoised results that are subsequently irrelevant .

@jonludlam
Copy link
Member Author

In case it wasn't very obvious from the diff, this can make a startling difference (in the pathological case the test case is testing) - the size of the odocl file reduced from 36 megs to 24k :-) (c7b327b#diff-ad34e4af41233ad07cbd0172dc46cc763e6e50a0b0d403bf371ca7b7768a4e8dL5)

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome !

@jonludlam jonludlam merged commit 1f016ad into ocaml:master Dec 15, 2021
jonludlam added a commit to jonludlam/opam-repository that referenced this pull request Feb 8, 2022
CHANGES:

Additions
- New subcommand to resolve references (@panglesd, @lubega-simon, ocaml/odoc#812)
- Improved rendering of long signatures (@panglesd, ocaml/odoc#782)
- Handle comments attached to open statement as floating comment, instead
  of dropping them (@panglesd, ocaml/odoc#797)
- Empty includes (containing entirely shadowed entries) are now hidden (@panglesd, ocaml/odoc#798)

Bugs fixed
- Fix a missing Result constructor during compile. This will cause some
  functor arguments to have different filenames (@jonludlam, ocaml/odoc#795)
- Better memory/disk space usage when handling module alias chains (@jonludlam, ocaml/odoc#799)
- Resolving class-type paths (ie., `val x : #c`) (@jonludlam, ocaml/odoc#809)
- Skip top-level attributes while extracting the top comment. Fix top-comment extraction with PPX preprocessing (@jorisgio, ocaml/odoc#819)
- Better handling of @canonical tags (@jonludlam, ocaml/odoc#820)
- css: improved layout (@jonludlam, @Julow, ocaml/odoc#822)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants