Re: Qi Symbols parser performance
Stephan Menzel <[email protected]> Sat, 13 Jan 2018 19:36:14 +0100
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAEQ568u5gFyhU2XZmA7V=0Yp_pfJZ0TC_bzB4pLY0sYhm7d-ow@mail.gmail.com> |
Hello Seth, On Fri, Jan 12, 2018 at 11:58 PM, Seth <[email protected]> wrote: > I've looked at it. I posted the notes in a stackoverflow post, as it is > more suited for this than email. > > See it here https://stackoverflow.com/q/48235133/85371 Thanks for putting that much effort in it and your work on that. I don't have a Stackoverflow account but perhaps I can add some thoughts here. First of all, I have had a look at how to re-use the parser. As Joel also pointed out, they are meant to be re-used, which indeed was the chief reason for the performance lack here. The map (of symbols) would have to be rebuilt every time. Now since the static object that you use for this is const, I'm gonna go ahead assuming that this is thread safe and the same const static parser object can be used concurrently. I have to admit, that I was very much used to re-instantiating parsers as needed. I was not aware that they can be this expensive to create. Especially since in the tutorials and examples of spirit, they are rarely ever re-used. In fact, I have just browsed through them and I haven't seen any example. Normally they are just inlined, which is also a creation on demand. If re-using static instances, as Joel pointed out, can be seen as best practice, I would suggest to put that in the documentation. Perhaps along with a note that it is safe (as in thread safe) to do so. If I had known, I would have done it differently all those years. Teaser: > > Lambda runs took 2676 nanoseconds > Qi runs took 98 nanoseconds > Map runs took 189 nanoseconds > What is interesting though is those numbers. They don't match my results at all. With the re-used symbols I get this: (I have skipped the 'iequals' aka Lambda approach as it's no longer relevant for the discussion and hasn't changed.) Qi runs took 2431 nanoseconds Map runs took 2762 nanoseconds So finally everything is back in order and qi is now the fastest of the three. It's not quite 98 ns though. I have only made slight changes to your suggestions. Had to remove the lambda that you use to reverse the extensions as you fill the symbols map. To my knowledge this only works using auto and auto is not allowed around here. This didn't make a difference performance wise though and only runs once anyway. I also had to change back to strings but that didn't make any (visible) difference either. May I ask, how did you get these results? 98 ns strikes me as very impressive. I can't get it under ~2400 even with the exact code you have posted. Could that be MSVC sh!tting the bed? Unfortunately I don't have the liberty of switching to other compilers here. This would also explain why, when I use the ilexicographical_compare() for the map approach, the performance I get here drops dramatically. With the exact code I get: Qi runs took 2411 nanoseconds Map runs took 6663 nanoseconds I wouldn't have expected this at all. So as usual, one mystery down, another pops right up ;-) Not important though, I'll chalk it down to MSVC. In any case, thanks again for the response. Have a great weekend Best regards... Stephan ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Spirit-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spirit-general