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

Support caching/emitting bytecode #3335

Closed
kitsonk opened this issue Nov 13, 2019 · 13 comments
Closed

Support caching/emitting bytecode #3335

kitsonk opened this issue Nov 13, 2019 · 13 comments
Assignees
Labels
cli related to cli/ dir deno_core Changes in "deno_core" crate are needed feat new feature (which has been agreed to/accepted)

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Nov 13, 2019

@ry mentioned to me that V8 supports a way to transpile modules to byte code. In theory we could persist that in the cache instead of JavaScript. Different than snapshots, which are code running in memory, this would be more like .pyc in Python.

We could also potentially emit the bundles to that format as well.

@ry
Copy link
Member

ry commented Nov 13, 2019

The feature I was referring to is described here: https://github.com/v8/v8/blob/b4bfbce6f91fc2cc72178af42bb3172c5f5eaebb/include/v8.h#L1625-L1629

This will become more accessible after we replace libdeno with rusty-v8. We should also solve #1692 before attempting this.

@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2021
@kitsonk kitsonk added cli related to cli/ dir suggestion suggestions for new features (yet to be agreed) deno_core Changes in "deno_core" crate are needed and removed stale labels Jan 6, 2021
@bartlomieju
Copy link
Member

@lucacasonato and I discussed this today. Besides required rusty_v8 bindings, we might have to change some types passed to deno_core, but other than that there are no blockers for this feature.

@bartlomieju bartlomieju added feat new feature (which has been agreed to/accepted) and removed suggestion suggestions for new features (yet to be agreed) labels Jan 20, 2022
@bartlomieju bartlomieju self-assigned this Jan 20, 2022
@Ayfri
Copy link

Ayfri commented Apr 1, 2022

Any update on that ?

@kitsonk
Copy link
Contributor Author

kitsonk commented Apr 2, 2022

It simply hasn't been a priority. The investment is high and the likely improvement in performance is questionable. While there are no blockers for it, there is a lot of other higher priority work for the core team.

@cunev
Copy link

cunev commented Jun 26, 2022

Would be great to see some progress on this issue.

@lucacasonato
Copy link
Member

lucacasonato commented Jun 26, 2022

Out of interest, what are your usecases @Ayfri and @cunev?

@cunev We are always happy to take PRs from third party contributors if this is something you are interested in!

@Ayfri
Copy link

Ayfri commented Jun 26, 2022

Just for curiousity in my case !

@teleclimber
Copy link

@lucacasonato In my case anything that can reduce startup time is welcome. In Dropserver [1] I run one Deno instance per app instance, and it gets shut off when the app instance is not in use (to free up resources). This means sometimes I have to start up an instance on an incoming HTTP request. As a result, the faster the startup time, the better.

It's not clear from the comments above how much this feature might help startup time, but if it can, I'm all for it.

Thanks!

[1] https://github.com/teleclimber/Dropserver

@cunev
Copy link

cunev commented Jun 27, 2022

@lucacasonato
Code caching would significantly reduce the instantiation time of the "compiled" Deno projects, and act as a small layer of protection for production apps.

Even tho, not a proper way of protecting the code, as long as there is no public V8 bytecode disassembler - it's a great feature to have.
ex. https://github.com/bytenode/bytenode. (result of this discussion)

@bermi
Copy link

bermi commented Jun 27, 2022

@lucacasonato not having to unzip the js to the user cache directory would make it easy to install cli deno apps as root that can be used by regular users. Right now we have to define an explicit cache dir.

Bundling the bytecode might also speed up thins for CLI apps.

@ForbiddenEra
Copy link

as long as there is no public V8 bytecode disassembler

There is. But for V8, bytecode is internal and changes based on different versions, so you could potentially need to have unique disassemblers for every version.

@lucacasonato
Copy link
Member

We automatically use V8 code cache since 1.43 now (https://deno.com/blog/v1.43#faster-es-and-commonjs-module-loading).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir deno_core Changes in "deno_core" crate are needed feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

9 participants