Skip to content

Cache compiled tl scripts#61

Merged
euclidianAce merged 9 commits intomainfrom
script-cache
Aug 19, 2025
Merged

Cache compiled tl scripts#61
euclidianAce merged 9 commits intomainfrom
script-cache

Conversation

@euclidianAce
Copy link
Member

Writing a script in teal introduces a noticable delay since it needs to
be compiled each time. Using our patented
check-the-mod-time-of-the-files™®© technology we can compile it once and
shove it in some random directory to be pulled up later when it hasn't
changed.

This behavior can be controlled with a few environment variables:

  • CYAN_DISABLE_SCRIPT_CACHE: disables saving and loading to and from
    the cache

  • CYAN_SCRIPT_CACHE_DIR: controls what directory saving and loading are
    done to and from.

    The default values on unix-likes are:

    • $XDG_CACHE_HOME/cyan-script-cache
    • $HOME/.cache/cyan-script-cache

    And on windows:

    • %AppData%\Temp\cyan-script-cache

Errors while saving and loading to and from the cache are not considered
failures as it is trivial to just recompile the script.

Note that this has not been tested yet on windows and I'm not super familiar with its directory conventions. So until that is figured out this won't be merged.

Writing a script in teal introduces a noticable delay since it needs to
be compiled each time. Using our patented
check-the-mod-time-of-the-files™®© technology we can compile it once and
shove it in some random directory to be pulled up later when it hasn't
changed.

This behavior can be controlled with a few environment variables:

 - CYAN_DISABLE_SCRIPT_CACHE: disables saving and loading to and from
   the cache

 - CYAN_SCRIPT_CACHE_DIR: controls what directory saving and loading are
   done to and from.

   The default values on unix-likes are:

      - $XDG_CACHE_HOME/cyan-script-cache
      - $HOME/.cache/cyan-script-cache

   And on windows:

      - %AppData%\Temp\cyan-script-cache

Errors while saving and loading to and from the cache are not considered
failures as it is trivial to just recompile the script.
For script caching we started storing script paths as absolute, but
displayed paths are generally relative to the starting directory. This
was hacked in as `script.base_directory`.

Introducing the `InvocationContext`.

To avoid global state, things that need information about how cyan
itself was invoked should take this as a parameter. Right now it only
contains the initial directory and project root directory.
@euclidianAce
Copy link
Member Author

Closes #47

@euclidianAce
Copy link
Member Author

Tests run fine locally, and I can't repro luarocks not being able to satisfy lexical-path ~> 0.1 🤷

@euclidianAce euclidianAce merged commit 80c208c into main Aug 19, 2025
0 of 5 checks passed
@euclidianAce euclidianAce deleted the script-cache branch August 19, 2025 00:02
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.

1 participant