Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156728031
D45837.id140479.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D45837.id140479.diff
View Options
diff --git a/share/man/man9/style.9 b/share/man/man9/style.9
--- a/share/man/man9/style.9
+++ b/share/man/man9/style.9
@@ -902,6 +902,19 @@
.Fn _Static_assert
instead of the older
.Fn CTASSERT .
+.Pp
+.Fn __predict_true
+and
+.Fn __predict_false
+should only be used in performance critical code.
+Consistently use
+.Fn __predict_false
+for error conditions that are not typical, and document the exceptions.
+Use
+.Fn __predict_true
+for operations expected to almost always succeed.
+Do not add these annotations without empirical evidence of the likelihood of the
+branch.
.Sh FILES
.Bl -tag -width indent
.It Pa /usr/src/tools/build/checkstyle9.pl
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -321,6 +321,13 @@
#define __restrict restrict
#endif
+/*
+ * All modern compilers have explicit branch prediction so that the CPU back-end
+ * can hint to the processor and also so that code blocks can be reordered such
+ * that the predicted path sees a more linear flow, thus improving cache
+ * behavior, etc. Use sparingly, except in performance critical code where
+ * they make things faster.
+ */
#define __predict_true(exp) __builtin_expect((exp), 1)
#define __predict_false(exp) __builtin_expect((exp), 0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 16, 11:09 PM (16 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33158006
Default Alt Text
D45837.id140479.diff (1 KB)
Attached To
Mode
D45837: cdefs.h: Add back comment about branch prediction
Attached
Detach File
Event Timeline
Log In to Comment