Skip to content

Some filter performance improvements

  • Added filter error and performance logging.
  • Converted some inner loop branches in box_blur_loop() into outer branches via generics.
    • This dropped the Gaussian blur time on the phone by about 0.3 seconds (from about 0.8 to about 0.5).
  • Added benchmarks for sRGB conversion and composite arithmetic.
  • Slightly improved the performance of the Pixels iterator.
  • Converted .round() calls to + 0.5 everywhere in filter-related code (since the values are known to be >= 0). This improved the performance of affected loops by about 30% (phone 4.5 => 3.6 seconds).

I also made a script for parsing the spammy filter performance log:

#!/usr/bin/python3

import sys

times = {}

lines = sys.stdin.readlines()
for a, b in zip(lines, lines[1:]):
    if not a.startswith('(rendered filter primitive '):
        continue

    primitive = a.split()[3][len('FilterPrimitive'):]
    time = float(b.split()[0])

    if primitive not in times:
        times[primitive] = [time]
    else:
        times[primitive].append(time)

for primitive, time_list in sorted(
        times.items(), key=lambda t: sum(t[1]), reverse=True):
    print(f"{sum(time_list):f} s: {primitive}")

    for time in sorted(time_list, reverse=True):
        print(f"\t{time:f} s")

    print()

print('========')

for primitive, time_list in sorted(
        times.items(), key=lambda t: sum(t[1]), reverse=True):
    print(f"{sum(time_list):f} s: {primitive}")

Example output: https://paste.gnome.org/psjwulqvq

Merge request reports