[ENH] 3x faster Symbol>>keywords

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ENH] 3x faster Symbol>>keywords

Andres Valloud-2
Hello VWNC,

  Previously, I had made Symbol>>keywords ~3x faster by preallocating
  storage better.  But it still showed up in many TimeProfiler
  outputs, and since I am trying to make the RB go faster on this box,
  I thought it was time to make it even faster.

  On top of the previous 3x speedup, here is an additional ~3x speedup
  for it.  This one is achieved by aggressively optimizing the most
  common case where symbols have only one keyword, by using a sliding
  window pointer pair instead of additional stream storage, and by
  using an available primitive to look for occurrences of $: instead
  of doing so via aCharacter = $: in a to:do: loop.

  Enjoy!

allSymbols := ByteSymbol allInstances.
Time millisecondsToRun: [allSymbols do: [:x | x keywords]] 753
Time millisecondsToRun: [allSymbols do: [:x | x newKeywords]] 251

allSymbols detect: [:x | x keywords ~= x newKeywords] "none"

--
Best regards,
 Andres                          mailto:[hidden email]

Symbol-keywords.st (1K) Download Attachment