Today MasterService#patchVersions creates a new Metadata$Builder, increments the version, and then calls build() which expensively recomputes a bunch of data structures, e.g. Metadata#indicesLookup. This is quite inefficient, we could just copy those data structures from the previous Metadata and save a bunch of work and garbage-generation.
This is what it looks like in a flamegraph:

That's only ~7.5% of the total time on this otherwise busy master, but we could still cut this in half.
Today
MasterService#patchVersionscreates a newMetadata$Builder, increments the version, and then callsbuild()which expensively recomputes a bunch of data structures, e.g.Metadata#indicesLookup. This is quite inefficient, we could just copy those data structures from the previousMetadataand save a bunch of work and garbage-generation.This is what it looks like in a flamegraph:
That's only ~7.5% of the total time on this otherwise busy master, but we could still cut this in half.