<commit_before>gpa: *Allocator,
manifest_dir: fs.Dir,
hash: HashHelper = .{},

const Cache = @This();
const std = @import("std");
const crypto = std.crypto;
const fs = std.fs;
const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const fmt = std.fmt;
const Allocator = std.mem.Allocator;

/// Process-scoped map keeping track of all locked Cache hashes, to detect deadlocks.
/// The plan is to enable this for debug builds only, but for now we enable
/// it always to catch a deadlock.
var all_cache_digest_set: std.AutoHashMapUnmanaged(BinDigest, void) = .{};
var all_cache_digest_lock: std.Mutex = .{};
const want_debug_deadlock = true; // TODO change this for release builds
const DebugBinDigest = if (want_debug_deadlock) BinDigest else void;
const null_debug_bin_digest = if (want_debug_deadlock) ([1]u8{0} ** bin_digest_len) else {};

/// Be sure to call `Manifest.deinit` after successful initialization.
pub fn obtain(cache: *const Cache) Manifest {<commit_msg>stage2: Cache deadlock debugging only for safe build modes<commit_after>gpa: *Allocator,
manifest_dir: fs.Dir,
hash: HashHelper = .{},

const Cache = @This();
const std = @import("std");
const crypto = std.crypto;
const fs = std.fs;
const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const fmt = std.fmt;
const Allocator = std.mem.Allocator;

/// Process-scoped map keeping track of all locked Cache hashes, to detect deadlocks.
/// This protection is conditionally compiled depending on `want_debug_deadlock`.
var all_cache_digest_set: std.AutoHashMapUnmanaged(BinDigest, void) = .{};
var all_cache_digest_lock: std.Mutex = .{};
const want_debug_deadlock = std.debug.runtime_safety;
const DebugBinDigest = if (want_debug_deadlock) BinDigest else void;
const null_debug_bin_digest = if (want_debug_deadlock) ([1]u8{0} ** bin_digest_len) else {};

/// Be sure to call `Manifest.deinit` after successful initialization.
pub fn obtain(cache: *const Cache) Manifest {
{'fraction_non_alphanumeric': 0.11490215755143, 'fraction_numerical': 0.0035122930255895636, 'mean_word_length': 5.060790273556231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5165149', 'n_tokens_mistral': 644, 'n_tokens_neox': 629, 'n_words': 209}