-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track disk io for reading disk index posting lists.
- Loading branch information
Showing
10 changed files
with
129 additions
and
14 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
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 "disk_io_stats.h" | ||
#include <ostream> | ||
|
||
namespace search { | ||
|
||
std::ostream& operator<<(std::ostream& os, const DiskIoStats& stats) { | ||
os << "{read_operations: " << stats.read_operations() << ", read_bytes: " << stats.read_bytes() << "}"; | ||
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,48 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <iosfwd> | ||
|
||
namespace search { | ||
|
||
/* | ||
* Class tracking disk io. | ||
*/ | ||
class DiskIoStats { | ||
uint64_t _read_operations; | ||
uint64_t _read_bytes; | ||
|
||
public: | ||
DiskIoStats() noexcept | ||
: _read_operations(0), | ||
_read_bytes(0) | ||
{} | ||
|
||
void add_read_operation(uint64_t bytes) noexcept { | ||
++_read_operations; | ||
_read_bytes += bytes; | ||
} | ||
void merge(const DiskIoStats& rhs) noexcept { | ||
_read_operations += rhs._read_operations; | ||
_read_bytes += rhs._read_bytes; | ||
} | ||
bool operator==(const DiskIoStats& rhs) const noexcept { | ||
return _read_operations == rhs._read_operations && | ||
_read_bytes == rhs._read_bytes; | ||
} | ||
void clear() noexcept { | ||
_read_operations = 0; | ||
_read_bytes = 0; | ||
} | ||
DiskIoStats read_and_clear() noexcept { auto result = *this; clear(); return result; } | ||
|
||
DiskIoStats& read_operations(uint64_t value) { _read_operations = value; return *this; } | ||
DiskIoStats& read_bytes(uint64_t value) { _read_bytes = value; return *this; } | ||
uint64_t read_operations() const noexcept { return _read_operations; } | ||
uint64_t read_bytes() const noexcept { return _read_bytes; } | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream& os, const DiskIoStats& 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