Skip to content

Conversation

@ktoso
Copy link
Member

@ktoso ktoso commented Mar 1, 2020

Motivation:

  • For tracing et al we'll want those cutpoints
  • Possibly metrics should use the same points btw

Related materials:

So we're actaually just on time with being able to do these things, it's a recent feature :-)

Modifications:

  • PoC cutpoints as an ActorInstrumentation
  • ActorInstruments for the Instruments.app that shows actor lifecycle, messages and other events
  • awesome for learning and exploring an actor system right now, in future also useful for debugging :)

The naming is a bit of a mess... need to figure it out.

Generally:

  • Instrumentation is the SPI,
  • then we plug in MetricsInstrument or TracingInstrument etc,
  • how do we call the Instruments integration?

Result:

Screen Shot 2020-03-02 at 12 21 22

  • Awesome "i can see what's going on, without even starting any external tracing/monitoring infra" while debugging and developing on my mac, user experience
  • prepares us for future Tracing integrationn

@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8" ?>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual instrument definition; it relates to the os_signpost calls we do in the code

self.address = shell.address
self.signpostID = OSSignpostID(
log: InstrumentsActorInstrumentation.logActors,
object: shell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to this the lifetime of this object is related to the specific shell <3 And all traces show up as related to it.
We cannot use the Address as this needs to be a pointer (i.e. a class value)

log: InstrumentsActorInstrumentation.logActors,
name: "Actor Lifecycle",
signpostID: self.signpostID,
"actor-spawned,myself:%{public}@", "\(self.address)"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These get (efficiently) parsed and carried into the Instruments app.

TODO: protect with if myLoggingHandle.signpostsEnabled { to only serialize the address and other data when needed.

log: InstrumentsActorInstrumentation.logActors,
name: "Actor Messages",
signpostID: self.signpostID,
"actor-message-received,myself:%{public}@,type:%{public}s", "\(self.address)", String(reflecting: type(of: message))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: protect with if myLoggingHandle.signpostsEnabled { to only serialize the address and other data when needed.

TODO: carry actual message as well

@ktoso ktoso changed the title [WIP/POC] Instrumentation points and PoC Instruments instrument +Instrumentation points and PoC os_signpost (Instruments) instrument Mar 2, 2020
settings.configure(with: OSSignpostInstrumentationProvider())
#endif
return settings
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default on Apple platforms we enable the signpost instrumentation, it's pretty cheap and if someone does not want it they may disable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instrumentation always has a cost though? might be better to disable by default and enable as needed?

@ktoso
Copy link
Member Author

ktoso commented Mar 2, 2020

More than happy to review this in depth (!).

I'll merge to ease development and using this to measure ongoing work.
Please review at will or we can talk it over some day in a tracing dedicated session

@ktoso ktoso merged commit 030bb10 into apple:master Mar 2, 2020
@ktoso ktoso deleted the wip-instruments branch March 2, 2020 05:35
@ktoso ktoso added this to the 0.5.0 - Cluster Hardening milestone Mar 2, 2020
@ktoso ktoso added 3 - in progress Ticket is being worked on t:observability Tracing, Metrics, Servicability... labels Mar 2, 2020
@ktoso ktoso self-assigned this Mar 2, 2020
@@ -0,0 +1,171 @@
// !$*UTF8*$!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to check in these .xcodeproj files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of fear we do with this project... :-(

I can't express this as swiftpm package as it's very xcode specific (the instruments "type"), to build it :-\

Or am I mistaking things, is this what people do with xcode projects? @tomerd @weissi ?

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Username in file path ^

<?xml version="1.0" encoding="UTF-8" ?>
<package>
<id>com.apple.actors.ActorInstruments</id>
<version>0.4.0</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does version have any special implications? As in, this has to match project version or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has one extra meaning:

if you "install" instruments into your Instruments.app "newer version" overrides an old one I believe. So when we update this we could keep updating this like 0.4.0.1 perhaps? And then bump as well whenever we release a tag

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.configure(with: OSSignpostInstrumentationProvider())
#endif
return settings
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instrumentation always has a cost though? might be better to disable by default and enable as needed?

@ktoso ktoso removed the 3 - in progress Ticket is being worked on label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:observability Tracing, Metrics, Servicability...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants