Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: apply memory optimizations to TokenReader #27

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

ianprime0509
Copy link
Owner

These optimizations are analogous to those made in #26 for Scanner. The performance improvement for Reader is less significant, but still noticeable:

Benchmark 1 (48 runs): zig-out/bin-old/reader Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           106ms ± 1.72ms     104ms …  110ms          0 ( 0%)        0%
  peak_rss           7.28MB ± 80.9KB    7.08MB … 7.34MB          0 ( 0%)        0%
  cpu_cycles          420M  ± 6.94M      413M  …  438M           0 ( 0%)        0%
  instructions       1.13G  ± 19.3      1.13G  … 1.13G           0 ( 0%)        0%
  cache_references    561K  ± 72.6K      477K  …  878K           2 ( 4%)        0%
  cache_misses       12.7K  ± 1.31K     11.3K  … 18.3K           3 ( 6%)        0%
  branch_misses      1.07M  ± 5.21K     1.07M  … 1.09M           0 ( 0%)        0%
Benchmark 2 (50 runs): zig-out/bin/reader Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           101ms ± 1.08ms    98.9ms …  103ms          1 ( 2%)        ⚡-  4.9% ±  0.5%
  peak_rss           7.29MB ± 63.6KB    7.21MB … 7.34MB          0 ( 0%)          +  0.2% ±  0.4%
  cpu_cycles          398M  ± 4.24M      393M  …  410M           1 ( 2%)        ⚡-  5.2% ±  0.5%
  instructions       1.11G  ± 20.8      1.11G  … 1.11G           0 ( 0%)        ⚡-  1.5% ±  0.0%
  cache_references    404K  ±  244K      314K  … 1.82M           4 ( 8%)        ⚡- 28.0% ± 13.0%
  cache_misses       12.0K  ± 1.11K     10.1K  … 15.3K           0 ( 0%)        ⚡-  5.6% ±  3.8%
  branch_misses      1.10M  ± 2.89K     1.10M  … 1.12M           4 ( 8%)        💩+  2.8% ±  0.2%

These optimizations are analogous to those made in #26 for `Scanner`.
The performance improvement for `Reader` is less significant, but still
noticeable:

```
Benchmark 1 (48 runs): zig-out/bin-old/reader Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           106ms ± 1.72ms     104ms …  110ms          0 ( 0%)        0%
  peak_rss           7.28MB ± 80.9KB    7.08MB … 7.34MB          0 ( 0%)        0%
  cpu_cycles          420M  ± 6.94M      413M  …  438M           0 ( 0%)        0%
  instructions       1.13G  ± 19.3      1.13G  … 1.13G           0 ( 0%)        0%
  cache_references    561K  ± 72.6K      477K  …  878K           2 ( 4%)        0%
  cache_misses       12.7K  ± 1.31K     11.3K  … 18.3K           3 ( 6%)        0%
  branch_misses      1.07M  ± 5.21K     1.07M  … 1.09M           0 ( 0%)        0%
Benchmark 2 (50 runs): zig-out/bin/reader Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           101ms ± 1.08ms    98.9ms …  103ms          1 ( 2%)        ⚡-  4.9% ±  0.5%
  peak_rss           7.29MB ± 63.6KB    7.21MB … 7.34MB          0 ( 0%)          +  0.2% ±  0.4%
  cpu_cycles          398M  ± 4.24M      393M  …  410M           1 ( 2%)        ⚡-  5.2% ±  0.5%
  instructions       1.11G  ± 20.8      1.11G  … 1.11G           0 ( 0%)        ⚡-  1.5% ±  0.0%
  cache_references    404K  ±  244K      314K  … 1.82M           4 ( 8%)        ⚡- 28.0% ± 13.0%
  cache_misses       12.0K  ± 1.11K     10.1K  … 15.3K           0 ( 0%)        ⚡-  5.6% ±  3.8%
  branch_misses      1.10M  ± 2.89K     1.10M  … 1.12M           4 ( 8%)        💩+  2.8% ±  0.2%
```
@ianprime0509 ianprime0509 merged commit fd84548 into main Oct 16, 2023
3 checks passed
@ianprime0509 ianprime0509 deleted the perf/token-reader branch October 16, 2023 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant