Skip to content

ENH: decoupled the codes to use all cache buckets and optimized *zeros* for small chunks of memory. #8755

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

Closed
wants to merge 7 commits into from

Conversation

blackball
Copy link

@blackball blackball commented Mar 8, 2017

  1. created cache for dimension data, the NCACHE_DIM needs to be discussed. Here I increased it a little because it's unfair that we allowed to cache way more array data than dimension data (1024x7 >> 16x7).
  2. avoided using memory allocation as callback function. this allows we optimize out most of the memset() cost for small memory chunks in npy_alloc_cache_zero(). In the old codes, if *sz < NBUCKETS*, it would call memset once, no matter the memory was from the cache or newly allocated.
  3. reused all cache buckets. previously, the data_cache[0] and dim_cache[0, 1] was not used.

@charris charris changed the title decoupled the codes to use all cache buckets and optimized *zeros* for small chunks of memory. ENH: decoupled the codes to use all cache buckets and optimized *zeros* for small chunks of memory. Mar 12, 2017
@charris
Copy link
Member

charris commented Mar 12, 2017

@juliantaylor Thoughts?
@blackball Your commits will eventually need to be squashed the commit message fixed to conform to the style in doc/source/dev/gitwash/development_workflow.rst.

assert(sz > 0);
if (p != NULL && sz-1 < NBUCKETS_DATA && datacache[sz-1].available < NCACHE_DATA) {
if (p != NULL && sz > 0 && sz-1 < NBUCKETS_DATA &&
datacache[sz-1].available < NCACHE_DATA) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need extra indent here, also in other places.

@charris
Copy link
Member

charris commented Mar 12, 2017

C style also needs attention, see doc/C_STYLE_GUIDE.rst.txt.

@blackball
Copy link
Author

@charris I have formatted the codes according to the style guides and created a branch(blackball:improve_alloc) for it. I will close this request, please refer to the new one.

@blackball blackball closed this Mar 13, 2017
@eric-wieser
Copy link
Member

@blackball: In future there's no need to do that. You can always just force-push over the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants