Optimizations for Windows

- Set opt_lg_chunk based on run-time OS setting
- Verify LG_PAGE is compatible with run-time OS setting
- When targeting Windows Vista or newer, use SRWLOCK instead of CRITICAL_SECTION
- When targeting Windows Vista or newer, statically initialize init_lock
This commit is contained in:
Matthijs
2015-06-25 22:53:58 +02:00
parent 241abc601b
commit a1aaf949a5
4 changed files with 36 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
/* Data. */
const char *opt_dss = DSS_DEFAULT;
size_t opt_lg_chunk = LG_CHUNK_DEFAULT;
size_t opt_lg_chunk = 0;
/* Used exclusively for gdump triggering. */
static size_t curchunks;
@@ -535,6 +535,21 @@ chunks_rtree_node_alloc(size_t nelms)
bool
chunk_boot(void)
{
#ifdef _WIN32
SYSTEM_INFO info;
GetSystemInfo(&info);
/* Verify actual page size is equal to or an integral multiple of configured page size */
if (info.dwPageSize & ((1U << LG_PAGE) - 1))
return (true);
/* Configure chunksize (if not set) to match granularity (usually 64K), so pages_map will always take fast path */
if (!opt_lg_chunk)
opt_lg_chunk = ffs((int)info.dwAllocationGranularity) - 1;
#else
if (!opt_lg_chunk)
opt_lg_chunk = LG_CHUNK_DEFAULT;
#endif
/* Set variables according to the value of opt_lg_chunk. */
chunksize = (ZU(1) << opt_lg_chunk);