Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Tunable parameters in dictobject.c (was dictnotes.txt out of date?)

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


mark at hotpy

Jun 13, 2012, 2:37 PM

Post #1 of 15 (322 views)
Permalink
Tunable parameters in dictobject.c (was dictnotes.txt out of date?)

Raymond Hettinger wrote:
>
> On Jun 13, 2012, at 10:35 AM, Eli Bendersky wrote:
>
>> Did you mean to send this to the list, Raymond?
>
>
> Yes. I wanted to find-out whether someone approved changing
> all the dict tunable parameters. I thought those weren't supposed
> to have changed. PEP 412 notes that the existing parameters
> were finely tuned and it did not make recommendations for changing them.

The PEP says that the current (3.2) implementation is finely tuned.
No mention is made of tunable parameters.

>
> At one point, I spent a full month testing all of the tunable parameters
> using dozens of popular Python applications. The values used in Py3.2
> represent the best settings for most apps.

Best in terms of speed, but what about memory use?

> They should not have been
> changed without deep thought and substantial testing.

I have thought about it, a lot :)
I have also tested it, using the Unladen Swallow benchmarks.
Additional (realistic) tests would be appreciated.

>
> The reduction of the dict min size has an immediate impact on code
> using multiple keyword arguments.

There is no change to the minimum size for combined-table (old style)
dictionaries.

>
> The reduced growth rate (from x4 to x2) negatively impacts apps that
> have a dicts with a steady size but constantly changing keys
> (removing an old key and adding a new one). The lru_cache is
> an example. The reduced growth causes it to resize much more
> frequently than before.

Resizing was probably the part of the implementation that took the most
time.

I had gained the impression from comments on this list,
comments on the tracker and the web in general that the memory
consumption of CPython was more of an issue than its performance.
So my goal was to minimise memory usage without any significant slowdown
(< 1% slowdown).

The problem with resizing is that you don't know when it is going to
stop. A bigger growth factor means fewer resizes, but more of a
potential overshoot (a larger final size than required).
So in order to reduce memory use a growth factor of x2 is required.

Split-table dicts are (to a first-order approximation) never resized
so the growth factor for them should as small as possible; x2.

Combined-table dicts are more challenging. Reducing the growth rate to
x2 increases the number of resizes by x2 or (x2-1) *and* increases the
number of items per resize by about 50%.
But it is not the number of resizes that matters, it is the time spent
performing those resizes.
I went to considerable effort to improve the performance of dictresize()
so that even benchmarks that create a lot of short-lived medium-to-large
sized combined-table dicts do not suffer impaired performance.

It would be possible to split the growth factor into two: one for
split-tables (which would be x2) and one for combined tables.

But which is better for combined tables, x4 or x2?
What is the relative value of speed and memory consumption?
50% less memory and 1% slower is good. 1% less memory and 50% slower is
bad. But what about intermediate values?

I think that for combined tables a growth factor of x2 is best,
but I don't have any hard evidence to back that up.

>
> I think the tunable parameters should be switched back to what they
> were before. Tim and others spent a lot of time getting those right
> and my month of detailed testing confirmed that those were excellent
> choices.

They may have been excellent choices for the previous implementation.
They are not necessarily the best for the new implementation.

The current parameters seem to be the best for the new implementation.
When Django and Twisted run on Python3, then it might be worthwhile to
do some more experimentation.

>
> The introduction of Mark's shared-key dicts was orthogonal to the
> issue of correct parameter settings. Those parameters did not have
> to change and probably should not have been changed.

Parameters for tuning code and the code itself are unlikely to be
orthogonal. While I did strive to minimise the impact of the changes on
combined-table dicts, the performance characteristics have necessarily
changed.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


raymond.hettinger at gmail

Jun 13, 2012, 6:15 PM

Post #2 of 15 (314 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Jun 13, 2012, at 2:37 PM, Mark Shannon wrote:

> I think that for combined tables a growth factor of x2 is best,
> but I don't have any hard evidence to back that up.


I believe that change should be reverted.
You've undone work that was based on extensive testing and timings of many python apps.
In particular, it harms the speed of building-up all large dictionaries,
and it greatly harms apps with steady-size dictionaries with changing keys.

The previously existing parameter were well studied
and have been well-reviewed by the likes of Tim Peters.
They shouldn't be changed without deep thought and study.
Certainly, "I think a growth factor of x2 is best" is insufficient.


Raymond

P.S. In the tracker discussion of key-sharing dict, you were asked
to NOT change the tunable parameters. I'm not sure why you
went ahead and did it anyway.


tjreedy at udel

Jun 13, 2012, 7:22 PM

Post #3 of 15 (314 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On 6/13/2012 9:15 PM, Raymond Hettinger wrote:
>
> On Jun 13, 2012, at 2:37 PM, Mark Shannon wrote:
>
>> I think that for combined tables a growth factor of x2 is best,
>> but I don't have any hard evidence to back that up.
>
> I believe that change should be reverted.
> You've undone work that was based on extensive testing and timings of
> many python apps.
> In particular, it harms the speed of building-up all large dictionaries,
> and it greatly harms apps with steady-size dictionaries with changing keys.
>
> The previously existing parameter were well studied
> and have been well-reviewed by the likes of Tim Peters.
> They shouldn't be changed without deep thought and study.
> Certainly, "I think a growth factor of x2 is best" is insufficient.

The use cases 'directly used dict that is possibly the primary data
structure and possibly gigabytes in size' is sufficiently different from
'hidden instance dicts that are typically a small, constant size (for a
given class) but possibly repeated a million times' are sufficiently
different that different tuning parameters might be appropriate. So I
agree with Raymond think you should leave the parameters for the
standard dicts alone until there is good evidence for a change. (Good ==
apparent to more than just one person ;-).

If you improved the resize speed of standard dicts, great. However, that
does not necessarily mean that the resize factor should change.

[clipped by Raymond]

>> I had gained the impression from comments on this list,
>> comments on the tracker and the web in general that the memory
>> consumption of CPython was more of an issue than its performance.

In 16 years, I seemed to have missed that. I assure you there are many
who feel the opposite.

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mark at hotpy

Jun 14, 2012, 3:45 AM

Post #4 of 15 (313 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

Raymond Hettinger wrote:
>
> On Jun 13, 2012, at 2:37 PM, Mark Shannon wrote:
>
>> I think that for combined tables a growth factor of x2 is best,
>> but I don't have any hard evidence to back that up.
>
> I believe that change should be reverted.
> You've undone work that was based on extensive testing and timings of
> many python apps.
> In particular, it harms the speed of building-up all large dictionaries,
> and it greatly harms apps with steady-size dictionaries with changing keys.
>
> The previously existing parameter were well studied
> and have been well-reviewed by the likes of Tim Peters.
> They shouldn't be changed without deep thought and study.
> Certainly, "I think a growth factor of x2 is best" is insufficient.

Indeed, "I think a growth factor of x2 is best" is insufficient,
but so is "based on extensive testing and timings of many python apps"
unless you provide those timings and apps.

So here is some evidence.
I have compared tip (always resize by x2) with a x4 variant
(resize split-dict x2 and combined-dicts x4).

All benchmarks from http://hg.python.org/benchmarks/
For my old 32bit machine, numbers are for the x4 variant relative to tip.

For the 2n3 suite (24 micro benchmarks)
Average speed up: None (~0.05% on average)
Average memory use +4%.

GC: 1% faster, no change to memory use.
Mako: 4% slower, 4% more memory
2to3: 3% faster, 32% more memory.

Overall: No change to speed, 5% more memory.

The results seem to indicate that resizing is now sufficiently fast
that changing from x4 to x2 makes no difference in terms of speed.
However, for some programs (notable 2to3) the change from x4 to x2 can
save a lot of memory.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


kristjan at ccpgames

Jun 14, 2012, 4:32 AM

Post #5 of 15 (323 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

FYI, I had to visit those parameters for my PS3 port and cut down on the bombastic memory footprint of 2.7 dicts.
Some the supposedly tunable parameters aren´t tunable at all.
See http://blog.ccpgames.com/kristjan/2012/04/25/optimizing-the-dict/
Speed and memory are most often conflicting requirements. I would like to two or more compile time
settings to choose from: Memory optimal, speed optimal, (and mix).

Cheers,
K
> -----Original Message-----
> From: python-dev-bounces+kristjan=ccpgames.com [at] python
> [mailto:python-dev-bounces+kristjan=ccpgames.com [at] python] On
> Behalf Of Mark Shannon
> Sent: 13. júní 2012 21:37
> To: python-dev [at] python
> Subject: [Python-Dev] Tunable parameters in dictobject.c (was dictnotes.txt
> out of date?)
>
> Raymond Hettinger wrote:
> >
> > On Jun 13, 2012, at 10:35 AM, Eli Bendersky wrote:
> >
> >> Did you mean to send this to the list, Raymond?
> >
> >
> > Yes. I wanted to find-out whether someone approved changing
> > all the dict tunable parameters. I thought those weren't supposed
> > to have changed. PEP 412 notes that the existing parameters were
> > finely tuned and it did not make recommendations for changing them.
>
> The PEP says that the current (3.2) implementation is finely tuned.
> No mention is made of tunable parameters.
>
> >
> > At one point, I spent a full month testing all of the tunable
> > parameters using dozens of popular Python applications. The values
> > used in Py3.2 represent the best settings for most apps.
>
> Best in terms of speed, but what about memory use?
>


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


raymond.hettinger at gmail

Jun 14, 2012, 7:01 AM

Post #6 of 15 (310 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Jun 14, 2012, at 4:32 AM, Kristján Valur Jónsson wrote:

> I would like to two or more compile time
> settings to choose from: Memory optimal, speed optimal, (and mix).

A compile time option would be nice.

The default should be what we've had though.
The new settings cause a lot more collisions
and resizes. The resizes themselves have more
collisions than before (there are few collisions
when resizing into a quadrupled dict than into
a doubled dict).

Dicts get their efficiency from sparseness.
Reducing the mindict size from 8 to 4 causes
substantially more collisions in small dicts
and gets closer to a linear search of a small tuple.


Raymond


martin at v

Jun 18, 2012, 12:20 AM

Post #7 of 15 (291 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

> The default should be what we've had though.
> The new settings cause a lot more collisions
> and resizes.

Raymond, can you kindly point to an application that demonstrates this
claim (in particular the "a lot more" part, which I'd translate to
"more than 20% more").

I'm fine with reverting changes, but I agree that any benchmarking
performed should be repeatable, and public. I agree it's sad to see
a month worth of benchmarking reverted - but had that benchmarking
been documented publicly, rather than just reporting the outcome,
such reversal might have been avoided.

> Dicts get their efficiency from sparseness.
> Reducing the mindict size from 8 to 4 causes
> substantially more collisions in small dicts
> and gets closer to a linear search of a small tuple.

Why do you think the dictsize has been reduced from 8 to 4? It has not.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mark at hotpy

Jun 18, 2012, 7:28 AM

Post #8 of 15 (285 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

Martin v. Löwis wrote:
>> The default should be what we've had though.
>> The new settings cause a lot more collisions
>> and resizes.
>
> Raymond, can you kindly point to an application that demonstrates this
> claim (in particular the "a lot more" part, which I'd translate to
> "more than 20% more").

It is quite easy to find a program that results in a lots more resizes.
The issue is not whether there are more resizes, but whether it is
faster or slower. The evidence suggests that the new default settings
are no slower and reduce memory use.

>
> I'm fine with reverting changes, but I agree that any benchmarking
> performed should be repeatable, and public. I agree it's sad to see
> a month worth of benchmarking reverted - but had that benchmarking
> been documented publicly, rather than just reporting the outcome,
> such reversal might have been avoided.
>
>> Dicts get their efficiency from sparseness.

But do they? The results of benchmarking would seem to suggest (at least
on my test machine) that overly-sparse dicts are slower.
Possibly due to increased cache misses.

>> Reducing the mindict size from 8 to 4 causes
>> substantially more collisions in small dicts
>> and gets closer to a linear search of a small tuple.
>
> Why do you think the dictsize has been reduced from 8 to 4? It has not.

For combined tables it remains 8 as before.

For split tables it *has* been reduced to 4.
This will increase collisions, and it is possible that a linear search would
be faster for these very small dictionaries.
However, a 4 entry table fits into a single cache line (for a 64 byte cache
line on a 32 bit machine) which may save a lot of cache misses.
But this all conjecture. Whatever the reason, the current parameters give
the best performance empirically.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


solipsis at pitrou

Jun 18, 2012, 8:04 AM

Post #9 of 15 (284 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Mon, 18 Jun 2012 15:28:24 +0100
Mark Shannon <mark [at] hotpy> wrote:
>
> But do they? The results of benchmarking would seem to suggest (at least
> on my test machine) that overly-sparse dicts are slower.
> Possibly due to increased cache misses.

Or, at least, they are not faster. See the synthetic experiments in
http://bugs.python.org/issue10408

That said, Raymond might have witnessed different results at the time.
Hardware evolves quickly and the parameters change (memory latency
today is at least 50+ CPU cycles, which is quite a lot of wasted work on
a pipelined superscalar CPU).

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


fijall at gmail

Jun 18, 2012, 12:31 PM

Post #10 of 15 (280 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Mon, Jun 18, 2012 at 5:04 PM, Antoine Pitrou <solipsis [at] pitrou> wrote:

> On Mon, 18 Jun 2012 15:28:24 +0100
> Mark Shannon <mark [at] hotpy> wrote:
> >
> > But do they? The results of benchmarking would seem to suggest (at least
> > on my test machine) that overly-sparse dicts are slower.
> > Possibly due to increased cache misses.
>
> Or, at least, they are not faster. See the synthetic experiments in
> http://bugs.python.org/issue10408
>
> That said, Raymond might have witnessed different results at the time.
> Hardware evolves quickly and the parameters change (memory latency
> today is at least 50+ CPU cycles, which is quite a lot of wasted work on
> a pipelined superscalar CPU).
>
> Regards
>
> Antoine.
>
>
More like 200-500 CPU cycles on modern CPUs.


solipsis at pitrou

Jun 18, 2012, 12:35 PM

Post #11 of 15 (280 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Mon, 18 Jun 2012 21:31:27 +0200
Maciej Fijalkowski <fijall [at] gmail> wrote:
> On Mon, Jun 18, 2012 at 5:04 PM, Antoine Pitrou <solipsis [at] pitrou> wrote:
>
> > On Mon, 18 Jun 2012 15:28:24 +0100
> > Mark Shannon <mark [at] hotpy> wrote:
> > >
> > > But do they? The results of benchmarking would seem to suggest (at least
> > > on my test machine) that overly-sparse dicts are slower.
> > > Possibly due to increased cache misses.
> >
> > Or, at least, they are not faster. See the synthetic experiments in
> > http://bugs.python.org/issue10408
> >
> > That said, Raymond might have witnessed different results at the time.
> > Hardware evolves quickly and the parameters change (memory latency
> > today is at least 50+ CPU cycles, which is quite a lot of wasted work on
> > a pipelined superscalar CPU).
> >
> > Regards
> >
> > Antoine.
> >
> >
> More like 200-500 CPU cycles on modern CPUs.

You are right. I was thinking 50 nanoseconds (which for a - relatively
high-end - 3GHz CPU puts us at 150 cycles).

Regards

Antoine.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


raymond.hettinger at gmail

Jun 18, 2012, 1:46 PM

Post #12 of 15 (281 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Jun 18, 2012, at 12:35 PM, Antoine Pitrou wrote:

> You are right. I was thinking 50 nanoseconds (which for a - relatively
> high-end - 3GHz CPU puts us at 150 cycles).

The last guidance I read from Intel said that
a cache miss was roughly as expensive as a floating-point divide.

When a dictionary is less sparse, it has more collisions
which means there are more cache misses.

Resizing into a dictionary growing at 2x means that we're going
from 2/3 full to 1/3 full and resizing at 4x means going from 2/3
full to 1/6 full. That latter will have fewer collisions (that said,
one-third full is still very good). So, the performance is worse
but not much worse.

For dictionaries large enough to require multiple resizes,
the 4x factor cuts the number of resizes in half and makes
each resize faster (because of few collisions). Only the
growth phase is affected though.

It is more problematic for use cases such as caching where
a dict is constantly deleting old entries to make space for
new ones. Such a dict never reaches a steady-state
because the dummy entries accumulate and trigger a resize.
Under the 2x scheme this happens much more often.

Under the 4x scheme, some dicts are left larger (more sparse)
than they otherwise would be (i.e. formerly it grew 8, 32, 128, ...)
and now it grows to (8, 16, 32, 64, ...). Some dicts will end-up
the same dicts. Others might fit in 16 rather than 32. That
decreases their sparsity, increases the number of collisions,
and slows the lookup speed. The effect is not large though
(the number of collisions between 1/4 full and 1/2 full is better
but 1/2 is still pretty good).

In the timings, I had done a few years ago, the results were that
just about anything that increased the number of collisions or
resizings would impact performance. I expect that effect will
be accentuated on modern processors but I'll have to do updated
tests to be sure.

From a high-level view, I question efforts to desparsify dictionaries.
When you have a bucket of water, the weight is in the water, not
in the bucket itself. The actual keys and values dominate dict size
unless you're reusing the same values over and over again.

That said, the 4x growth factor was capped at 50,000. For larger
dicts it fell back to 2x. Some the only dicts affected by the 2x vs 4x
decision lie by in the 6 to 50k ranges. The only apps that see any
noticeable difference in memory size are ones that have many
dicts of that size range alive at the same time.

Sorry I can make a more detailed post right now. I'll make time in
the next couple of weeks to post some code and timings that
document the collision counts, total memory size, and its affect
on various dict use cases.


Raymond


steve at pearwood

Jun 18, 2012, 2:08 PM

Post #13 of 15 (281 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

Raymond Hettinger wrote:

> Sorry I can make a more detailed post right now. I'll make time in
> the next couple of weeks to post some code and timings that
> document the collision counts, total memory size, and its affect
> on various dict use cases.


Is there some way to instrument dictionary sparseness, number of hits and
misses, etc. from Python?

A secret command-line switch, perhaps, or a compile-time option?

And if there isn't, perhaps there should be.


--
Steven



_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


solipsis at pitrou

Jun 18, 2012, 2:11 PM

Post #14 of 15 (283 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On Mon, 18 Jun 2012 13:46:25 -0700
Raymond Hettinger <raymond.hettinger [at] gmail> wrote:
>
> On Jun 18, 2012, at 12:35 PM, Antoine Pitrou wrote:
>
> > You are right. I was thinking 50 nanoseconds (which for a - relatively
> > high-end - 3GHz CPU puts us at 150 cycles).
>
> The last guidance I read from Intel said that
> a cache miss was roughly as expensive as a floating-point divide.

Floating-point divides are not performance-critical in most Python code,
so the comparison is not very useful. Besides, this statement does not
state which kind of cache would be involved in the cache miss.

On recent Intel CPUs a floating-point divide takes between 10
and 24 cycles (*), which could be in line with a L3 cache access (i.e. a
L2 cache miss), but certainly not a main memory access (150+ cycles).

(*) according to http://www.agner.org/optimize/instruction_tables.pdf

(also, modern CPUs have automatic prefetchers which try to hide the
latency of accessing main memory, but AFAIK this only really helps with
large streaming accesses)

> When a dictionary is less sparse, it has more collisions
> which means there are more cache misses.

Only in the eventuality that a single dict access is done (or a very
small number of them compared to the number of stored elements). But if
you are doing many accesses with good temporal locality, then the
sparse dict's bigger size implies a bigger cache footprint and
therefore a lesser efficiency - not only for the dict accesses
themselves, but for the rest of the code since more data will get
evicted to make place for the dict.

Furthermore, total memory consumption can be important regardless of
execution time. RAM is cheap but VMs are common where memory is much
smaller than on entire systems.

> For dictionaries large enough to require multiple resizes,
> the 4x factor cuts the number of resizes in half and makes
> each resize faster (because of few collisions). Only the
> growth phase is affected though.

Indeed.

> From a high-level view, I question efforts to desparsify dictionaries.
> When you have a bucket of water, the weight is in the water, not
> in the bucket itself.

But caches store whole cache lines, not individual bytes, so you do care
about the bucket's size. With 16-byte or 24-byte dict entries, and
64-byte cache lines, it is easy to see that a sparse dict could result
in a significant waste of the cache lines' storage if e.g. only 1 of 3
entries were used (and used entries were distributed in a regular
manner).

> The actual keys and values dominate dict size
> unless you're reusing the same values over and over again.

It certainly depends a lot on the use case.

Regards

Antoine.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


martin at v

Jun 18, 2012, 2:55 PM

Post #15 of 15 (277 views)
Permalink
Re: Tunable parameters in dictobject.c (was dictnotes.txt out of date?) [In reply to]

On 18.06.2012 23:08, Steven D'Aprano wrote:
> Raymond Hettinger wrote:
>
>> Sorry I can make a more detailed post right now. I'll make time in
>> the next couple of weeks to post some code and timings that
>> document the collision counts, total memory size, and its affect
>> on various dict use cases.
>
>
> Is there some way to instrument dictionary sparseness, number of hits
> and misses, etc. from Python?
>
> A secret command-line switch, perhaps, or a compile-time option?

Not that I know of, no.

> And if there isn't, perhaps there should be.

If so, only compile time options could be acceptable. However,
in my experience with profiling, the specific statistics that you
want to obtain are rarely known in advance, so you have to write
specific instrumentation every time you want to do an experiment -
and then the instrumentation is only good for that single experiment.

Thus, nobody publishes the instrumentation, since it would accumulate
as clutter.

Regards,
Martin

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.