<commit_before>// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/fastos.h>
#include "alloc.h"
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>
#include <linux/mman.h>
#include <stdexcept>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/backtrace.h>
#include <vespa/vespalib/util/sync.h>
#include <vespa/log/log.h>
#include <map>
#include <atomic>

LOG_SETUP(".vespalib.alloc");

namespace vespalib {

void * AlignedHeapAlloc::alloc(size_t sz, size_t alignment)
{
    if (!sz) {
        return 0;
    }
    void* ptr;
    int result = posix_memalign(&ptr, alignment, sz);
    if (result != 0) {
        throw IllegalArgumentException(
                make_string("posix_memalign(%zu, %zu) failed with code %d",
                            sz, alignment, result));
    }
    return ptr;
}

namespace {

volatile bool _G_hasHugePageFailureJustHappened(false);
volatile bool _G_SilenceCoreOnOOM(false);
volatile int  _G_HugeFlags = -1;
volatile size_t _G_MMapLogLimit = std::numeric_limits<size_t>::max();
volatile size_t _G_MMapNoCoreLimit = std::numeric_limits<size_t>::max();
Lock _G_lock;
std::atomic<size_t> _G_mmapCount(0);

struct MMapInfo {
    MMapInfo() :
        _id(0ul),
        _sz(0ul),
        _stackTrace()
    {}
    MMapInfo(size_t id, size_t sz, const string & stackTrace) :<commit_msg>Remove volatile<commit_after>// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/fastos.h>
#include "alloc.h"
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>
#include <linux/mman.h>
#include <stdexcept>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/backtrace.h>
#include <vespa/vespalib/util/sync.h>
#include <vespa/log/log.h>
#include <map>
#include <atomic>

LOG_SETUP(".vespalib.alloc");

namespace vespalib {

void * AlignedHeapAlloc::alloc(size_t sz, size_t alignment)
{
    if (!sz) {
        return 0;
    }
    void* ptr;
    int result = posix_memalign(&ptr, alignment, sz);
    if (result != 0) {
        throw IllegalArgumentException(
                make_string("posix_memalign(%zu, %zu) failed with code %d",
                            sz, alignment, result));
    }
    return ptr;
}

namespace {

volatile bool _G_hasHugePageFailureJustHappened(false);
bool _G_SilenceCoreOnOOM(false);
int  _G_HugeFlags = 0;
size_t _G_MMapLogLimit = std::numeric_limits<size_t>::max();
size_t _G_MMapNoCoreLimit = std::numeric_limits<size_t>::max();
Lock _G_lock;
std::atomic<size_t> _G_mmapCount(0);

struct MMapInfo {
    MMapInfo() :
        _id(0ul),
        _sz(0ul),
        _stackTrace()
    {}
    MMapInfo(size_t id, size_t sz, const string & stackTrace) :
{'fraction_non_alphanumeric': 0.13184165232358003, 'fraction_numerical': 0.008261617900172116, 'mean_word_length': 3.7717569786535305, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3389369', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1050, 'n_words': 235}