Skip to content
Snippets Groups Projects
Commit a3e7e9bd authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

equix: Disable huge page support by default

Equi-X supports optionally allocating its solver memory using huge
pages, to reduce the virtual memory subsystem overhead required to make
the entire solver buffer live.

Tor doesn't use this feature, since it seems to have no noticeable
performance benefit at this time, but we still included code for it at
compile time. To improve portability, this patch disables huge page
support by default and enables it only in the cmake build system used
for equix benchmarks.

With this patch equix-bench still supports huge pages. Verified using
strace that we're making the hugepage allocation.

There's no fallback for huge pages, so Equi-X initialization will fail
if they are requested and we don't support them for any runtime or
compile-time reason.

Addresses #40843 (NetBSD) but also prevents future porting issues
related to huge pages.
parent 95e8ffa9
No related branches found
No related tags found
1 merge request!751maint-0.4.8: NetBSD portability fixes for HashX and Equi-X
......@@ -11,6 +11,7 @@ set(EQUIX_VERSION_STR "${EQUIX_VERSION}.${EQUIX_VERSION_MINOR}.${EQUIX_VERSION_P
project(equix)
add_definitions(-DHASHX_SIZE=8)
add_definitions(-DEQUIX_SUPPORT_HUGEPAGES)
add_subdirectory("hashx")
......
......@@ -90,6 +90,7 @@ bool hashx_vm_rx(void* ptr, size_t bytes) {
return page_protect(ptr, bytes, PAGE_EXECUTE_READ);
}
#ifdef EQUIX_SUPPORT_HUGEPAGES
void* hashx_vm_alloc_huge(size_t bytes) {
void* mem;
#ifdef HASHX_WIN
......@@ -124,6 +125,7 @@ void* hashx_vm_alloc_huge(size_t bytes) {
#endif
return mem;
}
#endif /* EQUIX_SUPPORT_HUGEPAGES */
void hashx_vm_free(void* ptr, size_t bytes) {
if (!ptr) {
......
......@@ -14,7 +14,10 @@
HASHX_PRIVATE void* hashx_vm_alloc(size_t size);
HASHX_PRIVATE bool hashx_vm_rw(void* ptr, size_t size);
HASHX_PRIVATE bool hashx_vm_rx(void* ptr, size_t size);
HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size);
HASHX_PRIVATE void hashx_vm_free(void* ptr, size_t size);
#ifdef EQUIX_SUPPORT_HUGEPAGES
HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size);
#endif
#endif
......@@ -27,7 +27,11 @@ equix_ctx* equix_alloc(equix_ctx_flags flags) {
if (flags & EQUIX_CTX_SOLVE) {
if (flags & EQUIX_CTX_HUGEPAGES) {
#ifdef EQUIX_SUPPORT_HUGEPAGES
ctx->heap = hashx_vm_alloc_huge(sizeof(solver_heap));
#else
ctx->heap = NULL;
#endif
}
else {
ctx->heap = malloc(sizeof(solver_heap));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment