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

consider implementing a compiler in js again #86

Closed
rom1504 opened this issue Jul 22, 2018 · 8 comments
Closed

consider implementing a compiler in js again #86

rom1504 opened this issue Jul 22, 2018 · 8 comments

Comments

@rom1504
Copy link
Member

rom1504 commented Jul 22, 2018

support .json , only objective is performance improvement

@Saiv46
Copy link
Contributor

Saiv46 commented Sep 3, 2019

Bump

The only problem is re-implementing read/write functions and optimization of produced code (can be solved with Closure Compiler, but that's huge overhead).

@rom1504
Copy link
Member Author

rom1504 commented Sep 3, 2019

Reimplementing what ?
The point of this issue is to implement a json to js compiler as if the code was manually written.
That is optimal

@rom1504
Copy link
Member Author

rom1504 commented Sep 3, 2019

And not sure what you mean by "bump".
Do you want to work on it ?

@Saiv46
Copy link
Contributor

Saiv46 commented Sep 5, 2019

I'm already working on that, trying to solve multiple issues at once (#87, #69, #63, #49, #28).
Messages like "bump" are used to bump threads up and make it more visible.

I'm re-implementing interpreter as type classes, to compile read/write/size functions to AST later.

@rom1504
Copy link
Member Author

rom1504 commented May 9, 2020

putting some background in this issue for anyone falling on it :

  • node-protodef is an interpreter
  • js is not amazing at polymorphic operation due to absence of types
  • writing the serialization/deserialization manually results in 100x faster performance (I tried this)
  • simple consequence => compilation would be much faster.
    Ways to do this :
  • completely new protocol definition language with compilation to various language https://github.com/ProtoDef-io/protodefc . Issue: need completely new integration in js and rewrite of all protocol definition. Was started at https://github.com/ProtoDef-io/node-protodefc but not quite there + no benchmark was done yet
  • just write a current json format to manual-like compile in js : would make integration easy and would solve the performance issue

this is this last point that this issue is about.
I believe this could make all users of protodef much faster (including node-minecraft-protocol)

@Karang
Copy link
Contributor

Karang commented May 9, 2020

putting some background in this issue for anyone falling on it :

* node-protodef is an interpreter

* js is not amazing at polymorphic operation due to absence of types

* writing the serialization/deserialization manually results in 100x faster performance (I tried this)

* simple consequence => compilation would be much faster.
  Ways to do this :

* completely new protocol definition language with compilation to various language https://github.com/ProtoDef-io/protodefc . Issue: need completely new integration in js and rewrite of all protocol definition. Was started at https://github.com/ProtoDef-io/node-protodefc but not quite there + no benchmark was done yet

* just write a current json format to manual-like compile in js : would make integration easy and would solve the performance issue

this is this last point that this issue is about.
I believe this could make all users of protodef much faster (including node-minecraft-protocol)

This is interesting. What you suggest is to make a node module that could take a protocol.json with the current specification and generate a .js file that contains an optimized ser/deser code ?

You said you tried writting it manually, is there an example (code) of what you did by hand ?

Also, what benchmark do you have to test the performance of the compiled vs interpreted protodef ?

@rom1504
Copy link
Member Author

rom1504 commented May 9, 2020

yeah. That js file could then either be saved and committed or simply be evaluated using eval

#65 has some examples but basically the idea of writing manually is just to write naive code to read buffers using https://nodejs.org/api/buffer.html
what node-protodef implements is an interpreter on top of buffer API

for benchmarks, see https://github.com/ProtoDef-io/node-protodef/pull/65/files#diff-95f0a310f289230d56c3a4949c17963eR85

see also all of this https://github.com/ProtoDef-io/node-protodef/tree/master/benchmark

I did not implement manually everything (that would be crazy long !), but on simple examples it's much faster to use manual code.

@rom1504
Copy link
Member Author

rom1504 commented May 20, 2020

now done

@rom1504 rom1504 closed this as completed May 20, 2020
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

No branches or pull requests

3 participants