googlefonts / oxidize

Notes on moving tools and libraries to Rust.
Apache License 2.0
173 stars 7 forks source link

Simple benchmark to compare view vs 'hybrid' performance #13

Closed cmyr closed 2 years ago

cmyr commented 2 years ago

I think this will be a useful initial datapoint, since the hybrid model is our worst case but also our most idiomatic & straight-forward option, and I'd like to A) set a baseline and B) rule out the hybrid.

This will also be helpful because we can verify that the macro approach will make sense for us in a non-trivial case.

To do this, I'm going to write a macro that generates both types, and then compare them on an approximation of a real task: my current idea is to take a sample string, resolve it to glyph ids, and then sum the area of the bounding boxes of each glyph. If anyone has a better idea I'd be happy to hear it. :)

rsheeter commented 2 years ago

Sounds like a reasonable starting point. If it's easy it would be nice to get zerocopy in there.

I'm not familiar with preferred tools for Rust benchmarking, so noob questions:

  1. what we will measure (instruction count? wall time? both?)
  2. how, e.g. with what tool? Is pprof (with it's lovely flame graphs!) preferred or ...?
madig commented 2 years ago

You could... recompute the bboxes (including diving into components). That's an annoyingly expensive task.

cmyr commented 2 years ago

Sounds like a reasonable starting point. If it's easy it would be nice to get zerocopy in there.

agreed, I've got some zerocopy examples working.

I'm not familiar with preferred tools for Rust benchmarking, so noob questions:

  1. what we will measure (instruction count? wall time? both?)
  2. how, e.g. with what tool? Is pprof (with it's lovely flame graphs!) preferred or ...?

I've moved the goal posts a bit, and am instead going to focus more on micro benchmarks, since there's better infrastructure available and hopefully I can come up with some examples that we can extrapolate from usefully. For the actual measuring I'm going to rely on criterion, which is a rust-specific benchmarking tool that is measuring wall time.

In any case I've made some good progress here, and will get results written up for early next week, then we can think about next steps.

cmyr commented 2 years ago

closing this, some initial results in #14