Commit f119abb
runtime: refactor runtime->tracer API to appear more like a lock
Currently the execution tracer synchronizes with itself using very
heavyweight operations. As a result, it's totally fine for most of the
tracer code to look like:
if traceEnabled() {
traceXXX(...)
}
However, if we want to make that synchronization more lightweight (as
issue #60773 proposes), then this is insufficient. In particular, we
need to make sure the tracer can't observe an inconsistency between g
atomicstatus and the event that would be emitted for a particular
g transition. This means making the g status change appear to happen
atomically with the corresponding trace event being written out from the
perspective of the tracer.
This requires a change in API to something more like a lock. While we're
here, we might as well make sure that trace events can *only* be emitted
while this lock is held. This change introduces such an API:
traceAcquire, which returns a value that can emit events, and
traceRelease, which requires the value that was returned by
traceAcquire. In practice, this won't be a real lock, it'll be more like
a seqlock.
For the current tracer, this API is completely overkill and the value
returned by traceAcquire basically just checks trace.enabled. But it's
necessary for the tracer described in #60773 and we can implement that
more cleanly if we do this refactoring now instead of later.
For #60773.
Change-Id: Ibb9ff5958376339fafc2b5180aef65cf2ba18646
Reviewed-on: https://go-review.googlesource.com/c/go/+/515635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>1 parent e3585c6 commit f119abb
File tree
9 files changed
+388
-177
lines changed- src/runtime
9 files changed
+388
-177
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 169 | + | |
172 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
229 | | - | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
236 | 240 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 241 | + | |
240 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
160 | | - | |
161 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
| |||
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
173 | | - | |
174 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
175 | 183 | | |
176 | 184 | | |
177 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
651 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
| |||
989 | 991 | | |
990 | 992 | | |
991 | 993 | | |
992 | | - | |
993 | | - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
994 | 998 | | |
995 | 999 | | |
996 | 1000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
424 | 428 | | |
425 | 429 | | |
426 | 430 | | |
| |||
461 | 465 | | |
462 | 466 | | |
463 | 467 | | |
464 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
465 | 473 | | |
466 | 474 | | |
467 | 475 | | |
468 | 476 | | |
469 | | - | |
470 | 477 | | |
471 | | - | |
472 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
473 | 484 | | |
474 | 485 | | |
475 | 486 | | |
| |||
515 | 526 | | |
516 | 527 | | |
517 | 528 | | |
518 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
519 | 534 | | |
520 | 535 | | |
521 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
810 | 811 | | |
811 | | - | |
812 | | - | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
| |||
828 | 830 | | |
829 | 831 | | |
830 | 832 | | |
831 | | - | |
832 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
833 | 837 | | |
834 | 838 | | |
835 | 839 | | |
| |||
856 | 860 | | |
857 | 861 | | |
858 | 862 | | |
| 863 | + | |
859 | 864 | | |
860 | | - | |
| 865 | + | |
861 | 866 | | |
862 | | - | |
| 867 | + | |
| 868 | + | |
863 | 869 | | |
864 | 870 | | |
865 | 871 | | |
| |||
1428 | 1434 | | |
1429 | 1435 | | |
1430 | 1436 | | |
1431 | | - | |
1432 | | - | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1433 | 1441 | | |
1434 | 1442 | | |
1435 | 1443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
520 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| |||
889 | 891 | | |
890 | 892 | | |
891 | 893 | | |
892 | | - | |
893 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
894 | 898 | | |
895 | 899 | | |
896 | 900 | | |
| |||
929 | 933 | | |
930 | 934 | | |
931 | 935 | | |
932 | | - | |
933 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
934 | 940 | | |
935 | 941 | | |
936 | 942 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | | - | |
795 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
796 | 798 | | |
797 | 799 | | |
798 | 800 | | |
| |||
839 | 841 | | |
840 | 842 | | |
841 | 843 | | |
842 | | - | |
843 | | - | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
844 | 848 | | |
845 | 849 | | |
846 | 850 | | |
| |||
911 | 915 | | |
912 | 916 | | |
913 | 917 | | |
914 | | - | |
| 918 | + | |
| 919 | + | |
915 | 920 | | |
916 | 921 | | |
917 | | - | |
| 922 | + | |
| 923 | + | |
918 | 924 | | |
919 | 925 | | |
920 | 926 | | |
| |||
0 commit comments