-
Couldn't load subscription status.
- Fork 15
Merge next into master for release #309
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
Conversation
This file contains hidden or 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
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* refactor: extract preset-to-option logic to separate function this commit is a preparation of the introduction of a cache mechanism to speed up the execution of cron-validate. Although the commit looks irrelevant if considered in isolation, it greatly simplify the analysis of the next commit. I also removed unused imports from index.ts Signed-off-by: albertodiazdorado <albertodiazdorado@gmail.com> * feat: load presets on module load In the previous source code version we would load the built-in presets on every invocation of 'cron' (via 'validateOptions'). This means that we do a lot of repeated work on consecutive invocations of 'cron'. With the new design we load the presets just once when we load the module 'options.ts', via the new function 'loadPresets()'. In order to avoid circular dependencies, I modified 'presets.ts' to export just vanilla JavaScript objects. Signed-off-by: albertodiazdorado <albertodiazdorado@gmail.com> * feat: improve performance by adding a cache mechanism cron-validated was very slow when called in a loop. The reason is that we repeated all these operations in every call: 1. Merge the preset and the overrides into a so-called 'unvalidatedConfig' 2. Dynamically generate a yup validation schema from the preset and the override 3. Validate the 'unvalidatedConfig' using the dynamically generated schema Step 2 is particularly slow, but steps 1 and 3 aren't particularly fast either. Luckily for us, all these 3 steps are perfectly cacheable. This Pull Request introduces a so-called 'optionsCache' to avoid repeating the 3 steps if we already executed them in the past (which happens all the time in a loop). The cache is a map from 'cache keys' to 'validated options'. The cache key is the concatenarion of 'presetId' and a stringified 'override' object. If two function calls produce the same cache key, it invariably means that the user wants to use the same 'Options' in both function calls. This is how the cache produces a performance improvement of about x100 for consecutive calls. Note that the construction of the cache key is not optimized. If the user uses 'cron-validate' two consecutive times with identical 'override' objects, but swaps the order of the override object fields, then they will not benefit from caching. This can be fixed by using deterministic stringification, but I do not consider it necessary. Signed-off-by: albertodiazdorado <albertodiazdorado@gmail.com> --------- Signed-off-by: albertodiazdorado <albertodiazdorado@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
|
🎉 This PR is included in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
No description provided.