Comments (2)
Hi @ericrenard!
I can provide a sample proto file and modifications made if needed.
I would appreciate that. I've been playing around with potential ways to pool the maps but nothing was proving to be significantly faster. Can you share some code?
from vtprotobuf.
Hi,
Sorry for replying so late, I was busy with other stuff :p
I uploaded an example here : https://github.com/MolotovTv/benchvitess
You have sample_vtproto.pb.go.standard which is the currently generated pb file for included proto and sample_vtproto.pb.go which is my hacked version.
Basically what I'm doing is to use the pool when a map value is an object and to pool the map itself (which is maybe not worth it).
Pre changes benchmark:
BenchmarkMarshal/marshalStd-12 27 41980015 ns/op 2184862 B/op 200005 allocs/op
BenchmarkMarshal/marshalVT-12 87 12711687 ns/op 1384449 B/op 1 allocs/op
BenchmarkUnmarshal/unMarshalStd-12 266701 3751 ns/op 1274 B/op 24 allocs/op
BenchmarkUnmarshal/unMarshalVT-12 830570 1262 ns/op 1186 B/op 13 allocs/op
BenchmarkUnmarshal/unMarshalVTWithPool-12 830074 1295 ns/op 1186 B/op 13 allocs/op
Post changes benchmark:
BenchmarkMarshal/marshalStd-12 25 44627198 ns/op 2184793 B/op 200005 allocs/op
BenchmarkMarshal/marshalVT-12 84 15979075 ns/op 1384450 B/op 1 allocs/op
BenchmarkUnmarshal/unMarshalStd-12 322051 3813 ns/op 1274 B/op 24 allocs/op
BenchmarkUnmarshal/unMarshalVT-12 415844 2787 ns/op 1187 B/op 13 allocs/op
BenchmarkUnmarshal/unMarshalVTWithPool-12 967172 1215 ns/op 3 B/op 0 allocs/op
I think pooling the values from the map is always better, but obviously the more objects in the map, the most difference it makes, for ex with 1000 keys :
BenchmarkUnmarshal/unMarshalVTWithPool-12 7194 149844 ns/op 147475 B/op 1030 allocs/op
BenchmarkUnmarshal/unMarshalVTWithPool-12 9793 118702 ns/op 192 B/op 0 allocs/op
While the difference in terms of speed is not huge in a benchmark, I think it makes a lot of difference on the gc pressure in context of, for example, microservices that do mainly unmarshall/marshal stuff.
from vtprotobuf.
Related Issues (20)
- Uncompilable code generated for repeated groups
- Duplicated code generated for GRPC client/server HOT 1
- Panic after WKT commit: assignment to entry in nil map HOT 2
- Extensions are not encoded
- docs/feature: Nested ReturnToVTPool() HOT 4
- bug: oneof field that includes bytes field yields invalid ResetVT method
- Supporting Embedded and Nullable features from gogo proto HOT 2
- bug: Broken ResetVT generation for optional message HOT 1
- bug: grpc client methods does not use qualified idents
- feature: poolable messages paths with wildcard HOT 2
- unmarshal_unsafe feature produced code does not compile: "Cannot use intStringLen (type int) as the type IntegerType" HOT 1
- Run vtproto multiple times on different files of the same package HOT 3
- bug: IsMap not checked on message field's ReturnToVTpool
- bug: UnmarshalUnsafe panics when map values are empty strings HOT 2
- Request for New Release that Includes Well-Known Type Support HOT 4
- gRPC codec has different semantic on Unmarshal than the default one HOT 1
- v0.6.0 is creating issues in ubuntu20 HOT 2
- Offering assistance and discussing upkeep / releases for vtprotobuf HOT 8
- wrong pool unmarshal slize HOT 3
- Add optional unsafe operations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vtprotobuf.