Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/956#discussion_r77443787
  
    --- Diff: iocore/eventsystem/UnixEventProcessor.cc ---
    @@ -152,6 +155,59 @@ EventProcessor::start(int n_event_threads, size_t 
stacksize)
     #else
           Debug("iocore_thread", "EThread: %d %s: %d", i, obj_name, 
obj->logical_index);
     #endif // HWLOC_API_VERSION
    +    }
    +#endif // TS_USE_HWLOC
    +
    +    snprintf(thr_name, MAX_THREAD_NAME_LENGTH, "[ET_NET %d]", i);
    +#if TS_USE_HWLOC
    +    if (obj_count > 0) {
    +      hwloc_membind_policy_t mem_policy = HWLOC_MEMBIND_DEFAULT;
    +      hwloc_nodeset_t nodeset           = hwloc_bitmap_alloc();
    +      int num_nodes                     = 0;
    +
    +      hwloc_cpuset_to_nodeset(ink_get_topology(), obj->cpuset, nodeset);
    +      num_nodes = 
hwloc_get_nbobjs_inside_cpuset_by_type(ink_get_topology(), obj->cpuset, 
HWLOC_OBJ_NODE);
    +
    +      if (num_nodes == 1) {
    +        mem_policy = HWLOC_MEMBIND_BIND;
    +      } else if (num_nodes > 1) {
    +        mem_policy = HWLOC_MEMBIND_INTERLEAVE;
    +      }
    +
    +      if (mem_policy != HWLOC_MEMBIND_DEFAULT) {
    +        hwloc_set_membind_nodeset(ink_get_topology(), nodeset, mem_policy, 
HWLOC_MEMBIND_THREAD);
    +      }
    --- End diff --
    
    If I understand this correctly, we swizzle the memory allocation policy for 
the thread so that the subsequent allocations for the stacks will be 
interleaved across nodes.
    
    Does this depend on the mechanics of how ``malloc(3)`` chooses to allocate?
    
    Why do we have to figure this out for each thread? Can we just do it once 
then allocate all the stacks?
    
    Why do we even bother with ``HWLOC_MEMBIND_BIND``? If there's only 1 node, 
it seems like it would have to bind memory to that node?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to