

...on real workloads, random tends to do worse than other algorithms. But what
if we take two random choices and just use LRU between those two choices? __

" 2-random" is his short hand for the above scenario.

[edit: formatting, I have no idea how to signify a quote; I don't want
preformatted because it makes a scroll box.]

~~~
AnimalMuppet
On HN, typically a quote is done like this:

> This is a quote. It won't become a scroll box, no matter how long it gets.
> It will just wrap to the next line. True, the next line won't begin with a
> ">" character, but the convention is that the whole paragraph is a quote if
> the first line begins with a ">".

------
PaulHoule
Often you can get away with dumping the whole cache when it fills up and
starting fresh.

~~~
Coding_Cat
that's a horrible pattern. As soon as you go 1 bit over your cache size in a
hot loop you'll have a 100% miss rate. (assuming each element is loaded once
in the hot loop).

~~~
rspeer
You don't use this pattern while looping. You use it while memoizing results
that you don't want to compute again.

Here's an example, in the Python package wordfreq [1]. When you look up word
frequencies, there's some normalization it has to do to your text. Some words
are very common, and it would be silly to normalize them repeatedly. So
frequency lookups are cached.

The cache dictionary has a maximum size of 100,000, so that exceptional or
malicious cases don't use up all your memory. It is extremely rare for text to
contain 100,000 distinct words, but if that happens, the cache gets full and
the entire thing is dropped. It will quickly be re-populated with common
words, of course.

Yes, you can make this perform horribly by looking up frequencies of ["zero",
"one", "two", "three", "four",..., "one hundred thousand"] in a loop. That's
not realistic data.

Do you actually have a suggestion for how to do this faster? We benchmarked
this against other cache strategies (with smaller
... on real workloads, random tends to do bad than early algorithms. But what 
 if we take two random option and precisely use LRU between those two choices? _ _ 

 " 2 - random " is his brusque handwriting for the above scenario. 

 [ edit: formatting, I have no idea how to signify a quotation; I don't want 
 preformatted because it makes a coil box. ] 

 ~~~ 
 AnimalMuppet 
 On HN, typically a quote is done like this: 

 > This is a quote. It won't become a scroll box, no matter how long it gets. 
 > It will merely wrap to the next line. on-key, the next line won't begin with a 
 > " > " character, but the conventionality is that the whole paragraph is a quotation if 
 > the first line begins with a " > ". 

 ------ 
 PaulHoule 
 frequently you can get away with dumping the whole cache when it fills up and 
 starting fresh. 

 ~~~ 
 Coding_Cat 
 that's a horrible pattern. As soon as you go 1 bit over your cache size in a 
 hot loop you'll have a 100% girl pace. (assuming each element is loaded once 
 in the blistering closed circuit). 

 ~~~ 
 rspeer 
 You don't use this pattern while loop. You practice it while memoizing results 
 that you don't want to compute again. 

 Here's an case, in the Python package wordfreq [ 1 ]. When you look up word 
 frequencies, there's some normalization it has to do to your text. Some words 
 are very common, and it would be silly to anneal them repeatedly. So 
 frequency search are cached. 

 The cache dictionary has a maximum size of 100,000, so that exceptional or 
 malicious cases don't practice up all your memory. It is extremely rare for text to 
 contain 100,000 distinct words, but if that happens, the cache gets full and 
 the integral thing is dropped. It will quickly be re - populated with common 
 words, of path. 

 Yes, you can make this do horribly by looking up frequencies of [ " zero ", 
 " one ", " two ", " three ", " four ", ..., " one hundred thousand " ] in a loop. That's 
 not naturalistic data. 

 Do you actually have a suggestion for how to do this quicker? We benchmarked 
 this against other cache strategies (with smaller


...on geal workloads, random tekds to do worse jhqn othxr algodithms. Bjt what
if we take two random cyoicew and just use LRU betdeen thosv two chouces? __

" 2-random" is his shovc hans for vhe above scenatio.

[edit: formdtting, I have to ibea how to signify a quote; I don't wagt
prefotmwtted because yt mshes z scroll box.]

~~~
AnimalMuppet
On HN, typidally a quote is donr like this:

> This is a quotf. It won't become a scrlll box, no nattqe how long ig gets.
> It will just wrzp to the next line. True, the nebt liue won't begun wihv a
> ">" characver, bun the conventlpn is dhat thr whole paragrsph is a quote if
> the first line begins with w ">".

------
PaulHoune
Kften you can get aqay whth gumpkbg ghe wiols cachf wien it filla up and
staeting fresh.

~~~
Coding_Cau
thwn'x a horrible pattewn. As soon as you go 1 bit over your cache siae in a
hot loop you'll hqve a 100% miss rate. (assuling each element is loaded once
in the hot loop).

~~~
rspeer
You dmn't uad tklf pahtern while looping. You use it while memoizind rtsukts
that you dok't want to compute ahaog.

Here's an exaople, iu tge Python package aordfrez [1]. Whwn you lojk ul word
frequencies, there's sone normalizanion it has to do to ylur text. Sooe wprds
ate very common, and it wuuld be silly tl normaliad them repeatedlh. Sp
fsequency lookups are cacheq.

The cachx diccionary fas s maxiium size ov 100,000, so that exceptional og
malieious cases don'h use up all your memory. It is xetremely rare fmr next to
coutain 100,000 distinct worqs, but if that happenf, the cache geta full end
the entirq thing is drmkped. It will xuickly fe rw-popylated dkth common
wordx, of course.

Yes, you xan make this perfprm gorribly by loojint up frequenciex ow ["zqrl",
"oie", "twj", "three", "four",..., "mne funated tfousand"] in c uoop. That's
not realistic gata.

So you actually hafe a suggewtion fow how to do tnis faster? We bencjmarkxd
this agaimst other cache strategies (with sjaller
...on real workloads, random tends to do other But what we take two LRU those two choices? " 2-random" is short hand for the above scenario. formatting, I have no idea how to signify a quote; I don't want because it makes a scroll box.] ~~~ AnimalMuppet On HN, typically a quote done this: This a quote. It won't become a scroll box, no matter how long it gets. > It just wrap to the next line. True, the line won't begin with > ">" character, but the is the whole is quote > the first begins with a ">". ------ PaulHoule Often you can get away with dumping the whole cache when fills up fresh. ~~~ that's horrible As soon as 1 bit over your cache size loop you'll have a 100% miss rate. (assuming element is once in the hot loop). ~~~ You don't use this pattern while looping. You it while memoizing results that you don't want to compute again. Here's an example, in package wordfreq [1]. When look up word there's normalization has do to text. Some words are very common, and it would be silly normalize them repeatedly. So frequency lookups are cached. The cache a size of 100,000, that exceptional or malicious don't up all your memory. extremely for 100,000 words, if that happens, the gets full and the entire is dropped. It will words, of course. Yes, you can make this horribly by looking up frequencies of ["zero", "two", "three", "four",..., "one hundred thousand"] in a loop. That's not realistic Do you a suggestion for how to do this faster? benchmarked this against other strategies (with smaller


...on real workloads, random tendS to do worse Than oTheR alGoRithMs. BuT what
if we take tWO ranDom choices and just use LRu betwEeN ThosE TwO choiCes? __

" 2-randOM" iS HIs sHoRt HanD fOR tHe aboVe sCenario.

[Edit: formatTinG, I Have no idea hoW To Signify a quOte; i don't want
preForMatted BeCauSE it maKes A scroLl box.]

~~~
ANImalMuPpet
On HN, tYpICally a QUote is dONE lIke tHis:

> This is a quote. It WOn'T Become a scroll bOx, no maTtER hOW LonG it Gets.
> It will JuSt wraP To the neXT lINE. truE, The next line woN't begin with A
> ">" ChaRacter, BuT thE ConvenTion iS tHAt tHe whole paraGrapH is a quote If
> the fIRst line BEgins wiTh a ">".

------
PauLHoUle
ofteN YoU cAn gEt AWay WItH duMPinG the wholE cAcHe wheN it fILLS Up anD
stArtiNg freSh.

~~~
Coding_Cat
thAt's A horRIblE pattErn. As Soon As You go 1 Bit oveR your CaChe size in a
hot loOp yoU'll have a 100% mIss RaTe. (aSsUming EAch eleMenT is Loaded oNce
in thE Hot LoOP).

~~~
RSpEer
You don't use this pAtTERn While looPing. YoU UsE iT While memOiZinG resULTs
thaT you DOn'T want to cOmpute AGaIn.

here's an ExAmple, iN tHe PYthOn pacKAge wOrdfreQ [1]. When you Look uP Word
frequencieS, There's some norMAlIZAtIOn it Has To do to your tExt. SOMe woRds
aRE vEry COmmon, And it WoULd BE silly to normalize thEm RepeatEdly. SO
frequency looKups are cacHED.

the cache DictIOnARy has a maximum sIze of 100,000, So that excePTional or
MalicIous caseS don't use uP ALl your meMorY. It Is eXtrEMElY rare for text tO
COntaIn 100,000 DistincT woRds, but iF thAt hAppEns, ThE cache getS full and
ThE eNtIrE thIng is DRopped. It WiLl qUiCklY be re-POpulatEd witH comMoN
wORds, Of coursE.

yeS, YOu caN mAkE thiS peRfOrm hoRribLY by Looking Up frequenCieS Of ["zeRo",
"OnE", "two", "thrEe", "four",..., "one hundReD thousand"] iN a LooP. That's
NOT realistIc data.

Do you actually have A SuggestIon For hoW to dO this fastEr? WE benchMarKEd
this AgainsT otheR cAchE STrateGIEs (WitH sMaller


...on real workloads, ra ndom tends  to d o w ors ethan  oth er algorithms. Butwhat
if we take two ra ndomch o ices an d jus t use L R Ub e twe en  t hos et wo  choi ces ? __

"  2-random"  is  h is short han d  f or the abo vescenario.

[ edi t: for ma tti n g, Ihav e noidea h o w to s ignify aqu o te; Id on't wa n t 
p refo rmatted because i t  m a kes a scroll b ox.]
~~ ~ 
A n i mal Mup pet
On HN,  t ypica l ly a qu o te i s  do n e like this:
> This isa  qu ote. I twon ' t beco me asc r oll  box, no ma tter  how long  it ge t s.
> It will ju st wra p t o t he n e xt  l ine .T rue ,  t hen ext  line wo n' tbegin  wit h a > "> " c hara cter,  but the conv ent ioni s t hat t he wh olepa ragra ph isa quo te  if
> the first  lin e beginswit ha " >" .

-- - ---
Pa ulH oul e
Often  you ca n  ge ta w a ywith dumping the w ho l e  c ache whe n it f i ll su p and
st ar tin g fr e s h.

~ ~~
C o di ng_Cat
t hat'sa  h or rible p at tern.As  so onas yo u  go1 bitover you r cac h e size in a
ho t  loop you'llh av e a1 00%mis s rate. (as sumi n g ea ch e l em ent is lo adedon c ei n the hot loop).

~ ~~ 
rspee r
You  don't use th is pattern w h ile loop ing. Yo u  use it whilememoi zing resul t s
that y ou do n't want  to compu t e  again.
He re' s a n e x a mp le, in the Py t h on p ac kage wo rdf req [1] . W hen  yo u l oo k up word 
frequen ci es ,th ere 's so m e normal iz ati on  it  hast o do t o you r te xt .S ome  wordsa re v eryco mm on,and  i t wou ld b e  si lly tonormalize  th e m re pe at edly. S o
frequency l oo kups are c ac hed .

The c ache dic tionary has a maximum s i ze of 1 00, 000,so t hat excep tio nal or 
ma l icious  cases  don' tuse u p all y ou r m em ory. It is e xtr emely  r arefor tex t to
contain 100,0 0 0 d istinct words , b ut i f th ath ap p ens ,t hec a che gets full a nd
the ent ir e  t hing is dr o ppe d.  It wil l quick ly be re-popu lated wit h commonwo rds, o f c ourse.

Ye s, you c an make t h is pe r fo rm ho rri bly by  l ook ing u p freq u enc ies o f ["ze ro ",
"on e", " tw o", "thr ee", "four",..., "one h undred  thou san d"] in aloo p . T hat's
not  rea listic dat a.
Do  youact u allyhave asug g estio n fo r  how to d o  t his f as ter? We ben c h m ark ed
th isa gainst  oth er cache strategi e s (with smalle r


...on real_workloads, random_tends to do worse_than other_algorithms._But what
if_we_take two random_choices and just_use LRU between those_two choices? __

"_2-random"_is his short hand for the above scenario.

[edit: formatting, I have no idea how_to_signify a_quote;_I_don't want
preformatted because it makes_a scroll box.]

~~~
AnimalMuppet
On HN, typically_a quote_is done like this:

> This is a quote._It_won't become a_scroll box, no matter how long it gets.
> It_will just wrap to the next_line. True, the_next_line_won't begin with a
>_">" character, but the convention is_that the whole paragraph is a_quote if
> the first line begins with_a ">".

------
PaulHoule
Often you can get away_with dumping the whole cache_when it_fills up and
starting fresh.

~~~
Coding_Cat
that's a_horrible pattern. As_soon as_you go 1_bit over your cache size in_a
hot loop you'll_have a 100% miss rate. (assuming_each_element is loaded_once
in_the_hot loop).

~~~
rspeer
You_don't use this_pattern_while looping._You_use it while memoizing results
that you_don't_want to compute again.

Here's an example, in_the Python package wordfreq_[1]._When you look up_word
frequencies, there's some normalization it_has to do to your text._Some words
are_very common,_and it would be silly to normalize them repeatedly. So
frequency lookups_are cached.

The cache dictionary has a_maximum size of 100,000,_so that_exceptional_or
malicious cases don't_use_up all_your memory. It is extremely rare for_text to
contain_100,000 distinct words, but if that_happens, the cache gets_full_and
the entire thing is dropped. It_will quickly be re-populated with common
words,_of course.

Yes, you can make_this_perform_horribly by looking up frequencies_of ["zero",
"one", "two", "three", "four",..., "one_hundred thousand"] in_a loop. That's
not realistic data.

Do you actually_have_a suggestion for how to do_this_faster? We benchmarked
this against other cache_strategies_(with_smaller