aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/debug/debug_io_utils.h
diff options
context:
space:
mode:
authorGravatar Shanqing Cai <cais@google.com>2018-08-28 19:03:56 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-28 19:12:42 -0700
commit3d35a07179d4d38d0cabac4415c550f1cbce00c0 (patch)
tree34c06cc6339a273722f48689e7e58de88d18c0ba /tensorflow/core/debug/debug_io_utils.h
parent20d5683b826be03776978af3b8108fc3b5dc9cb8 (diff)
tfdbg: Add adjustable limit to total bytes dumped to disk
RELNOTES: tfdbg: Limit the total disk space occupied by dumped tensor data to 100 GBytes. Add environment variable `TFDBG_DISK_BYTES_LIMIT` to allow adjustment of this upper limit. PiperOrigin-RevId: 210648585
Diffstat (limited to 'tensorflow/core/debug/debug_io_utils.h')
-rw-r--r--tensorflow/core/debug/debug_io_utils.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/tensorflow/core/debug/debug_io_utils.h b/tensorflow/core/debug/debug_io_utils.h
index cedb7386b7..56f8b74e18 100644
--- a/tensorflow/core/debug/debug_io_utils.h
+++ b/tensorflow/core/debug/debug_io_utils.h
@@ -193,6 +193,26 @@ class DebugFileIO {
const string& dir_name,
const string& file_name);
+ // Request additional bytes to be dumped to the file system.
+ //
+ // Does not actually dump the bytes, but instead just performs the
+ // bookkeeping necessary to prevent the total dumped amount of data from
+ // exceeding the limit (default 100 GBytes or set customly through the
+ // environment variable TFDBG_DISK_BYTES_LIMIT).
+ //
+ // Args:
+ // bytes: Number of bytes to request.
+ //
+ // Returns:
+ // Whether the request is approved given the total dumping
+ // limit.
+ static bool requestDiskByteUsage(uint64 bytes);
+
+ // Reset the disk byte usage to zero.
+ static void resetDiskByteUsage();
+
+ static uint64 globalDiskBytesLimit;
+
private:
// Encapsulates the Tensor in an Event protobuf and write it to file.
static Status DumpTensorToEventFile(const DebugNodeKey& debug_node_key,
@@ -204,6 +224,11 @@ class DebugFileIO {
// TODO(cais): Replace with shared implementation once http://b/30497715 is
// fixed.
static Status RecursiveCreateDir(Env* env, const string& dir);
+
+ static uint64 diskBytesUsed;
+ static const uint64 defaultGlobalDiskBytesLimit;
+
+ friend class DiskUsageLimitTest;
};
} // namespace tensorflow