ianprime0509 / zig-xml

XML parser for Zig
http://ianjohnson.dev/zig-xml/
BSD Zero Clause License
14 stars 3 forks source link

refactor: rewrite the project #36

Closed ianprime0509 closed 1 week ago

ianprime0509 commented 1 week ago

This is a complete rewrite of the project, using a more efficient and flexible design based around the concept of a forward-only "view" into the source document. Some capabilities are regressed in this initial implementation, including built-in non-UTF-8 support and some of the writer functionality.


Benchmark results compared to the old Reader implementation:

Benchmark 1 (43 runs): ../../zig-xml-main/bench/zig-out/bin/reader zig-out/Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           118ms ± 2.11ms     115ms …  125ms          1 ( 2%)        0%
  peak_rss           7.49MB ± 77.4KB    7.32MB … 7.58MB          0 ( 0%)        0%
  cpu_cycles          465M  ± 6.90M      456M  …  477M           0 ( 0%)        0%
  instructions       1.17G  ± 21.0      1.17G  … 1.17G           0 ( 0%)        0%
  cache_references   1.07M  ±  312K      728K  … 2.70M           1 ( 2%)        0%
  cache_misses       26.3K  ± 9.07K     13.3K  … 55.4K           1 ( 2%)        0%
  branch_misses      1.38M  ± 4.20K     1.38M  … 1.40M           2 ( 5%)        0%
Benchmark 2 (73 runs): zig-out/bin/reader zig-out/Gtk-4.0.gir
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          68.9ms ±  626us    68.1ms … 71.4ms          4 ( 5%)        ⚡- 41.3% ±  0.4%
  peak_rss           7.53MB ± 58.3KB    7.45MB … 7.60MB          0 ( 0%)          +  0.5% ±  0.3%
  cpu_cycles          265M  ± 1.41M      262M  …  269M           0 ( 0%)        ⚡- 43.0% ±  0.4%
  instructions        604M  ± 16.8       604M  …  604M          12 (16%)        ⚡- 48.3% ±  0.0%
  cache_references    481K  ±  265K      268K  … 2.42M           5 ( 7%)        ⚡- 54.9% ± 10.1%
  cache_misses       19.8K  ± 3.77K     11.0K  … 27.5K           5 ( 7%)        ⚡- 24.6% ±  9.1%
  branch_misses       899K  ± 3.71K      893K  …  910K           2 ( 3%)        ⚡- 35.0% ±  0.1%
ianprime0509 commented 1 week ago

Follow-up work will be to implement new features and optimizations. Aside from the core design, very little attempt at optimizing the code has been made so far.