summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-02 03:28:26 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-02 03:28:26 +0000
commit27814980a362ce88a1b34834aeb3cc38e4257d2f (patch)
tree40a24cab782fc9749f198061241a11d5926fb0f3 /llvm/include
parent4fda708624e1453c89e0520008de4780fc4fb885 (diff)
downloadbcm5719-llvm-27814980a362ce88a1b34834aeb3cc38e4257d2f.tar.gz
bcm5719-llvm-27814980a362ce88a1b34834aeb3cc38e4257d2f.zip
Add Cache Pruning support
Incremental LTO will usea cache to store object files. This patch handles the pruning part of the cache, exposing a few knobs: - Pruning interval: the implementation keeps a "timestamp" file in the directory and will scan it only after a given interval since the last modification of the timestamp file. This is for performance purpose, we don't want to scan continuously the folder. - Entry expiration: this is the time after which a file that hasn't been used is remove from the cache. - Maximum size: expressed in percentage of the available disk space, it helps to avoid that we blow up the disk space. http://reviews.llvm.org/D18422 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265209
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Support/CachePruning.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/CachePruning.h b/llvm/include/llvm/Support/CachePruning.h
new file mode 100644
index 00000000000..38341411913
--- /dev/null
+++ b/llvm/include/llvm/Support/CachePruning.h
@@ -0,0 +1,69 @@
+//=- CachePruning.h - Helper to manage the pruning of a cache dir -*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements pruning of a directory intended for cache storage, using
+// various policies.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_CACHE_PRUNING_H
+#define LLVM_SUPPORT_CACHE_PRUNING_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+
+/// Handle pruning a directory provided a path and some options to control what
+/// to prune.
+class CachePruning {
+public:
+ /// Prepare to prune \p Path.
+ CachePruning(StringRef Path) : Path(Path) {}
+
+ /// Define the pruning interval. This is intended to be used to avoid scanning
+ /// the directory too often. It does not impact the decision of which file to
+ /// prune. A value of 0 forces the scan to occurs.
+ CachePruning &setPruningInterval(int PruningInterval) {
+ Interval = PruningInterval;
+ return *this;
+ }
+
+ /// Define the expiration for a file. When a file hasn't been accessed for
+ /// \p ExpireAfter seconds, it is removed from the cache. A value of 0 disable
+ /// the expiration-based pruning.
+ CachePruning &setEntryExpiration(unsigned ExpireAfter) {
+ Expiration = ExpireAfter;
+ return *this;
+ }
+
+ /// Define the maximum size for the cache directory, in terms of percentage of
+ /// the available space on the the disk. Set to 100 to indicate no limit, 50
+ /// to indicate that the cache size will not be left over half the
+ /// available disk space. A value over 100 will be reduced to 100. A value of
+ /// 0 disable the size-based pruning.
+ CachePruning &setMaxSize(unsigned Percentage) {
+ PercentageOfAvailableSpace = std::min(100u, Percentage);
+ return *this;
+ }
+
+ /// Peform pruning using the supplied options, returns true if pruning
+ /// occured, i.e. if PruningInterval was expired.
+ bool prune();
+
+private:
+ // Options that matches the setters above.
+ std::string Path;
+ unsigned Expiration = 0;
+ unsigned Interval = 0;
+ unsigned PercentageOfAvailableSpace = 0;
+};
+
+} // namespace llvm
+
+#endif \ No newline at end of file
OpenPOWER on IntegriCloud