[llvm] r321376 - [ThinLTO][CachePruning] explicitly disable pruning
Aleksey Shlyapnikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 22 11:12:56 PST 2017
This commit breaks our bot:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/11854,
please fix.
On Fri, Dec 22, 2017 at 10:32 AM, Ben Dunbobbin via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: bd1976llvm
> Date: Fri Dec 22 10:32:15 2017
> New Revision: 321376
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321376&view=rev
> Log:
> [ThinLTO][CachePruning] explicitly disable pruning
>
> In https://reviews.llvm.org/rL321077 and https://reviews.llvm.org/D41231
> I fixed a regression in the c-api which prevented the pruning from being
> *effectively* disabled.
>
> However this approach, helpfully recommended by @labath, is cleaner.
> It is also nice to remove the weasel words about effectively disabling
> from the api comments.
>
> Differential Revision: https://reviews.llvm.org/D41497
>
> Modified:
> llvm/trunk/include/llvm-c/lto.h
> llvm/trunk/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
> llvm/trunk/include/llvm/Support/CachePruning.h
> llvm/trunk/lib/Support/CachePruning.cpp
>
> Modified: llvm/trunk/include/llvm-c/lto.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm-c/lto.h?rev=321376&r1=321375&r2=321376&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm-c/lto.h (original)
> +++ llvm/trunk/include/llvm-c/lto.h Fri Dec 22 10:32:15 2017
> @@ -764,7 +764,7 @@ extern void thinlto_codegen_add_cross_re
> * To avoid filling the disk space, a few knobs are provided:
> * - The pruning interval limits the frequency at which the garbage
> collector
> * will try to scan the cache directory to prune expired entries.
> - * Setting to a negative number applies the maximum interval.
> + * Setting to a negative number disables the pruning.
> * - The pruning expiration time indicates to the garbage collector how
> old an
> * entry needs to be to be removed.
> * - Finally, the garbage collector can be instructed to prune the cache
> until
> @@ -782,9 +782,9 @@ extern void thinlto_codegen_set_cache_di
> const char *cache_dir);
>
> /**
> - * Sets the cache pruning interval (in seconds). A negative value sets the
> - * maximum possible pruning interval. An unspecified default value will be
> - * applied, and a value of 0 will be ignored.
> + * Sets the cache pruning interval (in seconds). A negative value
> disables the
> + * pruning. An unspecified default value will be applied, and a value of
> 0 will
> + * be ignored.
> *
> * \since LTO_API_VERSION=18
> */
>
> Modified: llvm/trunk/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/LTO/legacy/ThinLTOCodeGenerator.h?rev=321376&r1=321375&r2=321376&
> view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h (original)
> +++ llvm/trunk/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h Fri Dec 22
> 10:32:15 2017
> @@ -148,16 +148,15 @@ public:
> /// incremental build.
> void setCacheDir(std::string Path) { CacheOptions.Path =
> std::move(Path); }
>
> - /// Cache policy: interval (seconds) between two prunes of the cache. A
> - /// negative value sets the maximum possible pruning interval. A value
> - /// of 0 will be ignored.
> + /// Cache policy: interval (seconds) between two prunes of the cache.
> Set to a
> + /// negative value to disable pruning. A value of 0 will be ignored.
> void setCachePruningInterval(int Interval) {
> - static_assert(std::is_same<decltype(CacheOptions.Policy.Interval),
> - std::chrono::seconds>::value,
> - "ensure same types to avoid risk of overflow");
> - if (Interval)
> - CacheOptions.Policy.Interval = Interval > 0 ?
> std::chrono::seconds(Interval)
> - :
> std::chrono::seconds::max();
> + if (Interval == 0)
> + return;
> + if(Interval < 0)
> + CacheOptions.Policy.Interval.reset();
> + else
> + CacheOptions.Policy.Interval = std::chrono::seconds(Interval);
> }
>
> /// Cache policy: expiration (in seconds) for an entry.
>
> Modified: llvm/trunk/include/llvm/Support/CachePruning.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/Support/CachePruning.h?rev=321376&r1=321375&r2=321376&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Support/CachePruning.h (original)
> +++ llvm/trunk/include/llvm/Support/CachePruning.h Fri Dec 22 10:32:15
> 2017
> @@ -27,8 +27,9 @@ template <typename T> class Expected;
> struct CachePruningPolicy {
> /// 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 occur.
> - std::chrono::seconds Interval = std::chrono::seconds(1200);
> + /// prune. A value of 0 forces the scan to occur. A value of None
> disables
> + /// pruning.
> + llvm::Optional<std::chrono::seconds> Interval =
> std::chrono::seconds(1200);
>
> /// The expiration for a file. When a file hasn't been accessed for
> Expiration
> /// seconds, it is removed from the cache. A value of 0 disables the
>
> Modified: llvm/trunk/lib/Support/CachePruning.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Support/CachePruning.cpp?rev=321376&r1=321375&r2=321376&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Support/CachePruning.cpp (original)
> +++ llvm/trunk/lib/Support/CachePruning.cpp Fri Dec 22 10:32:15 2017
> @@ -155,8 +155,7 @@ bool llvm::pruneCache(StringRef Path, Ca
> SmallString<128> TimestampFile(Path);
> sys::path::append(TimestampFile, "llvmcache.timestamp");
> sys::fs::file_status FileStatus;
> - const auto CurrentTime =
> - time_point_cast<decltype(Policy.Interval)>(system_clock::now());
> + const auto CurrentTime = system_clock::now();
> if (auto EC = sys::fs::status(TimestampFile, FileStatus)) {
> if (EC == errc::no_such_file_or_directory) {
> // If the timestamp file wasn't there, create one now.
> @@ -166,13 +165,14 @@ bool llvm::pruneCache(StringRef Path, Ca
> return false;
> }
> } else {
> + if (!Policy.Interval)
> + return false;
> if (Policy.Interval != seconds(0)) {
> // Check whether the time stamp is older than our pruning interval.
> // If not, do nothing.
> - const auto TimeStampModTime = time_point_cast<decltype(
> Policy.Interval)>(
> - FileStatus.getLastModificationTime());
> + const auto TimeStampModTime = FileStatus.getLastModificationTime();
> auto TimeStampAge = CurrentTime - TimeStampModTime;
> - if (TimeStampAge <= Policy.Interval) {
> + if (TimeStampAge <= *Policy.Interval) {
> DEBUG(dbgs() << "Timestamp file too recent ("
> << duration_cast<seconds>(TimeStampAge).count()
> << "s old), do not prune.\n");
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171222/47836c92/attachment.html>
More information about the llvm-commits
mailing list