GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: Fix cache use regression · charris/numpy@e659814

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy/_core/src/multiarray
    • alloc.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/_core/src/multiarray/alloc.c‎

Copy file name to clipboardExpand all lines: numpy/_core/src/multiarray/alloc.c
+17-18Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@
2727
#endif
2828
#endif
2929

30-
#define NBUCKETS 1024 /* number of buckets for data*/
31-
#define NBUCKETS_DIM 16 /* number of buckets for dimensions/strides */
32-
#define NCACHE 7 /* number of cache entries per bucket */
30+
/* Do not enable the alloc cache if the GIL is disabled, or if ASAN or MSAN
31+
* instrumentation is enabled. The cache makes ASAN use-after-free or MSAN
32+
* use-of-uninitialized-memory warnings less useful. */
33+
#define USE_ALLOC_CACHE 1
34+
#ifdef Py_GIL_DISABLED
35+
# define USE_ALLOC_CACHE 0
36+
#elif defined(__has_feature)
37+
# if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
38+
# define USE_ALLOC_CACHE 0
39+
# endif
40+
#endif
41+
42+
#if USE_ALLOC_CACHE
43+
# define NBUCKETS 1024 /* number of buckets for data*/
44+
# define NBUCKETS_DIM 16 /* number of buckets for dimensions/strides */
45+
# define NCACHE 7 /* number of cache entries per bucket */
3346
/* this structure fits neatly into a cacheline */
3447
typedef struct {
3548
npy_uintp available; /* number of cached pointers */
3649
void * ptrs[NCACHE];
3750
} cache_bucket;
3851
static cache_bucket datacache[NBUCKETS];
3952
static cache_bucket dimcache[NBUCKETS_DIM];
40-
53+
#endif /* USE_ALLOC_CACHE */
4154

4255
/*
4356
* This function tells whether NumPy attempts to call `madvise` with
@@ -99,20 +112,6 @@ indicate_hugepages(void *p, size_t size) {
99112
}
100113

101114

102-
/* Do not enable the alloc cache if the GIL is disabled, or if ASAN or MSAN
103-
* instrumentation is enabled. The cache makes ASAN use-after-free or MSAN
104-
* use-of-uninitialized-memory warnings less useful. */
105-
#ifdef Py_GIL_DISABLED
106-
#define USE_ALLOC_CACHE 0
107-
#elif defined(__has_feature)
108-
# if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
109-
# define USE_ALLOC_CACHE 0
110-
# endif
111-
#else
112-
#define USE_ALLOC_CACHE 1
113-
#endif
114-
115-
116115
/* as the cache is managed in global variables verify the GIL is held */
117116

118117
/*

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.