<commit_before>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package utils

import (
	"os"
	"runtime"
	"sync"
)

var mu = sync.Mutex{}
var gomaxprocs = runtime.GOMAXPROCS
var numcpu = runtime.NumCPU
var enabledMultiCPUs = false

// EnableMultipleCPUs is called when we want to allow the system to have
// GOMAXPROCS>1. By default we only want to enable GOMAXPROCS>1 when running in
// the jujud machine agents that are serving the API. We don't want to set it
// in the test suite, etc.
// So first you call EnableMultipleCPUs() when we determine we are running from
// main(), and then later on you call UseMultipleCPUs() when we determine we
// are running a machine agent that is serving the API.
func EnableMultipleCPUs() {
	mu.Lock()
	defer mu.Unlock()
	// We check to see if GOMAXPROCS is set in the environment. If it is,
	// then we will just use the environment variable, and not override it
	// ourselves
	if os.Getenv("GOMAXPROCS") == "" {
		enabledMultiCPUs = true
	}
}


// UseMultipleCPUs is called when we have decided we want to set GOMAXPROCS to
// the current number of CPU cores. This will not override the environment
// variable if it is set.
func UseMultipleCPUs() {
	mu.Lock()
	defer mu.Unlock()
	if !enabledMultiCPUs {
		logger.Debugf("multiple CPUs not enabled, calling GOMAXPROCS(0)")
		gomaxprocs(0)
		return
	}
	gomaxprocs(numcpu())
}
<commit_msg>Include something in the debug log<commit_after>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package utils

import (
	"os"
	"runtime"
	"sync"
)

var mu = sync.Mutex{}
var gomaxprocs = runtime.GOMAXPROCS
var numcpu = runtime.NumCPU
var enabledMultiCPUs = false

// EnableMultipleCPUs is called when we want to allow the system to have
// GOMAXPROCS>1. By default we only want to enable GOMAXPROCS>1 when running in
// the jujud machine agents that are serving the API. We don't want to set it
// in the test suite, etc.
// So first you call EnableMultipleCPUs() when we determine we are running from
// main(), and then later on you call UseMultipleCPUs() when we determine we
// are running a machine agent that is serving the API.
func EnableMultipleCPUs() {
	mu.Lock()
	defer mu.Unlock()
	// We check to see if GOMAXPROCS is set in the environment. If it is,
	// then we will just use the environment variable, and not override it
	// ourselves
	if os.Getenv("GOMAXPROCS") == "" {
		enabledMultiCPUs = true
	}
}


// UseMultipleCPUs is called when we have decided we want to set GOMAXPROCS to
// the current number of CPU cores. This will not override the environment
// variable if it is set.
func UseMultipleCPUs() {
	mu.Lock()
	defer mu.Unlock()
	if !enabledMultiCPUs {
		logger.Debugf("multiple CPUs not enabled, calling GOMAXPROCS(0)")
		gomaxprocs(0)
		return
	}
	n := numcpu()
	logger.Debugf("setting GOMAXPROCS to %d", n)
	gomaxprocs(n)
}

{'fraction_non_alphanumeric': 0.08661417322834646, 'fraction_numerical': 0.0061622731941116055, 'mean_word_length': 3.7358184764991895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5952575', 'n_tokens_mistral': 926, 'n_tokens_neox': 922, 'n_words': 396}