Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::IO::StorageDriveWin Class Reference

Inherits AZ::IO::StreamStackEntry.

Classes

struct  ConstructionOptions
 
struct  FileReadInformation
 
struct  FileReadStatus
 

Public Member Functions

 StorageDriveWin (const AZStd::vector< AZStd::string_view > &drivePaths, u32 maxFileHandles, u32 maxMetaDataCacheEntries, size_t physicalSectorSize, size_t logicalSectorSize, u32 ioChannelCount, s32 overCommit, ConstructionOptions options)
 
void PrepareRequest (FileRequest *request) override
 
void QueueRequest (FileRequest *request) override
 
bool ExecuteRequests () override
 
void UpdateStatus (Status &status) const override
 Gets a combined status update from all the nodes in the stack.
 
void UpdateCompletionEstimates (AZStd::chrono::steady_clock::time_point now, AZStd::vector< FileRequest * > &internalPending, StreamerContext::PreparedQueue::iterator pendingBegin, StreamerContext::PreparedQueue::iterator pendingEnd) override
 
void CollectStatistics (AZStd::vector< Statistic > &statistics) const override
 
- Public Member Functions inherited from AZ::IO::StreamStackEntry
 StreamStackEntry (AZStd::string &&name)
 
virtual const AZStd::stringGetName () const
 Returns the name that uniquely identifies this entry.
 
virtual void SetNext (AZStd::shared_ptr< StreamStackEntry > next)
 
virtual AZStd::shared_ptr< StreamStackEntryGetNext () const
 
virtual void SetContext (StreamerContext &context)
 
virtual void PrepareRequest (FileRequest *request)
 
virtual void QueueRequest (FileRequest *request)
 
virtual bool ExecuteRequests ()
 
virtual void UpdateStatus (Status &status) const
 Gets a combined status update from all the nodes in the stack.
 
virtual void UpdateCompletionEstimates (AZStd::chrono::steady_clock::time_point now, AZStd::vector< FileRequest * > &internalPending, StreamerContext::PreparedQueue::iterator pendingBegin, StreamerContext::PreparedQueue::iterator pendingEnd)
 
virtual void CollectStatistics (AZStd::vector< Statistic > &statistics) const
 

Protected Types

enum class  OpenFileResult { FileOpened , RequestForwarded , CacheFull }
 

Protected Member Functions

OpenFileResult OpenFile (HANDLE &fileHandle, size_t &cacheSlot, FileRequest *request, const Requests::ReadData &data)
 
bool ReadRequest (FileRequest *request)
 
bool ReadRequest (FileRequest *request, size_t readSlot)
 
bool CancelRequest (FileRequest *cancelRequest, FileRequestPtr &target)
 
void FileExistsRequest (FileRequest *request)
 
void FileMetaDataRetrievalRequest (FileRequest *request)
 
size_t FindInFileHandleCache (const RequestPath &filePath) const
 
size_t FindAvailableFileHandleCacheIndex () const
 
size_t FindAvailableReadSlot ()
 
size_t FindInMetaDataCache (const RequestPath &filePath) const
 
size_t GetNextMetaDataCacheSlot ()
 
bool IsServicedByThisDrive (AZ::IO::PathView filePath) const
 
void EstimateCompletionTimeForRequest (FileRequest *request, AZStd::chrono::steady_clock::time_point &startTime, const RequestPath *&activeFile, u64 &activeOffset) const
 
void EstimateCompletionTimeForRequestChecked (FileRequest *request, AZStd::chrono::steady_clock::time_point startTime, const RequestPath *&activeFile, u64 &activeOffset) const
 
s32 CalculateNumAvailableSlots () const
 
void FlushCache (const RequestPath &filePath)
 
void FlushEntireCache ()
 
bool FinalizeReads ()
 
void FinalizeSingleRequest (FileReadStatus &status, size_t readSlot, DWORD numBytesTransferred, bool isCanceled, bool encounteredError)
 
void Report (const Requests::ReportData &data) const
 

Protected Attributes

TimedAverageWindow< s_statisticsWindowSizem_fileOpenCloseTimeAverage
 
TimedAverageWindow< s_statisticsWindowSizem_getFileExistsTimeAverage
 
TimedAverageWindow< s_statisticsWindowSizem_getFileMetaDataRetrievalTimeAverage
 
TimedAverageWindow< s_statisticsWindowSizem_readTimeAverage
 
AverageWindow< u64, float, s_statisticsWindowSizem_readSizeAverage
 
AZStd::chrono::steady_clock::time_point m_activeReads_startTime
 
AZStd::deque< FileRequest * > m_pendingReadRequests
 
AZStd::deque< FileRequest * > m_pendingRequests
 
AZStd::vector< FileReadInformationm_readSlots_readInfo
 
AZStd::vector< FileReadStatusm_readSlots_statusInfo
 
AZStd::vector< bool > m_readSlots_active
 
AZStd::vector< AZStd::chrono::steady_clock::time_point > m_fileCache_lastTimeUsed
 
AZStd::vector< RequestPathm_fileCache_paths
 
AZStd::vector< HANDLE > m_fileCache_handles
 
AZStd::vector< u16 > m_fileCache_activeReads
 
AZStd::vector< RequestPathm_metaDataCache_paths
 
AZStd::vector< u64 > m_metaDataCache_fileSize
 
AZStd::vector< AZStd::stringm_drivePaths
 
size_t m_activeReads_ByteCount { 0 }
 
size_t m_physicalSectorSize { 0 }
 
size_t m_logicalSectorSize { 0 }
 
size_t m_activeCacheSlot { InvalidFileCacheIndex }
 
size_t m_metaDataCache_front { 0 }
 
u64 m_activeOffset { 0 }
 
u32 m_maxFileHandles { 1 }
 
u32 m_ioChannelCount { 1 }
 
s32 m_overCommit { 0 }
 
u16 m_activeReads_Count { 0 }
 
ConstructionOptions m_constructionOptions
 
bool m_cachesInitialized { false }
 
- Protected Attributes inherited from AZ::IO::StreamStackEntry
AZStd::string m_name
 The name that uniquely identifies this entry.
 
AZStd::shared_ptr< StreamStackEntrym_next
 The next entry in the stack.
 
StreamerContextm_context
 Context information for the entire streaming stack.
 

Static Protected Attributes

static const AZStd::chrono::microseconds s_averageSeekTime
 
static constexpr size_t InvalidFileCacheIndex = std::numeric_limits<size_t>::max()
 
static constexpr size_t InvalidReadSlotIndex = std::numeric_limits<size_t>::max()
 
static constexpr size_t InvalidMetaDataCacheIndex = std::numeric_limits<size_t>::max()
 

Constructor & Destructor Documentation

◆ StorageDriveWin()

AZ::IO::StorageDriveWin::StorageDriveWin ( const AZStd::vector< AZStd::string_view > &  drivePaths,
u32  maxFileHandles,
u32  maxMetaDataCacheEntries,
size_t  physicalSectorSize,
size_t  logicalSectorSize,
u32  ioChannelCount,
s32  overCommit,
ConstructionOptions  options 
)

Creates an instance of a storage device that's optimized for use on Windows.

Parameters
drivePathsThe paths to the drives that are supported by this device. A single device can have multiple logical disks.
maxFileHandlesThe maximum number of file handles that are cached. Only a small number are needed when running from archives, but it's recommended that a larger number are kept open when reading from loose files.
maxMetaDataCacheEntiresThe maximum number of files to keep meta data, such as the file size, to cache. Only a small number are needed when running from archives, but it's recommended that a larger number are kept open when reading from loose files.
physicalSectorSizeThe minimal sector size as instructed by the device. When unbuffered reads are used the output buffer needs to be aligned to this value.
logicalSectorSizeThe minimal sector size as instructed by the device. When unbuffered reads are used the file size and read offset need to be aligned to this value.
ioChannelCountThe maximum number of requests that the IO controller driving the device supports. This value will be capped by the maximum number of parallel requests that can be issued per thread.
overCommitThe number of additional slots that will be reported as available. This makes sure that there are always a few requests pending to avoid starvation. An over-commit that is too large can negatively impact the scheduler's ability to re-order requests for optimal read order. A negative value will under-commit and will avoid saturating the IO controller which can be needed if the drive is used by other applications.
optionsAdditional configuration options. See ConstructionOptions for more details.

Member Function Documentation

◆ CollectStatistics()

void AZ::IO::StorageDriveWin::CollectStatistics ( AZStd::vector< Statistic > &  statistics) const
overridevirtual

Collect various statistics on this stack entry. These are for profiling and debugging purposes only.

Reimplemented from AZ::IO::StreamStackEntry.

◆ ExecuteRequests()

bool AZ::IO::StorageDriveWin::ExecuteRequests ( )
overridevirtual

Executes one or more queued requests. This is needed for synchronously executing requests, but asynchronous requests can already be running from the PrepareRequest call in which case this call is ignored.

Returns
True if a request was processed, otherwise false.

Reimplemented from AZ::IO::StreamStackEntry.

◆ PrepareRequest()

void AZ::IO::StorageDriveWin::PrepareRequest ( FileRequest request)
overridevirtual

Prepare an external request for processing. This can include resolving file paths, create more specific internal requests, etc. The returned will be queued for further processing by QueueRequest and ExecuteRequest.

Reimplemented from AZ::IO::StreamStackEntry.

◆ QueueRequest()

void AZ::IO::StorageDriveWin::QueueRequest ( FileRequest request)
overridevirtual

Queues a request to be executed at a later point when ExecuteRequests is called. This can include splitting up the request in more fine-grained steps.

Reimplemented from AZ::IO::StreamStackEntry.

◆ UpdateCompletionEstimates()

void AZ::IO::StorageDriveWin::UpdateCompletionEstimates ( AZStd::chrono::steady_clock::time_point  now,
AZStd::vector< FileRequest * > &  internalPending,
StreamerContext::PreparedQueue::iterator  pendingBegin,
StreamerContext::PreparedQueue::iterator  pendingEnd 
)
overridevirtual

Updates the estimate of the time the requests will complete. This generally works by bubbling up the estimation and each stack entry adding it's additional overhead if any. When chaining this call, first call the next entry in the stack before adding the current entry's estimate.

Parameters
nowThe current time. This is captured once to avoid repeatedly querying the system clock.
internalPendingThe requests that are pending in the stream stack. These are always estimated as coming after the queued requests. Because this call will go from the top of the stack to the bottom, but estimation is calculated from the bottom to the top, this list should be processed in reverse order.
pendingBeginIterator pointing to the start of the requests that are waiting for a processing slot in the stack.
pendingEndIterator pointing to the end of the requests that are waiting for a processing slot in the stack.

Reimplemented from AZ::IO::StreamStackEntry.

◆ UpdateStatus()

void AZ::IO::StorageDriveWin::UpdateStatus ( Status status) const
overridevirtual

Gets a combined status update from all the nodes in the stack.

Reimplemented from AZ::IO::StreamStackEntry.


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