ProtoDef-io / node-protodef

Describe your protocol, and read it with ease.
MIT License
31 stars 18 forks source link

Update readArray at datatypes/structures.js #98

Closed Saiv46 closed 4 years ago

Saiv46 commented 5 years ago

Using Array.push and accessing the object's result.value property is performance-cost by itself.

Maybe we should improve that?

rom1504 commented 5 years ago

We have a benchmark which currently sum the times for various value serialization. You can run it only for array and check whether it makes a difference.

It's clear that node-protodef is not optimal, previous experiences showed that it's 10-100x slower than manually written code.

If you're serious in your efforts to optimize protodef, the way to go is to produce a protocol json to JavaScript compiler. (The code is currently an interpreter). It would be a fun project but will also take some time.

On Sun, Sep 1, 2019, 13:03 Alexander Ivanov notifications@github.com wrote:

Using Array.push and accessing the object's result.value property is performance-cost by itself.

Maybe we should improve that?

[] Benchmark it [] Merge

You can view, comment on, or merge this pull request online at:

https://github.com/ProtoDef-io/node-protodef/pull/98 Commit Summary

  • Update readArray at structures.js
  • :oops:

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ProtoDef-io/node-protodef/pull/98?email_source=notifications&email_token=AAR437SJ4HWDXYUWV7ZIMG3QHOORBA5CNFSM4ISWN2MKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIUKYUA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR437V4GLC5NGA2SFTNWSLQHOORBANCNFSM4ISWN2MA .

Saiv46 commented 5 years ago

If you're serious in your efforts to optimize protodef, the way to go is to produce a protocol json to JavaScript compiler. (The code is currently an interpreter). It would be a fun project but will also take some time.

There's already performant code generators such as astring, I think I can somehow convert json protocol to AST in the future "compiler".

rom1504 commented 5 years ago

Sounds good

On Mon, Sep 2, 2019, 08:48 Alexander Ivanov notifications@github.com wrote:

If you're serious in your efforts to optimize protodef, the way to go is to produce a protocol json to JavaScript compiler. (The code is currently an interpreter). It would be a fun project but will also take some time.

There's already have performant code generators such as astring https://github.com/davidbonnet/astring#benchmark, I think I can somehow convert json protocol to AST in the future "compiler".

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ProtoDef-io/node-protodef/pull/98?email_source=notifications&email_token=AAR437T2ML2AJQLSIRQ2VRDQHSZMRA5CNFSM4ISWN2MKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5U4A2I#issuecomment-527024233, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR437VF7LGMUXV4K3Q24KLQHSZMRANCNFSM4ISWN2MA .

Saiv46 commented 4 years ago

switch and context fields made compilation non-trivial. Instead, I re-implementing this as classes to avoid polymorphism and then inline method functions with regexp.