Date: Sun, 26 Jul 2009 00:50:43 +0400 From: Solar Designer <solar@...nwall.com> To: john-users@...ts.openwall.com Subject: Re: Work (optimization) in progress, and some ideas On Sat, Jul 25, 2009 at 02:37:28PM -0500, JimF wrote: > When that is done, I have a few other 'loose' ends to finish up on some > other code that another member posted to me. Then I will start looking at > any possible optimzations to be found in the rule processing code. > > I think the code to do prepending is one of the slower cases, and I am sure > I can speed that up, but how much, I can't say yet. Here are a few ideas that I didn't get around to trying out yet: 1. Cache the length of "in" (or the previous command's "out") in a variable across the rule commands in rules_apply(). This would eliminate the need for most strlen() "calls". Indeed, strlen() is done inline these days, but nevertheless the loops have a cost when the strings are of non-negligible length. Also, it may let some strcpy()'s and the like be replaced with memcpy(). Updating the cached length will usually not involve a strlen(). Instead, it would be done based on the previous length - e.g., 'd' and 'f' will double the previous length, whereas '$' and '^' will increase it by 1. 2. To make prepends and similar faster, reserve some space before the start of the input buffer (that is, point "in" to the middle of a buffer initially). Then prepends will be like "*(out = in - 1) = value;" when there's sufficient space in the buffer. 3. Don't copy the input "word" to "in" when that is possible to avoid without modifying "word" (tricky, the extra if's might outweigh the performance advantage for short words). 4. Introduce string append/prepend/insert commands, like: A"string" - append B"string" - prepend CN"string" - insert in position N In case the double-quote character is to be included in the string, any other character may be used in its place, just like with the 's' command of ed/sed/vi/perl: A,string, - append a string that possibly contains the double-quote character, but does not contain the comma. Unfortunately, the 'P' and 'I' command characters are already taken. ... Finally, I feel that it may be appropriate to rework the rules syntax at some point - invent something more generic - but not now. Alexander -- To unsubscribe, e-mail john-users-unsubscribe@...ts.openwall.com and reply to the automated confirmation request that will be sent to you.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.