|
|
|
|
|
by ggruschow
5414 days ago
|
|
Some things to think about: - 50mb is >> total cache on most systems you'll use.
- This is far from the only function you need to optimize.
--> The best performing algorithm in a micro-benchmark can be sub-optimal in real use.
- You've got a fixed-for-the-day list of <10k <9 letter unique upper-case strings
- The bulk of them you'll process are <= 4 letters (CMCSA/CMCSK be damned).
- The median is 3 and the mean is <3.6.
- The symbols aren't anywhere close to uniformly active
--> Benchmark with a typical data stream, not a uniformly distributed one.
- You're likely not even considering trading most of them.
- How much better is your algorithm than the obvious binary-search?
- Or worse -- plain'ol front-to-back linear search?
- Are you sure you understand 100% of how the computer works?
--> Yes? Mail a check to Goldman and find a better line of work.
--> No? Test it with a quick benchmark.
- Is binary search cache friendly?
- Why not? Plot out the memory accesses if need be.
- What's wrong with taking a linear-interpolated guess?
- Is that cache friendly? .. or could it be?
- When your guess misses, what's that cost?
- Can you think of a cheap modification to lower that cost?
- Is the distribution really linear?
- What's wrong with a "perfect hash function"?
- Does it need to be perfect?
Incidentally, hardware wins at this function. You can just generate logic to do all the if symbol == "XYZ": return 3's in parallel. |
|
... is anyone really using hardware to do this, by the way?
Hardware regexing at this scale is practically a COTS part, or was when I stopped doing network security products in '05.