[Parseperl-discuss] PPI::XS: Good candidates for XS implementation?
Brought to you by:
adamkennedy
From: Torsten S. <kaf...@gm...> - 2006-10-21 19:35:54
|
Aloha, since I have quite a bit of XS experience, I thought I'd tackle implementing a few methods in PPI::XS to speed things up. To find bottlenecks I used the module I talked about in the earlier message and let it analyze a ~3500 line program under the supervision of a profiler.[1] The profiles unveiled a few hotspots: * PPI::Node::find_first, 9 calls, ~9 seconds * PPI::Tokenizer::_process_next_char, 44305 calls, ~3.5 seconds * PPI::Lexer::_lex_statement, 2908 calls, ~3 seconds PPI::Node::find_first calls many methods and does little computation on its own, so implementing it in XS wouldn't provide much benefit. The same is true for PPI::Lexer::_lex_statement. PPI::Tokenizer::_process_next_char looked more promising. So I wrote an XS port of it. Patch attached. Well, the bad news is that this didn't improve performance measurably. I looked at a few other candidates in the profiles but the all seem to have the same issue: not much computation, lots of method calls. I don't think you can improve code like this very much by simply porting it to XS verbatim. perl already does a pretty good job when it creates the optree, it seems. So, any suggestions on what might be a good candidate for porting? -- Bye, -Torsten [1] I tried Devel::DProf, Devel::Profile, and Devel::AutoProfiler. All yielded similar results. |