-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32821 from vespa-engine/toregge/add-cache-disk-io…
…-stats Add CacheDiskIoStats.
- Loading branch information
Showing
12 changed files
with
127 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
searchlib/src/vespa/searchlib/util/cache_disk_io_stats.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
|
||
#include "cache_disk_io_stats.h" | ||
#include <ostream> | ||
|
||
namespace search { | ||
|
||
std::ostream& operator<<(std::ostream& os, const CacheDiskIoStats& stats) { | ||
os << "{read: " << stats.read() << ", cached_read: " << stats.cached_read() << "}"; | ||
return os; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
#pragma once | ||
|
||
#include "disk_io_stats.h" | ||
|
||
namespace search { | ||
|
||
/* | ||
* Class tracking disk io when using a cache. | ||
*/ | ||
class CacheDiskIoStats { | ||
DiskIoStats _read; // cache miss | ||
DiskIoStats _cached_read; // cache hit | ||
|
||
public: | ||
CacheDiskIoStats() noexcept | ||
: _read(), | ||
_cached_read() | ||
{ | ||
} | ||
|
||
CacheDiskIoStats& read(const DiskIoStats& value) { _read = value; return *this; } | ||
CacheDiskIoStats& cached_read(DiskIoStats& value) { _cached_read = value; return *this; } | ||
const DiskIoStats& read() const noexcept { return _read; } | ||
const DiskIoStats& cached_read() const noexcept { return _cached_read; } | ||
void merge(const CacheDiskIoStats& rhs) noexcept { | ||
_read.merge(rhs.read()); | ||
_cached_read.merge(rhs.cached_read()); | ||
} | ||
|
||
bool operator==(const CacheDiskIoStats &rhs) const noexcept { | ||
return _read == rhs.read() && | ||
_cached_read == rhs.cached_read(); | ||
} | ||
CacheDiskIoStats read_and_clear() noexcept { auto result = *this; clear(); return result; } | ||
void clear() noexcept { | ||
_read.clear(); | ||
_cached_read.clear(); | ||
} | ||
void add_uncached_read_operation(uint64_t bytes) noexcept { _read.add_read_operation(bytes); } | ||
void add_cached_read_operation(uint64_t bytes) noexcept { _cached_read.add_read_operation(bytes); } | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream& os, const CacheDiskIoStats& stats); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters