Repository navigation
[CAS] Implemented llvm-cas --show-stat #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
slydiman
wants to merge
2
commits into
swift/next
Choose a base branch
from
swift/cas-diag-stats
base: swift/next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
| // REQUIRES: ondisk_cas | ||
| // REQUIRES: llvm-cas | ||
|
|
||
| // RUN: rm -rf %t && mkdir -p %t | ||
|
|
||
| // RUN: %llvm-cas --show-stats -cas %t/cas | FileCheck %s -check-prefix=NO-CACHE | ||
|
|
||
| // RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache %clang -c %s -o %t/test.o -Xclang -Rcompile-job-cache | ||
| // RUN: %llvm-cas --show-stats -cas %t/cas | FileCheck %s -check-prefix=CACHE-MISS | ||
|
|
||
| // RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache %clang -c %s -o %t/test.o -Xclang -Rcompile-job-cache | ||
| // RUN: %llvm-cas --show-stats -cas %t/cas | FileCheck %s -check-prefix=CACHE-HIT | ||
|
|
||
| // RUN: %llvm-cas --zero-stats -cas %t/cas | FileCheck %s -check-prefix=ZERO | ||
|
|
||
| // RUN: %llvm-cas --show-stats -cas %t/cas | FileCheck %s -check-prefix=AFTER-ZERO | ||
|
|
||
| // NO-CACHE: Cache hits: 0 | ||
| // NO-CACHE: Cache misses: 0 | ||
|
|
||
| // CACHE-MISS: Cache hits: 0 | ||
| // CACHE-MISS: Cache misses: 1 | ||
|
|
||
| // CACHE-HIT: Cache hits: 1 | ||
| // CACHE-HIT: Cache misses: 1 | ||
|
|
||
| // ZERO: zero-stats: successfull | ||
|
|
||
| // AFTER-ZERO: Cache hits: 0 | ||
| // AFTER-ZERO: Cache misses: 0 | ||
|
|
||
| int main() { return 0; } |
This file contains hidden or 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 hidden or 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,75 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| /// \file | ||
| /// | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_CAS_STATS_H | ||
| #define LLVM_CAS_STATS_H | ||
|
|
||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/Support/Error.h" | ||
| #include "llvm/Support/FileSystem.h" | ||
|
|
||
| namespace llvm::cas { | ||
|
|
||
| class Stats { | ||
| public: | ||
| static const uint64_t Version = 1; | ||
|
|
||
| enum class Key : uint16_t { | ||
| version = 0, | ||
| hit = 1, | ||
| miss = 2, | ||
| miss_result_not_found = 3, | ||
| backend_output_not_found = 4, | ||
| skipped = 5, | ||
| depscan_time = 6, | ||
| depscan_count = 7, | ||
| backend_key_query_time = 8, | ||
| backend_key_query_count = 9, | ||
| backend_key_update_time = 10, | ||
| backend_key_update_count = 11, | ||
| backend_load_time = 12, | ||
| backend_load_count = 13, | ||
| backend_store_time = 14, | ||
| backend_store_count = 15, | ||
| last = 16, | ||
| }; | ||
|
|
||
| Stats() : FD(-1) {}; | ||
| Stats(Stats &&Other) : Map(std::move(Other.Map)), FD(Other.FD) { | ||
| Other.FD = -1; | ||
| }; | ||
| ~Stats() { close(); } | ||
|
|
||
| Error open(StringRef Path); | ||
| void close(); | ||
|
|
||
| uint64_t get(Key K); | ||
| void set(Key K, uint64_t V); | ||
| void inc(Key K, uint64_t V = 1); | ||
|
|
||
| double get_f(Key K); | ||
| void set_f(Key K, double V); | ||
| void inc_f(Key K, double V); | ||
|
|
||
| private: | ||
| bool key_valid(Key K) { return (Map && K < Key::last); } | ||
| void *key2addr(Key K) { | ||
| return reinterpret_cast<void *>(Map.data() + (uint64_t)K * sizeof(uint64_t)); | ||
| } | ||
| int FD; | ||
| sys::fs::mapped_file_region Map; | ||
| }; | ||
|
|
||
| } // namespace llvm::cas | ||
|
|
||
| #endif // LLVM_CAS_STATS_H |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented-out code still needed, or can we safely remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can remove it.