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

[Go] no zero-copy? #765

Open
asido opened this issue Mar 19, 2020 · 5 comments
Open

[Go] no zero-copy? #765

asido opened this issue Mar 19, 2020 · 5 comments

Comments

@asido
Copy link

asido commented Mar 19, 2020

I generated Go code and see there is no Wrap() method. Instead, there is Encode(io.Reader), which fetches and assigns all values to public fields in the model. Is there no zero-copy alternative in Go, that allows to read the data in-place?

@neomantra
Copy link
Contributor

This is correct. The current Go implementation takes raw SBE message and creates a fully-formed Golang struct from it and thus every field is marshaled.

The reasoning behind this is described here:
https://github.com/real-logic/simple-binary-encoding/wiki/Golang-User-Guide#golang-idioms

This design prioritizes easy-to-use and hard-to-misuse over performance. It should be possible to make a zero-copy / flyweight generator if someone were up to the task.

ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Apr 4, 2023
@matthewdowney
Copy link

@ethanf curious if your impl ended up looking promising?

ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Jul 3, 2023
Full test coverage is still in the works.
@ethanf
Copy link
Contributor

ethanf commented Jul 3, 2023

@ethanf curious if your impl ended up looking promising?

I've updated https://github.com/ethanf/simple-binary-encoding/tree/go-flyweight with the latest code. It's code complete and mostly works, but there's still work to do updating the tests unfortunately.

ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Aug 3, 2023
Full test coverage is still in the works.
@ethanf
Copy link
Contributor

ethanf commented Aug 7, 2023

https://github.com/ethanf/simple-binary-encoding/tree/go-flyweight has passing tests now, does anyone have a preference for how to switch between the flyweight and struct versions of the generated code? Is a system property that switches between the generators acceptable?

ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Aug 8, 2023
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Aug 8, 2023
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Aug 8, 2023
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
@neomantra
Copy link
Contributor

Thanks for your contribution! I only started looking at it and will take it for a spin in a few weeks.

I do think that using system properties like that is consistent with other SBE / Aeron tool options.

ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Aug 25, 2023
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Dec 7, 2023
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Sep 17, 2024
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
ethanf added a commit to ethanf/simple-binary-encoding that referenced this issue Sep 18, 2024
To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```
vyazelenko pushed a commit that referenced this issue Oct 29, 2024
* [Go] SBE implementation in Go using flyweights #765

To generate flyweights instead of structs, set the following flag:

```
sbe.go.generate.generate.flyweights=true
```

* [Go] Checkstyle fix

* [Go] Fix null string return value

* [Go] Remove spurious type definition for choices

* [Go] Fix formatting in WrapForDecode

* [Go] Add returning an array by []byte

* [Go] Fix array not present in version

* [Go] Add ComputeLength methods

* [Go] Fix some compiler warnings and remove unused code

* [Go] Draft of OTF decoder

* [Go] Add OTF Json Printer

* [Go] Fix SbeBlockAndHeaderLength and add constants for composite sizes

* [Go] Add IrDecoder for runtime types

* [Go] Add enum get method

* [Go] Fixes for updating component counts in irdecoder

* [Go] Run goimports

* [Go] Update with latest changes

* [Go] Change the file structure for GOPATH

* [Go] Fix copywrite year

* [Go] Fix tests for otf

This generates flyweights in the sbe-tool build for use in the otf library.

* [Go] Add helpers for otf PrimitiveValue
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

4 participants