# Applying SnoopPrecompile to ProtoBuf Generated Code

**URL:** https://discourse.julialang.org/t/applying-snoopprecompile-to-protobuf-generated-code/97240
**Category:** Performance
**Tags:** question, snoopcompile, protobuf
**Created:** [April 7, 2023, 9:45pm UTC](https://discourse.julialang.org/t/applying-snoopprecompile-to-protobuf-generated-code/97240 "2023-04-07T21:45:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ThomasPluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomaspluck/32/48854_2.png) [@ThomasPluck](https://discourse.julialang.org/u/ThomasPluck)
#### Post date: [April 7, 2023, 9:45pm UTC](https://discourse.julialang.org/t/applying-snoopprecompile-to-protobuf-generated-code/97240/1 "2023-04-07T21:45:20Z")

</div>

Hi, so I’m generating some code using .protofiles, they are the usual messages etc. - I have some building automation that I’m fairly happy with and everything works as intended:

> **[Vlsir/bindings/julia at dev · ThomasPluck/Vlsir](https://github.com/ThomasPluck/Vlsir/tree/dev/bindings/julia)**
>
> dev/bindings/julia

These proto files can get quite large, and I figure that they might benefit from some pre-emptive precompilation. I was wondering how you might apply this programmatically to the Julia generated like this.

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [April 8, 2023, 8:47am UTC](https://discourse.julialang.org/t/applying-snoopprecompile-to-protobuf-generated-code/97240/2 "2023-04-08T08:47:00Z")

</div>

Not knowing anything about protofiles, VLSIR, or precisely what you’re hoping to achieve, I’m going to have to ask you to make your request more explicit. SnoopPrecompile’s purpose is to reduce the latency of Julia code on first execution. Can you give an example of code that is currently slow on first execution that you’re hoping to speed up?

Normal usage of SnoopPrecompile is quite simple, the docs are here: [SnoopPrecompile · SnoopCompile](https://timholy.github.io/SnoopCompile.jl/dev/snoop_pc/). But perhaps you’re hoping to do something a bit outside its usual role?

---

<div class="post-metadata">

### Author: ![ThomasPluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomaspluck/32/48854_2.png) [@ThomasPluck](https://discourse.julialang.org/u/ThomasPluck)
#### Post date: [April 8, 2023, 11:17am UTC](https://discourse.julialang.org/t/applying-snoopprecompile-to-protobuf-generated-code/97240/3 "2023-04-08T11:17:09Z")

</div>

I am a Julia newbie and I seem to be jumping into the deep end here, so I apologise in advance if my understanding of precompilation is poor!

So, the specifics:

`ProtoBuf.jl` is used to parse Protocol Buffers - which are just serialized “intermediate representations” of data between programming languages - into long lists of Julia function/struct definitions which you can see in the linked repository folder’s folders as `*_pb.jl` files.

Downstream, we intend to import these structs and functions as needed into more Julia. I can understand how precompilation might work on a piece of ordinary Julia - however, how would it be used across the generate files in `_pb.jl` - should everything be put in one big `@precompile_setup` block, should precompilation be atomised across the structs/functions, should there be a seperate file which calls all of these structs/functions and then should _that_ be put in a `precompile` block?
