26#ifndef TEMPTABLE_MEM_H
27#define TEMPTABLE_MEM_H
42#define _WIN32_WINNT 0x0601
50#define TEMPTABLE_USE_LINUX_NUMA
62#if defined(HAVE_WINNUMA)
63extern DWORD win_page_size;
99 void *
memory = fetch(bytes);
113 static void *fetch(
size_t bytes);
114 static void drop(
void *ptr,
size_t bytes);
117#ifdef TEMPTABLE_USE_LINUX_NUMA
132 void *
memory = fetch(bytes);
146 static void *fetch(
size_t bytes);
147 static void drop(
void *ptr,
size_t bytes);
151#if defined(TEMPTABLE_USE_LINUX_NUMA)
152 if (linux_numa_available) {
153 return numa_alloc_local(bytes);
157#elif defined(HAVE_WINNUMA)
158 PROCESSOR_NUMBER processorNumber;
160 GetCurrentProcessorNumberEx(&processorNumber);
161 GetNumaProcessorNodeEx(&processorNumber, &numaNodeId);
163 (bytes + win_page_size - 1) & ~(
static_cast<size_t>(win_page_size) - 1);
164 return VirtualAllocExNuma(GetCurrentProcess(),
nullptr, bytes,
165 MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE,
174#if defined(TEMPTABLE_USE_LINUX_NUMA)
175 if (linux_numa_available) {
176 numa_free(ptr, bytes);
180#elif defined(HAVE_WINNUMA)
181 BOOL ret [[maybe_unused]] = VirtualFree(ptr, 0, MEM_RELEASE);
189 DBUG_EXECUTE_IF(
"temptable_fetch_from_disk_return_null",
return nullptr;);
192 const int mode = _O_RDWR;
194 const int mode = O_RDWR;
211 void *ptr =
my_mmap(
nullptr, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, f, 0);
236 return (ptr == MAP_FAILED) ?
nullptr : ptr;
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
int my_fallocator(File fd, my_off_t newlength, int filler, myf MyFlags)
Change size of the specified file.
Definition: my_fallocator.cc:70
my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags)
Seek to a position in a file.
Definition: my_seek.cc:68
File create_temp_file(char *to, const char *dir, const char *pfx, int mode, UnlinkOrKeepFile unlink_or_keep, myf MyFlags)
Definition: mf_tempfile.cc:219
#define my_mmap(a, b, c, d, e, f)
Definition: my_sys.h:844
#define MY_SEEK_SET
Definition: my_sys.h:168
#define MY_WME
Definition: my_sys.h:125
int my_close(File fd, myf MyFlags)
Close a file.
Definition: my_open.cc:98
#define my_munmap(a, b)
Definition: my_sys.h:848
@ UNLINK_FILE
Definition: my_sys.h:777
bool drop(THD *thd, const Table *tp)
Remove SDI for a table.
Definition: sdi.cc:638
#define malloc(A)
Definition: lexyy.cc:914
#define free(A)
Definition: lexyy.cc:915
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:170
#define MY_FILEPOS_ERROR
Definition: my_inttypes.h:72
#define MYF(v)
Definition: my_inttypes.h:96
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:82
int File
Definition: my_io_bits.h:50
Common header for many mysys elements.
#define mysql_tmpdir
Definition: mysqld.h:694
Definition: aligned_atomic.h:43
mode
Definition: file_handle.h:59
Definition: allocator.h:44
Source
Type of memory allocated.
Definition: memutils.h:67
@ MMAP_FILE
Memory is allocated on disk, using mmap()'ed file.
@ RAM
Memory is allocated from RAM, using malloc() for example.
TempTable auxiliary Result enum.
static void deallocate(void *ptr, size_t bytes)
Deallocates memory from MMAP-ed file.
Definition: memutils.h:143
static void * allocate(size_t bytes)
Allocates memory from MMAP-ed file.
Definition: memutils.h:131
static void * allocate(size_t bytes)
Allocates memory from RAM.
Definition: memutils.h:98
static void deallocate(void *ptr, size_t bytes)
Deallocates memory from RAM.
Definition: memutils.h:110
static const bool linux_numa_available
Set to true if Linux's numa_available() reports "available" (!= -1).
Definition: memutils.h:119
Primary-template (functor) class for memory-utils.
Definition: memutils.h:76
static void deallocate(void *ptr, size_t bytes)
static void * allocate(size_t bytes)