Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
1353f54a
Commit
1353f54a
authored
Jun 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X tracing: Review a bit
parent
8dbd955e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
26 deletions
+61
-26
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+4
-4
go/xcommon/tracing/runtime.go
go/xcommon/tracing/runtime.go
+38
-0
go/xcommon/tracing/runtime_test.go
go/xcommon/tracing/runtime_test.go
+2
-0
go/xcommon/tracing/tracing.go
go/xcommon/tracing/tracing.go
+16
-21
go/xcommon/tracing/tracing.s
go/xcommon/tracing/tracing.s
+1
-1
No files found.
go/neo/server/cluster_test.go
View file @
1353f54a
...
...
@@ -129,12 +129,12 @@ func TestMasterStorage(t *testing.T) {
net
:=
pipenet
.
New
(
"testnet"
)
// test network
tg
:=
&
tracing
.
Group
{}
defer
t
g
.
Done
()
pg
:=
&
tracing
.
Probe
Group
{}
defer
p
g
.
Done
()
tracing
.
Lock
()
neo_traceConnRecv_Attach
(
t
g
,
tracer
.
traceNeoConnRecv
)
neo_traceConnSend_Attach
(
t
g
,
tracer
.
traceNeoConnSend
)
neo_traceConnRecv_Attach
(
p
g
,
tracer
.
traceNeoConnRecv
)
neo_traceConnSend_Attach
(
p
g
,
tracer
.
traceNeoConnSend
)
tracing
.
Unlock
()
...
...
go/xcommon/tracing/runtime.go
0 → 100644
View file @
1353f54a
// Copyright (C) 2016-2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
package
tracing
// stop-the-world that should probably be in xruntime, but I'm (yet) hesitating
// to expose the API to public.
import
_
"unsafe"
//go:linkname runtime_stopTheWorld runtime.stopTheWorld
//go:linkname runtime_startTheWorld runtime.startTheWorld
// runtime_stopTheWorld returns with the world stopped
// Current goroutine remains the only one who is running, with others
// goroutines stopped at safe GC points.
// It requires careful programming as many things that normally work lead to
// fatal errors when the world is stoppped - for example using timers would be
// invalid, but adjusting plain values in memory is ok.
func
runtime_stopTheWorld
(
reason
string
)
// StartTheWorld restarts the world after it was stopped by runtime_stopTheWorld
func
runtime_startTheWorld
()
go/xcommon/tracing/runtime_test.go
0 → 100644
View file @
1353f54a
package
tracing
// TODO tests for stop/start the world.
go/xcommon/tracing/tracing.go
View file @
1353f54a
...
...
@@ -16,24 +16,19 @@
// See COPYING file for full licensing terms.
// Package tracing provides runtime support for Go tracing facilities
// XXX ^^^ += "and usage" ?
// TODO describe how to define tracepoints
// TODO doc:
// - tracepoints
// - probes
// - probes can be attached/detached to/from tracepoints
package
tracing
import
(
"sync"
"sync/atomic"
_
"unsafe"
)
// XXX move StopTheWorld to xruntime ?
//go:linkname runtime_stopTheWorld runtime.stopTheWorld
func
runtime_stopTheWorld
(
string
)
//go:linkname runtime_startTheWorld runtime.startTheWorld
func
runtime_startTheWorld
()
// big tracing lock
var
traceMu
sync
.
Mutex
var
traceLocked
int32
// for cheap protective checks whether Lock is held
...
...
@@ -81,7 +76,7 @@ type Probe struct {
// probefunc func(some arguments)
}
// Next return next probe attached to the same tracepoint
// Next return
s
next probe attached to the same tracepoint
// It is safe to iterate Next under any conditions.
func
(
p
*
Probe
)
Next
()
*
Probe
{
return
p
.
next
...
...
@@ -91,7 +86,7 @@ func (p *Probe) Next() *Probe {
// If group is non-nil the probe is also added to the group.
// Must be called under Lock.
// Probe must be newly created.
func
AttachProbe
(
g
*
Group
,
listp
**
Probe
,
probe
*
Probe
)
{
func
AttachProbe
(
pg
*
Probe
Group
,
listp
**
Probe
,
probe
*
Probe
)
{
verifyLocked
()
if
!
(
probe
.
prev
==
nil
||
probe
.
next
==
nil
)
{
...
...
@@ -110,8 +105,8 @@ func AttachProbe(g *Group, listp **Probe, probe *Probe) {
*
listp
=
probe
}
if
g
!=
nil
{
g
.
Add
(
probe
)
if
p
g
!=
nil
{
p
g
.
Add
(
probe
)
}
}
...
...
@@ -145,27 +140,27 @@ func (p *Probe) Detach() {
p
.
prev
=
p
}
// Group is a group of probes attached to tracepoints
type
Group
struct
{
//
Probe
Group is a group of probes attached to tracepoints
type
Probe
Group
struct
{
probev
[]
*
Probe
}
// Add adds a probe to the group
// Must be called under Lock
func
(
g
*
Group
)
Add
(
p
*
Probe
)
{
func
(
pg
*
Probe
Group
)
Add
(
p
*
Probe
)
{
verifyLocked
()
g
.
probev
=
append
(
g
.
probev
)
pg
.
probev
=
append
(
pg
.
probev
,
p
)
}
// Done detaches all probes registered in the group
// Must be called under normal conditions, not under Lock
func
(
g
*
Group
)
Done
()
{
func
(
pg
*
Probe
Group
)
Done
()
{
verifyUnlocked
()
Lock
()
defer
Unlock
()
for
_
,
p
:=
range
g
.
probev
{
for
_
,
p
:=
range
p
g
.
probev
{
p
.
Detach
()
}
g
.
probev
=
nil
p
g
.
probev
=
nil
}
go/xcommon/tracing/tracing.s
View file @
1353f54a
//
empty
.
s
so
`
go
build
`
does
not
use
-
complete
//
empty
.
s
so
`
go
build
`
does
not
use
-
complete
for
go
:
linkname
to
work
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment