snmalloc pessimal performance in post-main cleanup

Open
#809 21 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp

Research direction

Start with the header-only override snippet in the issue and the linked Cataclysm-DDA integration pull request, then reproduce the Windows test-binary cleanup behavior. Use the reported profiling results to determine whether the post-main iteration is expected or a snmalloc bug; done means the behavior is explained and, if defective, a focused fix or reproduction is identified.

Written by the indexing model from the issue text.

Description

While integrating snmalloc into https://github.com/CleverRaven/Cataclysm-DDA, I noticed a bizarre issue crop up: snmalloc seeming causing a hang post completion of the test binary. Profiling on Windows shows that it seems to spend all of its cycles repeatedly iterating some internal structure at exorbitant cost. I'm not sure if this is simply expected behavior due to a large number of deallocations at once or if it a bad interaction with post-main thread behavior violating snmalloc's assumptions.

The pull request for the integration is https://github.com/CleverRaven/Cataclysm-DDA/pull/85099. I am using the 'header only' style build method with the following (simplified) contents to override just new/delete for Windows.

#define SNMALLOC_USE_WAIT_ON_ADDRESS 1
#ifndef _WIN32
#include <snmalloc/override/malloc.cc> // NOLINT(bugprone-suspicious-include)
#endif
#include <snmalloc/override/new.cc> // NOLINT(bugprone-suspicious-include)
Image Image
Dominant language
C++
Stars
2k
Forks
138
Avg merge
11h 19m
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/snmalloc

All issues in microsoft/snmalloc

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.