Add docs to Skylark performance about len(depset) vs. if depset.

PiperOrigin-RevId: 174403764
diff --git a/site/docs/skylark/performance.md b/site/docs/skylark/performance.md
index 3eb011f..b7a88b4 100644
--- a/site/docs/skylark/performance.md
+++ b/site/docs/skylark/performance.md
@@ -86,6 +86,28 @@
 iterate a depset (explicitly or implicitly), or take its size, you are
 effectively calling `to_list`. This functionality will soon be removed.
 
+### Never call `len(depset)`
+
+It is O(N) to get the number of items in a depset. It is however
+O(1) to check if a depset is empty. This includes checking the truthiness
+of a depset:
+
+```
+def _impl(ctx):
+  args = ctx.actions.args()
+  files = depset(...)
+
+  # Bad, has to iterate over entire depset to get length
+  if len(files) == 0:
+    args.add("--files")
+    args.add(files)
+
+  # Good, O(1)
+  if files:
+    args.add("--files")
+    args.add(files)
+```
+
 ## Use `ctx.actions.args()` for command lines
 
 When building command lines you should use [ctx.actions.args()](lib/Args.html).