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

refactor: pass hash into code cache #752

Merged
merged 5 commits into from
May 23, 2024

Conversation

dsherret
Copy link
Member

This avoids the cli having to re-lookup the hash again.

@@ -275,7 +288,8 @@ impl ModuleLoader for MockLoader {

fn code_cache_ready(
&self,
module_specifier: &ModuleSpecifier,
module_specifier: ModuleSpecifier,
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this to an owned value because deno_core has it available without cloning and this can help prevent cloning if someone wants to send this to another thread when saving the code cache.

@@ -275,7 +288,8 @@ impl ModuleLoader for MockLoader {

fn code_cache_ready(
&self,
module_specifier: &ModuleSpecifier,
module_specifier: ModuleSpecifier,
_hash: u64,
code_cache: &[u8],
) -> Pin<Box<dyn Future<Output = ()>>> {
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 should look into doing something similar for the script callbacks. I'm just not sure how to convert a Local<String> to a &str... maybe deno_core should just create the hash.

Copy link
Member

Choose a reason for hiding this comment

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

You can convert it like so: &x.to_rust_string_lossy(scope)

@dsherret dsherret merged commit f0a7357 into denoland:main May 23, 2024
18 checks passed
@dsherret dsherret deleted the refactor_pass_hash_into_code_cache branch May 23, 2024 19:01
dsherret added a commit to denoland/deno that referenced this pull request May 24, 2024
* denoland/deno_core#752
* denoland/deno_core#753

Did benchmarking on this and it's slightly faster (couple ms) or equal
to in performance as main.

Closes #23904
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.

None yet

3 participants