Page MenuHomeFreeBSD

cdefs.h: Add back comment about branch prediction
ClosedPublic

Authored by imp on Jul 2 2024, 6:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 5, 12:06 AM
Unknown Object (File)
Mon, Jan 27, 4:38 PM
Unknown Object (File)
Fri, Jan 24, 5:59 PM
Unknown Object (File)
Fri, Jan 24, 5:06 PM
Unknown Object (File)
Fri, Jan 10, 9:34 AM
Unknown Object (File)
Jan 3 2025, 2:07 AM
Unknown Object (File)
Jan 2 2025, 10:15 AM
Unknown Object (File)
Dec 14 2024, 1:30 AM
Subscribers

Details

Summary

Add back, with some minor editing, the comments about branch prediction,
when to use it, etc.

Requested by: jhb
Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Jul 2 2024, 6:03 PM
imp created this revision.

It did occur to me after I sent my earlier e-mail that while it's probably good to document this here, it probably belongs in style(9) in some form as well.

sys/sys/cdefs.h
326

maybe?

This revision is now accepted and ready to land.Jul 2 2024, 6:29 PM

simplify, and move some info into style(9)

This revision now requires review to proceed.Jul 2 2024, 7:33 PM
sys/sys/cdefs.h
326

Yup.

imp marked an inline comment as done.Jul 2 2024, 7:34 PM
share/man/man9/style.9
904

I would keep some of the old language about only using in paths that run frequently (not sure that "performance critical" alone implies that?).

905

I feel like some guidance on how to (not) nest these is also useful, that is I think the best practice (but this wasn't in the old comment) is to use a single hint for an entire if () expression, not multiple hints joined with operators, etc.

Maybe amend this to:

The
.Fn __predict_true
and
.Fn __predict_false
branch prediction hints should...

and then start this sentence with:

When using branch prediction hints,
atypical error conditions should use
.Fn __predict_false
(document any exceptions).
...

Currently I think it reads like it wants to encourage __predict_false.

update with jhb's suggestions. Hopefully I got them right

imp marked 2 inline comments as done.Jul 2 2024, 11:24 PM
imp added inline comments.
share/man/man9/style.9
904

Tried to update with this suggestion. It's good.

905

Good suggestion. Hopefully what I did captures this and deemphasizes things enough.

brooks added a subscriber: brooks.
brooks added inline comments.
sys/sys/cdefs.h
329

Consider adding a slight emphasis on measurement rather than just vibes

This revision is now accepted and ready to land.Jul 3 2024, 8:34 AM
This revision was automatically updated to reflect the committed changes.
imp marked 2 inline comments as done.