[protobuf] Performance differences when creating builder - why?
Hi all, I was recently comparing different serialization frameworks and one of these was Protobuf. A simplified version of the used .proto file is attached. After writing a bit java code which creates a certain builder instance (code is also attached), I realized that there are some performance differences between the execution time for the first invocation of the code and the second invocation. I have repeated this several times and for different .proto files and it has always been like that. After debugging the code, I cannot see differences in which code is called - my first assumption was that in the first invocation some additional code is called which increases the execution time. But I could not find such a case. Is there any particular reason why the first invocation is much slower than the second one? I used the most current version of protobuf for the evaluation, if this is relevant for the answer. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout. simple.proto Description: Binary data package de.simple.performance; import de.simple.performance.SimpleProtos.A; import de.simple.performance.SimpleProtos.AVariant; import de.simple.performance.SimpleProtos.B; import de.simple.performance.SimpleProtos.C; public class SimplePerformance { public static void main(String[] args) { builderInvocation(); //second invocation much faster than the first one - why? builderInvocation(); } private static void builderInvocation() { long start = System.nanoTime(); A.Builder a = A.newBuilder(); AVariant.Builder aVar = AVariant.newBuilder(); B.Builder b = B.newBuilder(); C.Builder c = C.newBuilder(); c.setName(name1); c.setLockReason(lockReason#no); b.setC(c); aVar.setB(b); a.addVariant(aVar); long end = System.nanoTime(); System.out.println(Execution time: + (end - start) + ns); } }
Re: [protobuf] Re: Portable protobuf compiler
Thanks osuciu - I checked into protoc-jar. Unfortunately, it suffers from the same problem I'm currently having - it just wraps a call to the C version of protoc for windows, osx and linux and provides those binaries embedded in the jar. This would be fine except, as the OP pointed out, protoc on linux is not portable from one linux distro to another. The readme.md file is not even clear as to which linux distro the linux version targets. I'm looking for a true native java port of the protoc compiler. It's a pretty trivial compiler and the C source code is available. I guess I'll have to do it myself. John On Monday, June 23, 2014 7:38:10 PM UTC-6, Feng Xiao wrote: On Mon, Jun 23, 2014 at 6:29 PM, John Calcote john.c...@gmail.com javascript: wrote: I'm also interested in a portable protoc compiler - java would be nice, but python would work too. No one has a comment on this? osuciu@'s protoc-jar might be of interest to you: https://github.com/os72/protoc-jar On Friday, January 24, 2014 2:07:27 AM UTC-7, Matthias Hogerheijde wrote: Hi, I've successfully compiled protoc in order to generate Java sources from a .proto file. (In this case gtfs-realtime.proto https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto .) We're using this in a Maven project. My wish is to have Maven compile the Java source from the .proto files automatically; and not have the compiled sources checked in into Git. I've configured Maven to automatically execute protoc with the desired parameters to generate the sources for me; all is going well. I even configured Maven to use the Windows executable when on a Windows platform. But the Linux version is not portable. When compiling the protoc-executable it hard-codes some absolute paths. This means that I cannot ship the executable with the project, for other programmers working on the same project don't have the same folder-tree as I do; and I don't want to force them to either. Does anyone know of a way to have a portable solution to generate the code on the fly, without having every contributor on the project having to download/configure/compile protoc? Kind Regards, Matthias Hogerheijde -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com javascript:. To post to this group, send email to prot...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Re: Portable protobuf compiler
Thanks Feng Xiao- I checked into protoc-jar. Unfortunately, it suffers from the same problem I'm currently having - it just wraps a call to the C version of protoc for windows, osx and linux and provides those binaries embedded in the jar. This would be fine except, as the OP pointed out, protoc on linux is not portable from one linux distro to another. The readme.md file is not even clear as to which linux distro the linux version targets. I'm looking for a true native java port of the protoc compiler. It's a pretty trivial compiler and the C source code is available. I guess I'll have to do it myself. John -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Re: Portable protobuf compiler
The Linux protoc in protoc-jar is a static 64bit build, I think on some RedHat flavor. But it still has some .so dependencies, libc.so, etc. I'm guessing that's the issue? If some Linux expert could provide a fully static build (no shared libs at all), I think that should work on most Linuxes. Happy to include it in protoc-jar Porting the whole thing to Java sounds great but may not be that trivial, not sure Cheers --Oliver On Tuesday, June 24, 2014 8:31:08 AM UTC-7, John Calcote wrote: Thanks Feng Xiao- I checked into protoc-jar. Unfortunately, it suffers from the same problem I'm currently having - it just wraps a call to the C version of protoc for windows, osx and linux and provides those binaries embedded in the jar. This would be fine except, as the OP pointed out, protoc on linux is not portable from one linux distro to another. The readme.md file is not even clear as to which linux distro the linux version targets. I'm looking for a true native java port of the protoc compiler. It's a pretty trivial compiler and the C source code is available. I guess I'll have to do it myself. John -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.