Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Destructuring and keyword access
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christophe Grand  
View profile  
 More options Oct 23 2012, 5:18 am
From: Christophe Grand <christo...@cgrand.net>
Date: Tue, 23 Oct 2012 11:18:27 +0200
Local: Tues, Oct 23 2012 5:18 am
Subject: Destructuring and keyword access

Hi,

Currently associative destructuring always expands to calls to get even
when the key is a keyword.
I have a small patch which make it expands to direct keyword lookups.
May I open an issue for that?

Thanks,

Christophe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Oct 23 2012, 7:45 am
From: Tassilo Horn <t...@gnu.org>
Date: Tue, 23 Oct 2012 13:45:00 +0200
Subject: Re: Destructuring and keyword access

Christophe Grand <christo...@cgrand.net> writes:

Hi Christophe,

> Currently associative destructuring always expands to calls to get
> even when the key is a keyword.  I have a small patch which make it
> expands to direct keyword lookups.

What's the benefit of that?  At least a quick benchmark seems to
indicate that the performance is equal.

--8<---------------cut here---------------start------------->8---
user=> (use 'criterium.core)
nil
user=> (let [m {:a 1, :b 2, :c 3, :d 4, :e 5, :f 6, :g 7, :h 8}]
         (bench (get m :g))
         (bench (:g m)))
Evaluation count : 173624160 in 60 samples of 2893736 calls.
             Execution time mean : 353.140625 ns
    Execution time std-deviation : 26.118695 ns
   Execution time lower quantile : 339.868576 ns ( 2.5%)
   Execution time upper quantile : 374.317787 ns (97.5%)

Found 4 outliers in 60 samples (6.6667 %)
        low-severe       2 (3.3333 %)
        low-mild         2 (3.3333 %)
 Variance from outliers : 55.1380 % Variance is severely inflated by outliers
Evaluation count : 166152240 in 60 samples of 2769204 calls.
             Execution time mean : 368.768440 ns
    Execution time std-deviation : 14.631760 ns
   Execution time lower quantile : 357.451880 ns ( 2.5%)
   Execution time upper quantile : 398.427724 ns (97.5%)

Found 2 outliers in 60 samples (3.3333 %)
        low-severe       2 (3.3333 %)
 Variance from outliers : 25.4904 % Variance is moderately inflated by outliers
nil
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options Oct 23 2012, 8:42 am
From: Christophe Grand <christo...@cgrand.net>
Date: Tue, 23 Oct 2012 14:42:51 +0200
Local: Tues, Oct 23 2012 8:42 am
Subject: Re: Destructuring and keyword access

Direct keyword lookups are optimized call sites for types implementing
IKeywordLookup (eg records).

=> (use 'criterium.core)
nil
=> (defrecord R [a b c d e f g h])
bench.core.R
=> (let [m (R. 1 2 3 4 5 6 7 8)]
     (bench (get m :g))
     (bench (:g m)))
Evaluation count : 330878040 in 60 samples of 5514634 calls.
             Execution time mean : 188,486839 ns
    Execution time std-deviation : 12,514961 ns
   Execution time lower quantile : 179,788178 ns ( 2,5%)
   Execution time upper quantile : 220,171461 ns (97,5%)

Found 6 outliers in 60 samples (10,0000 %)
    low-severe     2 (3,3333 %)
    low-mild     4 (6,6667 %)
 Variance from outliers : 50,0898 % Variance is severely inflated by
outliers
Evaluation count : 503316480 in 60 samples of 8388608 calls.
             Execution time mean : 121,512183 ns
    Execution time std-deviation : 13,544785 ns
   Execution time lower quantile : 116,452694 ns ( 2,5%)
   Execution time upper quantile : 130,043954 ns (97,5%)

Found 8 outliers in 60 samples (13,3333 %)
    low-severe     4 (6,6667 %)
    low-mild     4 (6,6667 %)
 Variance from outliers : 73,8211 % Variance is severely inflated by
outliers
nil

Christophe

--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Oct 23 2012, 9:14 am
From: Tassilo Horn <t...@gnu.org>
Date: Tue, 23 Oct 2012 15:14:04 +0200
Local: Tues, Oct 23 2012 9:14 am
Subject: Re: Destructuring and keyword access

Christophe Grand <christo...@cgrand.net> writes:
> Direct keyword lookups are optimized call sites for types implementing
> IKeywordLookup (eg records).

Ah, ok, that makes a lot of sense.

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options Oct 23 2012, 10:08 am
From: Christophe Grand <christo...@cgrand.net>
Date: Tue, 23 Oct 2012 16:08:36 +0200
Local: Tues, Oct 23 2012 10:08 am
Subject: Re: Destructuring and keyword access

On a related subject: may I open an issue to have PersistentHashMap to
implement IKeywordLookup? It proves to be more efficient (nearly halves the
lookup time)  than I would have thought.

Christophe

On Tue, Oct 23, 2012 at 11:18 AM, Christophe Grand <christo...@cgrand.net>wrote:

> Hi,

> Currently associative destructuring always expands to calls to get even
> when the key is a keyword.
> I have a small patch which make it expands to direct keyword lookups.
> May I open an issue for that?

> Thanks,

> Christophe

--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon Bloom  
View profile  
 More options Oct 23 2012, 2:27 pm
From: Brandon Bloom <snprbo...@gmail.com>
Date: Tue, 23 Oct 2012 11:27:19 -0700 (PDT)
Local: Tues, Oct 23 2012 2:27 pm
Subject: Re: Destructuring and keyword access

> Direct keyword lookups are optimized call sites for types implementing

IKeywordLookup (eg records).

Wouldn't it be preferable to enhance the call optimization, rather than the
destructuring code generation?

If you make this enhancement to the call site optimizer, then the
improvement is automatically available to any other macros that generate
associative lookups. Consider pattern matching, unification, and other
value extracting forms.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options Oct 24 2012, 10:03 am
From: Christophe Grand <christo...@cgrand.net>
Date: Wed, 24 Oct 2012 16:03:19 +0200
Local: Wed, Oct 24 2012 10:03 am
Subject: Re: Destructuring and keyword access

You are right: in addition to the proposed change to destructure, the
inline expansion of get should be modified to emit direct keyword lookups
when possible.

Christophe

On Tue, Oct 23, 2012 at 8:27 PM, Brandon Bloom <snprbo...@gmail.com> wrote:
> > Direct keyword lookups are optimized call sites for types implementing
> IKeywordLookup (eg records).

> Wouldn't it be preferable to enhance the call optimization, rather than
> the destructuring code generation?

> If you make this enhancement to the call site optimizer, then the
> improvement is automatically available to any other macros that generate
> associative lookups. Consider pattern matching, unification, and other
> value extracting forms.

--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon Bloom  
View profile  
 More options Oct 25 2012, 12:25 pm
From: Brandon Bloom <snprbo...@gmail.com>
Date: Thu, 25 Oct 2012 09:25:27 -0700 (PDT)
Local: Thurs, Oct 25 2012 12:25 pm
Subject: Re: Destructuring and keyword access

Why "in addition to" vs "instead of"? If 'get expands inline to a direct
keyword lookup on (keyword? key), then there is no reason to bypass 'get
during destructuring.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
 More options Oct 29 2012, 7:59 am
From: Rich Hickey <richhic...@gmail.com>
Date: Mon, 29 Oct 2012 07:58:55 -0400
Local: Mon, Oct 29 2012 7:58 am
Subject: Re: Destructuring and keyword access

On Oct 23, 2012, at 5:18 AM, Christophe Grand wrote:

> Hi,

> Currently associative destructuring always expands to calls to get even when the key is a keyword.
> I have a small patch which make it expands to direct keyword lookups.
> May I open an issue for that?

Yes, thanks.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
 More options Oct 29 2012, 8:03 am
From: Rich Hickey <richhic...@gmail.com>
Date: Mon, 29 Oct 2012 08:03:12 -0400
Local: Mon, Oct 29 2012 8:03 am
Subject: Re: Destructuring and keyword access

On Oct 23, 2012, at 10:08 AM, Christophe Grand wrote:

> On a related subject: may I open an issue to have PersistentHashMap to implement IKeywordLookup? It proves to be more efficient (nearly halves the lookup time)  than I would have thought.

Do you have a gist or something outlining the approach? What you are saying here is not enough to go on.

Thanks,

Rich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options Oct 29 2012, 9:06 am
From: Christophe Grand <christo...@cgrand.net>
Date: Mon, 29 Oct 2012 14:06:42 +0100
Local: Mon, Oct 29 2012 9:06 am
Subject: Re: Destructuring and keyword access

Thanks, done: http://dev.clojure.org/jira/browse/CLJ-1096

--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options Oct 29 2012, 11:12 am
From: Christophe Grand <christo...@cgrand.net>
Date: Mon, 29 Oct 2012 16:12:10 +0100
Local: Mon, Oct 29 2012 11:12 am
Subject: Re: Destructuring and keyword access

On Mon, Oct 29, 2012 at 1:03 PM, Rich Hickey <richhic...@gmail.com> wrote:

> On Oct 23, 2012, at 10:08 AM, Christophe Grand wrote:

> > On a related subject: may I open an issue to have PersistentHashMap to
> implement IKeywordLookup? It proves to be more efficient (nearly halves the
> lookup time)  than I would have thought.

> Do you have a gist or something outlining the approach? What you are
> saying here is not enough to go on.

Sure, so, here is a patch:
https://github.com/cgrand/clojure/commit/8c483f76cf7abb26db15fd7fb814...

And some quick measures:

=> (let [m (reduce #(assoc % (keyword (str %2)) %2) {}
"abcdefghijklmnopqr")]
    (time
      (dotimes [_ 1e8] (:k m)))
    (time
      (dotimes [_ 1e8] (get m :k))))
"Elapsed time: 5838.101 msecs"
"Elapsed time: 16338.974 msecs"
nil

As I said I didn't expected that much of a boost.

Christophe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »