LLVM 23.0.0git
llvm::cas::ondisk::OnDiskCASLogger Class Reference

Interface for logging low-level on-disk cas operations. More...

#include "llvm/CAS/OnDiskCASLogger.h"

Public Types

using TrieOffset = int64_t
 An offset into an OnDiskTrieRawHashMap.

Public Member Functions

LLVM_ABI ~OnDiskCASLogger ()
LLVM_ABI void logSubtrieHandleCmpXchg (void *Region, TrieOffset Trie, size_t SlotI, TrieOffset Expected, TrieOffset New, TrieOffset Previous)
LLVM_ABI void logSubtrieHandleCreate (void *Region, TrieOffset Trie, uint32_t StartBit, uint32_t NumBits)
LLVM_ABI void logHashMappedTrieHandleCreateRecord (void *Region, TrieOffset TrieOffset, ArrayRef< uint8_t > Hash)
LLVM_ABI void logMappedFileRegionArenaResizeFile (StringRef Path, size_t Before, size_t After)
LLVM_ABI void logMappedFileRegionArenaCreate (StringRef Path, int FD, void *Region, size_t Capacity, size_t Size)
LLVM_ABI void logMappedFileRegionArenaOom (StringRef Path, size_t Capacity, size_t Size, size_t AllocSize)
LLVM_ABI void logMappedFileRegionArenaClose (StringRef Path)
LLVM_ABI void logMappedFileRegionArenaAllocate (void *Region, TrieOffset Off, size_t Size)
LLVM_ABI void logUnifiedOnDiskCacheCollectGarbage (StringRef Path)
LLVM_ABI void logUnifiedOnDiskCacheValidateIfNeeded (StringRef Path, uint64_t BootTime, uint64_t ValidationTime, bool CheckHash, bool AllowRecovery, bool Force, std::optional< StringRef > LLVMCas, StringRef ValidationError, bool Skipped, bool Recovered)
LLVM_ABI void logTempFileCreate (StringRef Name)
LLVM_ABI void logTempFileKeep (StringRef TmpName, StringRef Name, std::error_code EC)
LLVM_ABI void logTempFileRemove (StringRef TmpName, std::error_code EC)

Static Public Member Functions

static LLVM_ABI Expected< std::unique_ptr< OnDiskCASLogger > > open (const Twine &Path, bool LogAllocations)
 Create or append to a log file inside the given CAS directory Path.
static LLVM_ABI Expected< std::unique_ptr< OnDiskCASLogger > > openIfEnabled (const Twine &Path)
 Create or append to a log file inside the given CAS directory Path if logging is enabled by the environment variable LLVM_CAS_LOG.

Detailed Description

Interface for logging low-level on-disk cas operations.

This log is intended to mirror the low-level details of the CAS in order to aid with debugging corruption or other issues with the on-disk format.

Definition at line 33 of file OnDiskCASLogger.h.

Member Typedef Documentation

◆ TrieOffset

An offset into an OnDiskTrieRawHashMap.

Definition at line 52 of file OnDiskCASLogger.h.

Constructor & Destructor Documentation

◆ ~OnDiskCASLogger()

OnDiskCASLogger::~OnDiskCASLogger ( )

Definition at line 46 of file OnDiskCASLogger.cpp.

Member Function Documentation

◆ logHashMappedTrieHandleCreateRecord()

void OnDiskCASLogger::logHashMappedTrieHandleCreateRecord ( void * Region,
TrieOffset TrieOffset,
ArrayRef< uint8_t > Hash )

Definition at line 165 of file OnDiskCASLogger.cpp.

References llvm::format_bytes(), and formatTrieOffset().

◆ logMappedFileRegionArenaAllocate()

void OnDiskCASLogger::logMappedFileRegionArenaAllocate ( void * Region,
TrieOffset Off,
size_t Size )

Definition at line 210 of file OnDiskCASLogger.cpp.

References formatTrieOffset(), and Size.

◆ logMappedFileRegionArenaClose()

void OnDiskCASLogger::logMappedFileRegionArenaClose ( StringRef Path)

Definition at line 206 of file OnDiskCASLogger.cpp.

◆ logMappedFileRegionArenaCreate()

void OnDiskCASLogger::logMappedFileRegionArenaCreate ( StringRef Path,
int FD,
void * Region,
size_t Capacity,
size_t Size )

◆ logMappedFileRegionArenaOom()

void OnDiskCASLogger::logMappedFileRegionArenaOom ( StringRef Path,
size_t Capacity,
size_t Size,
size_t AllocSize )

Definition at line 199 of file OnDiskCASLogger.cpp.

References Size.

◆ logMappedFileRegionArenaResizeFile()

void OnDiskCASLogger::logMappedFileRegionArenaResizeFile ( StringRef Path,
size_t Before,
size_t After )

Definition at line 173 of file OnDiskCASLogger.cpp.

◆ logSubtrieHandleCmpXchg()

void OnDiskCASLogger::logSubtrieHandleCmpXchg ( void * Region,
TrieOffset Trie,
size_t SlotI,
TrieOffset Expected,
TrieOffset New,
TrieOffset Previous )

Definition at line 141 of file OnDiskCASLogger.cpp.

References formatTrieOffset().

◆ logSubtrieHandleCreate()

void OnDiskCASLogger::logSubtrieHandleCreate ( void * Region,
TrieOffset Trie,
uint32_t StartBit,
uint32_t NumBits )

Definition at line 156 of file OnDiskCASLogger.cpp.

References formatTrieOffset().

◆ logTempFileCreate()

void OnDiskCASLogger::logTempFileCreate ( StringRef Name)

Definition at line 245 of file OnDiskCASLogger.cpp.

◆ logTempFileKeep()

void OnDiskCASLogger::logTempFileKeep ( StringRef TmpName,
StringRef Name,
std::error_code EC )

Definition at line 250 of file OnDiskCASLogger.cpp.

◆ logTempFileRemove()

void OnDiskCASLogger::logTempFileRemove ( StringRef TmpName,
std::error_code EC )

Definition at line 258 of file OnDiskCASLogger.cpp.

◆ logUnifiedOnDiskCacheCollectGarbage()

void OnDiskCASLogger::logUnifiedOnDiskCacheCollectGarbage ( StringRef Path)

Definition at line 221 of file OnDiskCASLogger.cpp.

◆ logUnifiedOnDiskCacheValidateIfNeeded()

void OnDiskCASLogger::logUnifiedOnDiskCacheValidateIfNeeded ( StringRef Path,
uint64_t BootTime,
uint64_t ValidationTime,
bool CheckHash,
bool AllowRecovery,
bool Force,
std::optional< StringRef > LLVMCas,
StringRef ValidationError,
bool Skipped,
bool Recovered )

◆ open()

Expected< std::unique_ptr< OnDiskCASLogger > > OnDiskCASLogger::open ( const Twine & Path,
bool LogAllocations )
static

Create or append to a log file inside the given CAS directory Path.

Parameters
PathThe parent directory of the log file.
LogAllocationsWhether to log all low-level allocations. This is on the order of twice as expensive to log.

Definition at line 71 of file OnDiskCASLogger.cpp.

References llvm::sys::path::append(), llvm::sys::fs::CD_OpenAlways, llvm::createFileError(), llvm::sys::fs::FA_Write, Filename, and llvm::sys::fs::OF_Append.

Referenced by openIfEnabled().

◆ openIfEnabled()

Expected< std::unique_ptr< OnDiskCASLogger > > OnDiskCASLogger::openIfEnabled ( const Twine & Path)
static

Create or append to a log file inside the given CAS directory Path if logging is enabled by the environment variable LLVM_CAS_LOG.

If LLVM_CAS_LOG is set >= 2 then also log allocations.

Definition at line 60 of file OnDiskCASLogger.cpp.

References llvm::StringRef::getAsInteger(), isDisabledEnv(), and open().

Referenced by llvm::cas::ondisk::UnifiedOnDiskCache::open(), and llvm::cas::ondisk::UnifiedOnDiskCache::validateIfNeeded().


The documentation for this class was generated from the following files: