drewnoakes / metadata-extractor-dotnet

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Other
915 stars 158 forks source link

Introduce and use Indexed BufferReader methods #402

Closed iamcarbon closed 5 months ago

iamcarbon commented 5 months ago

This PR introduces indexed accessors on the Buffer reader, and eliminates another batch of allocations.

iamcarbon commented 5 months ago

After this PR, we'll be able to spanify ITypeChecker. Fun seeing these build on each other!

Screenshot 2024-02-05 at 7 41 03 PM
drewnoakes commented 5 months ago

After this PR, we'll be able to spanify ITypeChecker. Fun seeing these build on each other!

Nice! I looked at that on the weekend and from memory it was blocked on the TGA checker that needed indexed access. Great that we can spanify it too.

I've been looking at trying to consolidate the THREE different approaches we have for reading ISO BMFF data. We have quite similar code for MP4, QuickTime and HEIF data formats. They're all different enough that it's not so straightforward, but I'm hopeful the end result will be good.

drewnoakes commented 5 months ago

I ran a trace over the regression suite, using .NET 8 in release mode, with only the .NET runner, which reads all the input files and writes out metadata text files.

image

The run used 9.92 seconds of CPU. We spent 135 ms in the GC, which is < 2%. Pretty good!

image

Interestingly there are 22 gen 2 collections. Some of these are the LOH which would be good to investigate as ideally we wouldn't be allocating anything on the LOH. I suspect they're mostly byte arrays, but will investigate:

image

I also see some finalizers running for reflection emit, which I find surprising. I'll try and track those down.