summaryrefslogtreecommitdiff
path: root/src/vm/eventpipefile.h
diff options
context:
space:
mode:
authorAdam Sitnik <adam.sitnik@gmail.com>2018-02-02 23:07:25 +0100
committerGitHub <noreply@github.com>2018-02-02 23:07:25 +0100
commitf6ba335278bb966e8e5f9cd33f51818c6fac44fa (patch)
tree34f19451c962381c3d834fa8db5f334556390756 /src/vm/eventpipefile.h
parent70bf6a4586b3cad9cf8cc26ca85ec6d552123202 (diff)
downloadcoreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.tar.gz
coreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.tar.bz2
coreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.zip
Event Pipe File V3 (#16107)
* write missing information to the event pipe file (pointer size to make it work fo x86) * define where the events start, not only where they end * include process Id in the event pipe file, bump the version so old consumers get clear error message * write the missing EndObject tag to close the header * include expected CPU sampling rate in the event pipe header file * include keywords in V3 of EventPipe metadata, fixes #11934 * remove forward references * entry object comes after the header and ends after it's data, before the event block objects * introduce event block * fix the GC contracts * generate metadata ids * end the file with null reference tag * getting it work * 4 byte alignment of serialized event data * Revert "include keywords in V3 of EventPipe metadata, fixes #11934" This reverts commit 98ef2f588e271f928fd051e96da526dc1e0f017c. * remove event Id and event version from metadata buffer (it was duplicated with native code) * increase the block size to be the same as buffer size * Write the last event block to the file after disabling the event pipe, right after last events * include the sife in itself * the native part was supposed to not duplicate the event id and version, not manged * ensure 4 byte alignment * build metadata when it's not provided, so payload is never empty (no need to serialize length) * this todo is no longer valid * don't align everything, just the content of event block as suggested by @vancem * improvements after code review * update TraceEvent dependency, make the test verify new feature * InterlockedIncrement(Int32) is not available for non-Windows OSes * code improvements after Skype code review from @jorive
Diffstat (limited to 'src/vm/eventpipefile.h')
-rw-r--r--src/vm/eventpipefile.h60
1 files changed, 42 insertions, 18 deletions
diff --git a/src/vm/eventpipefile.h b/src/vm/eventpipefile.h
index 2f6853545d..48f0bb0557 100644
--- a/src/vm/eventpipefile.h
+++ b/src/vm/eventpipefile.h
@@ -9,6 +9,7 @@
#ifdef FEATURE_PERFTRACING
#include "eventpipe.h"
+#include "eventpipeblock.h"
#include "eventpipeeventinstance.h"
#include "fastserializableobject.h"
#include "fastserializer.h"
@@ -25,37 +26,53 @@ class EventPipeFile : public FastSerializableObject
);
~EventPipeFile();
- // Write an event to the file.
void WriteEvent(EventPipeEventInstance &instance);
- // Serialize this object.
- // Not supported - this is the entry object for the trace,
- // which means that the contents hasn't yet been created.
- void FastSerialize(FastSerializer *pSerializer)
+ void WriteEnd();
+
+ const char* GetTypeName()
{
LIMITED_METHOD_CONTRACT;
- _ASSERTE(!"This function should never be called!");
+ return "Trace";
}
- // Get the type name of this object.
- const char* GetTypeName()
+ void FastSerialize(FastSerializer *pSerializer)
{
- LIMITED_METHOD_CONTRACT;
- return "Microsoft.DotNet.Runtime.EventPipeFile";
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_PREEMPTIVE;
+ PRECONDITION(pSerializer != NULL);
+ }
+ CONTRACTL_END;
+
+ pSerializer->WriteBuffer((BYTE*)&m_fileOpenSystemTime, sizeof(m_fileOpenSystemTime));
+ pSerializer->WriteBuffer((BYTE*)&m_fileOpenTimeStamp, sizeof(m_fileOpenTimeStamp));
+ pSerializer->WriteBuffer((BYTE*)&m_timeStampFrequency, sizeof(m_timeStampFrequency));
+
+ // the beginning of V3
+ pSerializer->WriteBuffer((BYTE*)&m_pointerSize, sizeof(m_pointerSize));
+ pSerializer->WriteBuffer((BYTE*)&m_currentProcessId, sizeof(m_currentProcessId));
+ pSerializer->WriteBuffer((BYTE*)&m_numberOfProcessors, sizeof(m_numberOfProcessors));
+ pSerializer->WriteBuffer((BYTE*)&m_samplingRateInNs, sizeof(m_samplingRateInNs));
}
private:
- // Get the metadata address in the file for an event.
- // The return value can be written into the file as a back-pointer to the event metadata.
- StreamLabel GetMetadataLabel(EventPipeEvent &event);
+ unsigned int GenerateMetadataId();
+
+ unsigned int GetMetadataId(EventPipeEvent &event);
- // Save the metadata address in the file for an event.
- void SaveMetadataLabel(EventPipeEvent &event, StreamLabel label);
+ void SaveMetadataId(EventPipeEvent &event, unsigned int metadataId);
+
+ void WriteToBlock(EventPipeEventInstance &instance, unsigned int metadataId);
// The object responsible for serialization.
FastSerializer *m_pSerializer;
+ EventPipeBlock *m_pBlock;
+
// The system time when the file was opened.
SYSTEMTIME m_fileOpenSystemTime;
@@ -65,15 +82,22 @@ class EventPipeFile : public FastSerializableObject
// The frequency of the timestamps used for this file.
LARGE_INTEGER m_timeStampFrequency;
- // The forward reference index that marks the beginning of the event stream.
- unsigned int m_beginEventsForwardReferenceIndex;
+ unsigned int m_pointerSize;
+
+ unsigned int m_currentProcessId;
+
+ unsigned int m_numberOfProcessors;
+
+ unsigned int m_samplingRateInNs;
// The serialization which is responsible for making sure only a single event
// or block of events gets written to the file at once.
SpinLock m_serializationLock;
// Hashtable of metadata labels.
- MapSHashWithRemove<EventPipeEvent*, StreamLabel> *m_pMetadataLabels;
+ MapSHashWithRemove<EventPipeEvent*, unsigned int> *m_pMetadataIds;
+
+ Volatile<LONG> m_metadataIdCounter;
#ifdef _DEBUG
bool m_lockOnWrite;