haskell / ghc-events

Library and tool for parsing .eventlog files from GHC
http://www.haskell.org/haskellwiki/ThreadScope
Other
33 stars 34 forks source link

What is evCap #63

Closed yaitskov closed 4 years ago

yaitskov commented 4 years ago

Please, comment purpose of evCap field in Event. Is it a thread id?

Mikolaj commented 4 years ago

Hi @yaitskov. I don't remember. Would you mind inserting a markdown link to the line of code? OOI, what are you working on?

yaitskov commented 4 years ago

@Mikolaj,

https://hackage.haskell.org/package/ghc-events-0.13.0/docs/src/GHC.RTS.EventTypes.html#evCap

Looks like it is polymorphic value depending on EventInfo constructor.

    postEventHeader(eb, tag);

    switch (tag) {
    case EVENT_CREATE_THREAD:   // (cap, thread)
    case EVENT_RUN_THREAD:      // (cap, thread)
    case EVENT_THREAD_RUNNABLE: // (cap, thread)
    {
        postThreadID(eb,thread);
        break;
    }

    case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread)
    {
        postThreadID(eb,info1 /* spark_thread */);
        break;
    }

    case EVENT_MIGRATE_THREAD:  // (cap, thread, new_cap)
    case EVENT_THREAD_WAKEUP:   // (cap, thread, other_cap)
    {
        postThreadID(eb,thread);
        postCapNo(eb,info1 /* new_cap | victim_cap | other_cap */);
        break;
   }

    case EVENT_STOP_THREAD:     // (cap, thread, status)
    {
        postThreadID(eb,thread);
        postWord16(eb,info1 /* status */);
        postThreadID(eb,info2 /* blocked on thread */);
        break;
    }

I am working on OpenTelemetry.

Mikolaj commented 4 years ago

A comment later on provides a hint:

-- | An event annotated with the Capability that generated it, if any
{-# DEPRECATED CapEvent "CapEvents will be removed soon, now Event has a field evCap" #-}

So, this is the capability on which the thread that emitted the event was running. The number indicates a CPU core, in other words. If absent, the even has no associated capability, e.g., is a global marker of a block of events, or something else global.

Mikolaj commented 4 years ago

BTW, there are various docs, papers and slides on that (on one I'm a co-author). Search for "Threadscope".

yaitskov commented 4 years ago

Thanks