When I run my original program on my own machine (instead of
Pasterack), the difference is more like 2-3x. So my original email
overstated the speed difference a bunch. I don't know what's going on
that makes it so different on pasterack.

An interesting side note -- we tried this program in Pycket, and two
interesting things happened:
 - it turned out to be another test case for a problem we are working
on right now -- memq was too slow because it was used previously with
different types
 - when that's fixed, memq and member are the same speed, because
Pycket's version of `eq?` is slower than it would be otherwise,
precisely because it has to maintain the semantics that Robby doesn't
like :)

Sam

On Sat, Sep 19, 2015 at 5:38 PM, Gustavo Massaccesi <gust...@oma.org.ar> wrote:
> There is something very strange with memq vs member:
> http://pasterack.org/pastes/80845  (note: I added one 0 to the loop
> constants)
>
> I used two mutable variables eq?? and equal?? to avoid (most of) the
> optimizations and I get that the time with equal? is 2x than the time
> with eq?. This is closer to the range I expected.
>
> Using directly eq? and equal? is slightly faster, and the time is the
> same because under the hood the optimizer transforms equal? to eq?
> when one of the arguments is an explicit symbol.
>
> The implementation of member and memq is very short but very
> entangled. I think that with some tweaks is possible to reduce the
> time difference to x2, and with some luck to make it more optimizer
> friendly and gain some additional speed.
>
> Gustavo
>
>
>
> On Thu, Sep 17, 2015 at 11:01 PM, Sam Tobin-Hochstadt
> <sa...@cs.indiana.edu> wrote:
>> Unfortunately, that's only true when eq? produces #t, which probably isn't
>> an issue when using eq? directly, but can be when using memq or similar.
>> This benchmark suggests about a 10x speed difference when the symbols are
>> different: http://pasterack.org/pastes/94877
>>
>> Sam
>>
>>
>> On Thu, Sep 17, 2015, 9:52 PM Robby Findler <ro...@eecs.northwestern.edu>
>> wrote:
>>>
>>> FWIW, if you use equal? in those cases, you'll get the same
>>> performance behavior and you will have fewer eq?s to audit when things
>>> go wonky.
>>>
>>> ;)
>>>
>>> Robby
>>>
>>> On Thu, Sep 17, 2015 at 8:36 PM, Neil Van Dyke <n...@neilvandyke.org>
>>> wrote:
>>> > Whew. :)  I only rarely have a non-symbol use for `eq?`, but I use `eq?`
>>> > heavily for symbols in everyday application code.
>>> >
>>> > Robby Findler wrote on 09/17/2015 09:27 PM:
>>> >>
>>> >> eq? on symbols is a special part of the specification and that seems
>>> >> benign to me, all things considered. The "giant hash in the sky" that
>>> >> makes sure that works isn't exactly trouble free, but we seem to have
>>> >> it under control.
>>> >
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Racket Users" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to racket-users+unsubscr...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to