Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise Unicode KEEPALIVE_SIZE_LIMIT from 9 to 32? #50465

Closed
terryjreedy opened this issue Jun 6, 2009 · 13 comments
Closed

Raise Unicode KEEPALIVE_SIZE_LIMIT from 9 to 32? #50465

terryjreedy opened this issue Jun 6, 2009 · 13 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@terryjreedy
Copy link
Member

BPO 6216
Nosy @malemburg, @terryjreedy, @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-10-24.01:23:28.731>
created_at = <Date 2009-06-06.00:04:12.380>
labels = ['interpreter-core', 'performance']
title = 'Raise Unicode KEEPALIVE_SIZE_LIMIT from 9 to 32?'
updated_at = <Date 2011-10-24.01:23:28.730>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2011-10-24.01:23:28.730>
actor = 'pitrou'
assignee = 'none'
closed = True
closed_date = <Date 2011-10-24.01:23:28.731>
closer = 'pitrou'
components = ['Interpreter Core']
creation = <Date 2009-06-06.00:04:12.380>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 6216
keywords = []
message_count = 13.0
messages = ['88981', '88982', '89002', '89070', '89098', '110897', '110927', '110951', '110977', '110978', '111075', '121023', '146275']
nosy_count = 4.0
nosy_names = ['lemburg', 'terry.reedy', 'pitrou', 'BreamoreBoy']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue6216'
versions = ['Python 3.2']

@terryjreedy
Copy link
Member Author

From msg88801
'''
for 3.1: raising the KEEPALIVE_SIZE_LIMIT to 32 as explained and
motivated here:

msg64215

That's a simple non-disruptive change which makes a lot of sense
due to the advances in CPU designs in the last 9 years. I determined
the original value of 9 using benchmarks and similar statistics in
1999/2000.

It's probably also a good time to remove the warning, now that the
implementation has proven itself for so many years...

/* Limit for the Unicode object free list stay alive optimization.

The implementation will keep allocated Unicode memory intact for
all objects on the free list having a size less than this
limit. This reduces malloc() overhead for small Unicode objects.

At worst this will result in PyUnicode_MAXFREELIST *
(sizeof(PyUnicodeObject) + KEEPALIVE_SIZE_LIMIT +
malloc()-overhead) bytes of unused garbage.

Setting the limit to 0 effectively turns the feature off.

Note: This is an experimental feature ! If you get core dumps when
using Unicode objects, turn this feature off.

*/

#define KEEPALIVE_SIZE_LIMIT       9
'''
If this is as non-controversial as it seems, perhaps someone could
change 9 to 32 and remove "Note: This is an experimental feature..." in
time for rc2.

@terryjreedy terryjreedy added interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Jun 6, 2009
@terryjreedy
Copy link
Member Author

Marc-Andre Lemburg's message is from bpo-1943

@pitrou
Copy link
Member

pitrou commented Jun 6, 2009

I'm not sure it is "as non-controversial as it seems".
Someone should 1) do the math 2) show impact on a couple of benchmarks
of his choice

@malemburg
Copy link
Member

I think we should also consider raising the free list limit
of currently 1024 objects.

The keep-alive optimization currently uses at most 1024 * 9 * 2
= 18432 bytes (+ pymalloc overhead) on a UCS2 build of Python in
the worst case.

With a limit of 32 you get 65536 bytes.

Given that Unicode objects are one of the most used object in
Python 3k and looking at todays CPU cache sizes, it would
probably be fair to allocate up to 256kB for such an
optimization, e.g. by allowing up to 4096 objects to reside
in the free list.

@terryjreedy
Copy link
Member Author

If you write a patch, you are free to include the additional change.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Jul 20, 2010

Terry, are you still interested in this?

@terryjreedy
Copy link
Member Author

That question should better be directed at Marc-Andre. I merely extracted this sub-issue from one of his posts in the very contentious discussion of bpo-1943, lest it get lost.

Antoine asked for a calculation. Marc-Andre gave one, but I do not know if that is what Antoine wanted. The referenced msg64215 gives 3 string length profiles that suggest that an increase to at least 16 might be useful.

@pitrou
Copy link
Member

pitrou commented Jul 20, 2010

You forgot "2) show impact on a couple of benchmarks of his choice", which is arguably the most important.

@terryjreedy
Copy link
Member Author

I did not forget. I omitted because there were no benchmarks to mention. I admit that silence is sometimes difficult to interpret and that I should have said so. Do you see that incrementing the limit could have negative effects that need to be justified? Just simply the extra space ? or something else?

@pitrou
Copy link
Member

pitrou commented Jul 20, 2010

I did not forget. I omitted because there were no benchmarks to
mention. I admit that silence is sometimes difficult to interpret and
that I should have said so. Do you see that incrementing the limit
could have negative effects that need to be justified? Just simply the
extra space ? or something else?

It can always have negative effects in the form of decreased cache
efficiency, or more fragmentation in the memory allocator.
Otherwise we could similarly bump up the size of all freelists in the
interpreter (there are several of them).

@malemburg
Copy link
Member

I'm interested in getting this into 3.2. Thanks for bringing
the issue back on my radar.

@terryjreedy
Copy link
Member Author

Two weeks left for 3.2 ;-)

@pitrou
Copy link
Member

pitrou commented Oct 24, 2011

Closing as outdated. There are no freelists anymore in the unicode implementation.

@pitrou pitrou closed this as completed Oct 24, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

3 participants