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

Avoid discarding cached interfaces #2767

Closed
nad opened this issue Sep 20, 2017 · 6 comments
Closed

Avoid discarding cached interfaces #2767

nad opened this issue Sep 20, 2017 · 6 comments
Assignees
Labels
performance Slow type checking, interaction, compilation or execution of Agda programs type: enhancement Issues and pull requests about possible improvements ux: emacs Issues relating to the Emacs agda2-mode ux: library management Issues relating to the library management system
Milestone

Comments

@nad
Copy link
Contributor

nad commented Sep 20, 2017

I often use the following setup in my Agda libraries:

  • The exported source files are placed in a subdirectory src.
  • Other files are placed elsewhere. One example might be a file ./README.agda that provides an overview over the library, importing modules located in src.
  • The .agda-lib file lists src as the only include directory.

In order to be able to type-check ./README.agda I include -i. in the Agda program options. However, this has a drawback: If I load ./README.agda and then load some file in src, then Agda discards cached interface files, because the include directories have changed. As a workaround I sometimes temporarily put . in the include directories. I would like to find a more principled solution to this problem.

@nad nad added ux: emacs Issues relating to the Emacs agda2-mode ux: library management Issues relating to the library management system performance Slow type checking, interaction, compilation or execution of Agda programs type: enhancement Issues and pull requests about possible improvements labels Sep 20, 2017
@nad nad added this to the 2.5.4 milestone Sep 20, 2017
@gallais
Copy link
Member

gallais commented Sep 20, 2017

Would it help to turn -i into a pragma option? You'd be able to mention that additional path directly at the top of README.

@nad
Copy link
Contributor Author

nad commented Sep 20, 2017

I don't think it should be possible to change the include directories inside a module.

@jespercockx jespercockx removed this from the 2.5.4 milestone May 9, 2018
@UlfNorell UlfNorell added this to the icebox milestone Jun 1, 2018
@UlfNorell
Copy link
Member

I guess the right thing to do would be to keep the cached interfaces and check that they refer to the module you expect when trying to load them.

@nad
Copy link
Contributor Author

nad commented Jun 1, 2018

I assume that you mean file rather than module.

I don't think it's quite as easy as that. What if you have changed the include path so that some module that the given file depends on now resides in a different file?

@UlfNorell
Copy link
Member

Right.

I believe we store the module (file? I'm unclear on when I'm allowed to use which word) dependencies in the interface. Maybe the best thing to do would be to prune the cached interfaces when the include path changes and throw out any interfaces with changed dependencies.

nad added a commit that referenced this issue Mar 4, 2022
Ulf Norell provided help with the design of this change.
nad added a commit that referenced this issue Mar 4, 2022
Ulf Norell provided help with the design of this change.
@nad
Copy link
Contributor Author

nad commented Mar 4, 2022

Maybe the best thing to do would be to prune the cached interfaces when the include path changes and throw out any interfaces with changed dependencies.

I've implemented something like that.

Switching between different libraries can still be slow. One could imagine storing the decoded libraries that are now discarded in a separate data structure, and reusing them if, say, the old include paths are restored (and nothing else has changed). However, I don't think we should waste memory on this.

@nad nad modified the milestones: icebox, 2.6.3 Mar 4, 2022
@nad nad self-assigned this Mar 4, 2022
@nad nad closed this as completed Mar 4, 2022
@andreasabel andreasabel modified the milestones: 2.6.3, 2.6.2.2 Mar 15, 2022
andreasabel pushed a commit that referenced this issue Mar 15, 2022
Ulf Norell provided help with the design of this change.

	src/full/Agda/TypeChecking/Monad/Options.hs
@andreasabel andreasabel mentioned this issue Mar 15, 2022
41 tasks
andreasabel pushed a commit that referenced this issue Mar 16, 2022
Ulf Norell provided help with the design of this change.

	src/full/Agda/TypeChecking/Monad/Options.hs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Slow type checking, interaction, compilation or execution of Agda programs type: enhancement Issues and pull requests about possible improvements ux: emacs Issues relating to the Emacs agda2-mode ux: library management Issues relating to the library management system
Projects
None yet
Development

No branches or pull requests

5 participants