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

Serialize compiled instructions with serde #9

Open
adamsky opened this issue Sep 23, 2020 · 4 comments
Open

Serialize compiled instructions with serde #9

adamsky opened this issue Sep 23, 2020 · 4 comments

Comments

@adamsky
Copy link

adamsky commented Sep 23, 2020

For some use cases it may be useful to be able to serialize and deserialize compiled Instructions, along with Slabs. Perhaps this could become an optional feature?

@adamsky
Copy link
Author

adamsky commented Sep 23, 2020

I've actually had a test case where I wanted to send already compiled instructions over the network and ended up implementing this, pulling in serde and placing a few derives here and there. It's not much but worked fine for me.

@likebike
Copy link
Owner

Hmm, that's really interesting. I guess I assumed that it would be more performant to just save/transfer the original String expression, and then re-parse it on the other side. As you have already figured out, the instructions are tied to the slab, and it takes quite a bit of memory copies and I/O to serialize all those things and save them to a file or send them across a network. Sending the expression string would be way easier, and fasteval parsing is so fast, I had assumed that for most use cases, it would be the right choice.

I'll definitely think about this more, and I'll run some tests. If it's really more performant to serialize compiled expressions, I can definitely support that. Your code will be a great foundation. Thanks!

@adamsky
Copy link
Author

adamsky commented Sep 24, 2020

From what I've seen in terms of performance, doing some very preliminary benchmarks, deserializing a compiled Instruction + Slab on the receiver side appears to be faster. Of course this largely depends on the format, and so with bincode it's faster, but using something more compact like msgpack ends up being slower. It also varies based on the actual content of the expression, with compiled serialization taking advantage of expression simplification and whatnot. I guess I'll need to investigate this more.

@adamsky
Copy link
Author

adamsky commented Sep 24, 2020

Of course by saying it's faster I only mean the receiver side, not the combined sender and receiver. Main idea here being that a sender only has to serialize once, which can maybe save some processing time spend by the whole system if there were more than 1 receivers.

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

2 participants