# EPF5 Week 8 Updates This week I ran a number of tests on lighthouse `BeaconState` and `SignedBeaconBlock` encoding/decoding, both on specttest data as well as real mainnet data. I was able to download real `BeaconState` data with the following command (note the slot number `9626400`): ``` curl -H "Accept: application/octet-stream" https://sync-mainnet.beaconcha.in/eth/v2/debug/beacon/states/9626400 > beacon-state.ssz ``` Thank you for helping with this, Daniel! Below are screenshots from the benchmarks on `BeaconState` encoding/decoding: - lighthouse `BeaconState` benches with real state data from slot `9626400`. ![Screen Shot 2024-08-01 at 8.01.02 AM](https://hackmd.io/_uploads/S1qZtetYR.png) - lighthouse `BeaconState` benches with consensus spec tests. the difference in decoding time is stunning. ![Screen Shot 2024-08-01 at 8.04.19 AM](https://hackmd.io/_uploads/SyyRteFY0.png) I had some issues getting flamegraphing to work, and I frankly wasted too much time trying. Fortunately, I found [dhat](https://crates.io/crates/dhat) which gives me a trace of heap allocations at runtime. I used this to see what was the main bottleneck. It's not as granular as I'd like yet, I can't see exactly what types take the longest to decode. I *can* see that variable length lists (henceforth variable lists) are by far the biggest bottlenecks. Fixed sized vectors, on the other hand, barely seem to make a dent in alloc costs. The fixed and variable list types are both backed by the `Vec` type, which is heap-allocated, so it's interesting just how much longer it takes to decode variable lists. variable list decoding in `BeaconState`. ![Screen Shot 2024-08-04 at 11.27.47 PM](https://hackmd.io/_uploads/HJeUvpatR.png) variable list decoding in `SignedBeaconBlock` ![Screen Shot 2024-08-04 at 11.29.10 PM](https://hackmd.io/_uploads/rJw8w6TKA.png) I'm going to rewrite my project proposal as development of the benchmarking suite is going slower than expected. I'm learning about and using a variety of tools, and I think a benchmarking suite will emerge from the frequent testing I'll be doing as I begin streamlining my benchmarking methodology. notes: - lighthouse consensus types crate uses `milhouse::List` type instead of the `ssz_types::VariableList` type which sigma prime also created. I should try inserting the `ssz_types` crate. It's unclear why they use milhouse since their own benchmarks would suggest `VariableList` is more performant. - I'll reimplement `BeaconState` with `ssz_types` just to confirm if `milhouse` is more performant or not. This more or less concludes the slow start of testing ssz crates and libraries, starting next week I will attempt to tackle bottlenecks present in rust ssz crates. I'm hoping to find some performance bugs and submit some meaningful PRs.