Skip to content

modules/performance: add ability to byte-compile lua packages and lua dependencies #3314

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

Merged
merged 12 commits into from
May 12, 2025

Conversation

stasjok
Copy link
Contributor

@stasjok stasjok commented May 11, 2025

This PR:

  • Introduces performance.byteCompileLua.luaLib option. When enabled, it'll byte-compile lua libraries in LUA_PATH. Specifically: extraLuaPackages and plugins propagatedBuildInputs.
  • Adds tests/utils/plugin-stubs.nix with a shared plugin stubs and generated lua code for using in performance tests.
  • Once again refactors performance tests using shared plugin stubs.

Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for continuing to work on these perf options!

@stasjok
Copy link
Contributor Author

stasjok commented May 12, 2025

I think all comments were addressed. I rebased it on top of c76112e.

stasjok added 12 commits May 12, 2025 17:39
Previously, to determine if a file is byte-compiled, a simple binary
file detection was used, specifically checking if it contained any null
bytes. This commit updates the check to read the file header and compare
it with a known LuaJIT header.
To reduce unexpected breakages due to changes in nixpkgs, replace the
tested plugins with specially crafted stub plugins.
* improve assert messages
* validate both byte-compiled and non-byte-compiled files are working
This commit adds `performance.byteCompileLua.luaLib` options. When
enabled it byte-compiles lua packages from extraLuaPackages option.
This commit adds byte compiling of plugin lua dependencies
(specifically propagatedBuildInputs). It's enabled by
`performance.byteCompileLua.luaLib` option.
This commit introduces a shared utils module for future use in
performance tests. It includes lua libraries and plugins of various
types and dependencies. Additionally, it provides lua code snippets to
verify that all features supplied by the plugins are functioning
correctly.
This commit replaces custom lua plugins in tests with shared stub
plugins from utils module.
After this change the test has started to fail. Debugging this issue
I found out that dependencies of plugins weren't processed.
This commit improves the test assertion to detect duplicated
dependencies in this case and fixes the underlying issue by also
processing dependencies.
Previously only extraLuaPackages themselves were byte-compiled, not
theirs dependencies. This commit fixes that by compiling lua packages
recursively. It uses byte-compile-lua-lib.nix shared file.
Also this commit uses the shared stub lua libraries for extraLuaPackages
byte-compiling test.
This commit finalizes using shared utils stub plugins for
performance.byteCompileLua tests.
To re-use more code from utils module, 'pluginChecksFor', 'libChecksFor'
and 'pythonChecksFor' functions were introduced. These functions
generate a check code for the given plugins/libs names.
This commit replaces stub plugins with the shared ones from utils
module.
This also removes separate tests for checking python and lua
dependencies. This is now tested in the 'default' test thanks to
`pluginChecks` code.
@stasjok stasjok force-pushed the byte-compile-lua-lib branch from 4d9b0c3 to 49a7bb5 Compare May 12, 2025 14:40
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Awesome! The diff looks good to me, thanks again

@MattSturgeon

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Contributor

mergify bot commented May 12, 2025

This pull request, with head sha 49a7bb573aa44b8464e28b1f06720f26e87c03b5, has been successfully merged with fast-forward by Mergify.

This pull request will be automatically closed by GitHub.

As soon as GitHub detects that the sha 49a7bb573aa44b8464e28b1f06720f26e87c03b5 is part of the main branch, it will mark this pull request as merged.

It is possible for this pull request to remain open if this detection does not happen, this usually happens when a force-push is done on this branch byte-compile-lua-lib, this means GitHub will fail to detect the merge.

@mergify mergify bot merged commit 49a7bb5 into nix-community:main May 12, 2025
4 checks passed
@mergify mergify bot temporarily deployed to github-pages May 12, 2025 14:51 Inactive
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