libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

Assorted performance tweaks #49

Closed jnthn closed 3 years ago

jnthn commented 3 years ago

I was recently asked to look in to the performance of Spreadsheet::XLSX. Profiling revealed that a significant amount of the overhead was from calls into the LibXML module:

image

(The blue indicates code that is in the current project - in this case, the SpreadSheet::XLSX module. The grey below it is external code, including modules, the Rakudo standard library, and so forth.)

Looking a little more deeply into the hot spots, I produced a number of changes, where are included in this PR. I suggest reviewing the individual commits; in each I wrote the gain and what I perceive as the trade-off of the change, as for the most part I think they need a decision of whether it's an OK thing to do from the perspective of the module architecture.

Between this and one small improvement in Spreadsheet::XLSX, I'm currently seeing saving of a large worksheet in around half the time (my benchmark included startup and sheet setup before saving, which is why the improvements in the commits are counted as lower). The vast majority of that is due to these changes, so presumably they'll help others with similar use cases (XML writing) using this module too.

dwarring commented 3 years ago

Thanks. Released to CPAN with LibXML 0.5.12.