Changeset 279660 in webkit


Ignore:
Timestamp:
Jul 7, 2021, 12:54:06 PM (4 years ago)
Author:
chris.reid@sony.com
Message:

[PlayStation] Don't assume 4KB block size when estimating Network Cache disk usage
https://bugs.webkit.org/show_bug.cgi?id=227502

Reviewed by Chris Dumez.

Source/WebKit:

Network Cache disk usage can underestimate the real disk usage on platforms
with file blocks larger than 4 KB.
Adding call to FileSystem::getVolumeFileBlockSize to use the FileSystem's
block size in the estimation.

  • NetworkProcess/cache/NetworkCacheStorage.cpp:
  • NetworkProcess/cache/NetworkCacheStorage.h:

Source/WTF:

Add getVolumeFileBlockSize to fetch the block size from the filesystem.
Currently only implemented for Windows and POSIX filesystems.

  • wtf/FileSystem.cpp:
  • wtf/FileSystem.h:
  • wtf/playstation/FileSystemPlayStation.cpp:
Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r279645 r279660  
     12021-07-07  Christopher Reid  <chris.reid@sony.com>
     2
     3        [PlayStation] Don't assume 4KB block size when estimating Network Cache disk usage
     4        https://bugs.webkit.org/show_bug.cgi?id=227502
     5
     6        Reviewed by Chris Dumez.
     7
     8        Add getVolumeFileBlockSize to fetch the block size from the filesystem.
     9        Currently only implemented for Windows and POSIX filesystems.
     10
     11        * wtf/FileSystem.cpp:
     12        * wtf/FileSystem.h:
     13        * wtf/playstation/FileSystemPlayStation.cpp:
     14
    1152021-07-07  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WTF/wtf/FileSystem.h

    r279645 r279660  
    124124WTF_EXPORT_PRIVATE String parentPath(const String&);
    125125WTF_EXPORT_PRIVATE std::optional<uint64_t> volumeFreeSpace(const String&);
     126WTF_EXPORT_PRIVATE std::optional<uint32_t> volumeFileBlockSize(const String&);
    126127WTF_EXPORT_PRIVATE std::optional<int32_t> getFileDeviceId(const CString&);
    127128WTF_EXPORT_PRIVATE bool createSymbolicLink(const String& targetPath, const String& symbolicLinkPath);
  • trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp

    r278521 r279660  
    247247}
    248248
     249std::optional<uint32_t> volumeFileBlockSize(const String&)
     250{
     251    return std::nullopt;
     252}
     253
    249254#if USE(FILE_LOCK)
    250255bool lockFile(PlatformFileHandle handle, OptionSet<FileLockMode> lockMode)
  • trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp

    r278641 r279660  
    185185}
    186186
     187std::optional<uint32_t> volumeFileBlockSize(const String& path)
     188{
     189    struct statvfs fileStat;
     190    if (!statvfs(fileSystemRepresentation(path).data(), &fileStat))
     191        return fileStat.f_frsize;
     192
     193    return std::nullopt;
     194}
     195
    187196#if !USE(CF)
    188197String stringFromFileSystemRepresentation(const char* path)
  • trunk/Source/WTF/wtf/win/FileSystemWin.cpp

    r279085 r279660  
    364364}
    365365
     366std::optional<uint32_t> volumeFileBlockSize(const String& path)
     367{
     368    DWORD sectorsPerCluster, bytesPerSector, freeClusters, totalClusters;
     369    if (!GetDiskFreeSpaceW(path.wideCharacters().data(), &sectorsPerCluster, &bytesPerSector, &freeClusters, &totalClusters))
     370        return std::nullopt;
     371
     372    return sectorsPerCluster * bytesPerSector;
     373}
     374
    366375MappedFileData::~MappedFileData()
    367376{
  • trunk/Source/WebKit/ChangeLog

    r279658 r279660  
     12021-07-07  Christopher Reid  <chris.reid@sony.com>
     2
     3        [PlayStation] Don't assume 4KB block size when estimating Network Cache disk usage
     4        https://bugs.webkit.org/show_bug.cgi?id=227502
     5
     6        Reviewed by Chris Dumez.
     7
     8        Network Cache disk usage can underestimate the real disk usage on platforms
     9        with file blocks larger than 4 KB.
     10        Adding call to FileSystem::getVolumeFileBlockSize to use the FileSystem's
     11        block size in the estimation.
     12
     13        * NetworkProcess/cache/NetworkCacheStorage.cpp:
     14        * NetworkProcess/cache/NetworkCacheStorage.h:
     15
    1162021-07-07  Fujii Hironori  <Hironori.Fujii@sony.com>
    217
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp

    r279645 r279660  
    311311}
    312312
    313 static size_t estimateRecordsSize(unsigned recordCount, unsigned blobCount)
     313uint32_t Storage::volumeBlockSize() const
     314{
     315    ASSERT(!RunLoop::isMain());
     316
     317    if (!m_volumeBlockSize)
     318        m_volumeBlockSize = FileSystem::volumeFileBlockSize(m_basePath).value_or(4 * KB);
     319
     320    return *m_volumeBlockSize;
     321}
     322
     323size_t Storage::estimateRecordsSize(unsigned recordCount, unsigned blobCount) const
    314324{
    315325    auto inlineBodyCount = recordCount - std::min(blobCount, recordCount);
    316     auto headerSizes = recordCount * 4096;
     326    auto headerSizes = recordCount * volumeBlockSize();
    317327    auto inlineBodySizes = (maximumInlineBodySize() / 2) * inlineBodyCount;
    318328    return headerSizes + inlineBodySizes;
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h

    r278340 r279660  
    163163    static bool isHigherPriority(const std::unique_ptr<ReadOperation>&, const std::unique_ptr<ReadOperation>&);
    164164
     165    size_t estimateRecordsSize(unsigned recordCount, unsigned blobCount) const;
     166    uint32_t volumeBlockSize() const;
     167
    165168    const String m_basePath;
    166169    const String m_recordsPath;
     
    171174    size_t m_capacity { std::numeric_limits<size_t>::max() };
    172175    size_t m_approximateRecordsSize { 0 };
     176    mutable std::optional<uint32_t> m_volumeBlockSize;
    173177
    174178    // 2^18 bit filter can support up to 26000 entries with false positive rate < 1%.
Note: See TracChangeset for help on using the changeset viewer.