forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
137344: ctxutil: introduce fast values r=RaduBerinde a=RaduBerinde #### go.mod: update logtag dependency See cockroachdb/logtags#4 Epic: none Release note: None #### serverident: unexport ServerIdentificationContextKey Epic: none Release note: None #### ctxutil: introduce fast values This commit introduces a custom context type that can be used to more efficiently associate values to contexts. Instead of using arbitrary objects as keys, the keys are a small set of integers. Any key must be globally registered first, and there is a limited number that can be registered. The `fastValuesCtx` stores *all* values for these keys, so traversing the context hierarchy is not necessary. We also provide a way to add multiple values at the same time, which saves on allocations. I looked at before and after profiles in sysbench. Before: - CPU usage: context.value 0.6% context.WithValue 0.3% total 0.9% - Allocs: context.WithValue: 3.5% After: - CPU usage: context.value + ctxutil.FastValue 0.5% context.WithValue 0.1% ctxutil.WithFastValue(s) 0.1% total 0.7% - Allocs: context.WithValue: 0.2% context.WithFastValue: 0.6% ctxutil.FastValuesBuilder.Finish: 1.4% total 2.2% I will investigate improving on this, perhaps with providing a pre-allocated context in codepaths where this is possible. Informs: cockroachdb#136581 Informs: cockroachdb#135904 Release note: None Co-authored-by: Radu Berinde <[email protected]>
- Loading branch information
Showing
26 changed files
with
320 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1821,10 +1821,10 @@ def go_deps(): | |
name = "com_github_cockroachdb_logtags", | ||
build_file_proto_mode = "disable_global", | ||
importpath = "github.com/cockroachdb/logtags", | ||
sha256 = "ca7776f47e5fecb4c495490a679036bfc29d95bd7625290cfdb9abb0baf97476", | ||
strip_prefix = "github.com/cockroachdb/[email protected]20230118201751-21c54148d20b", | ||
sha256 = "ff8b3d36873cfff78669000d194cbaa96520549a62408c52b538380d953b99d7", | ||
strip_prefix = "github.com/cockroachdb/[email protected]20241205023844-89a8856d99be", | ||
urls = [ | ||
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/logtags/com_github_cockroachdb_logtags-v0.0.0-20230118201751-21c54148d20b.zip", | ||
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/logtags/com_github_cockroachdb_logtags-v0.0.0-20241205023844-89a8856d99be.zip", | ||
], | ||
) | ||
go_repository( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.