diff options
| author | Richard Brooksby | 2012-08-31 15:37:29 +0100 |
|---|---|---|
| committer | Richard Brooksby | 2012-08-31 15:37:29 +0100 |
| commit | bf36f61bb4e9d2d942abde9d12525a0610033f13 (patch) | |
| tree | 067ceddca71f3db735a49da61667b55e14350d3f /mps/code | |
| parent | 455e3ee43cb87db88f14e4093f2bf4f80c30134d (diff) | |
| download | emacs-bf36f61bb4e9d2d942abde9d12525a0610033f13.tar.gz emacs-bf36f61bb4e9d2d942abde9d12525a0610033f13.zip | |
Avoid creating the telemetry output stream until there are events to log.
Copied from Perforce
Change: 179134
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/event.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/mps/code/event.c b/mps/code/event.c index 29c38febcd0..7657e71cc37 100644 --- a/mps/code/event.c +++ b/mps/code/event.c | |||
| @@ -32,6 +32,7 @@ SRCID(event, "$Id$"); | |||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | static Bool eventInited = FALSE; | 34 | static Bool eventInited = FALSE; |
| 35 | static Bool eventIOInited = FALSE; | ||
| 35 | static mps_io_t eventIO; | 36 | static mps_io_t eventIO; |
| 36 | static Count eventUserCount; | 37 | static Count eventUserCount; |
| 37 | static Serial EventInternSerial; | 38 | static Serial EventInternSerial; |
| @@ -54,6 +55,19 @@ Res EventFlush(void) | |||
| 54 | AVER(EventLast <= EventBuffer + EventBufferSIZE); | 55 | AVER(EventLast <= EventBuffer + EventBufferSIZE); |
| 55 | size = (size_t)(EventBuffer + EventBufferSIZE - EventLast); | 56 | size = (size_t)(EventBuffer + EventBufferSIZE - EventLast); |
| 56 | 57 | ||
| 58 | /* Checking the size avoids creating the event stream when the arena is | ||
| 59 | destroyed and no events have been logged. */ | ||
| 60 | if (size == 0) | ||
| 61 | return ResOK; | ||
| 62 | |||
| 63 | /* Ensure the IO stream is open. We do this late so that no stream is | ||
| 64 | created if no events are enabled by telemetry control. */ | ||
| 65 | if (!eventIOInited) { | ||
| 66 | res = (Res)mps_io_create(&eventIO); | ||
| 67 | if(res != ResOK) return res; | ||
| 68 | eventIOInited = TRUE; | ||
| 69 | } | ||
| 70 | |||
| 57 | /* Writing might be faster if the size is aligned to a multiple of the | 71 | /* Writing might be faster if the size is aligned to a multiple of the |
| 58 | C library or kernel's buffer size. We could pad out the buffer with | 72 | C library or kernel's buffer size. We could pad out the buffer with |
| 59 | a marker for this purpose. */ | 73 | a marker for this purpose. */ |
| @@ -84,8 +98,6 @@ Res EventSync(void) | |||
| 84 | 98 | ||
| 85 | Res EventInit(void) | 99 | Res EventInit(void) |
| 86 | { | 100 | { |
| 87 | Res res; | ||
| 88 | |||
| 89 | /* Make local enums for all event params in order to check that the indexes | 101 | /* Make local enums for all event params in order to check that the indexes |
| 90 | in the parameter definition macros are in order, and that parameter | 102 | in the parameter definition macros are in order, and that parameter |
| 91 | idents are unique. */ | 103 | idents are unique. */ |
| @@ -141,8 +153,6 @@ Res EventInit(void) | |||
| 141 | /* Only if this is the first call. */ | 153 | /* Only if this is the first call. */ |
| 142 | if(!eventInited) { /* See .trans.log */ | 154 | if(!eventInited) { /* See .trans.log */ |
| 143 | AVER(EventLast == NULL); | 155 | AVER(EventLast == NULL); |
| 144 | res = (Res)mps_io_create(&eventIO); | ||
| 145 | if(res != ResOK) return res; | ||
| 146 | EventLast = EventBuffer + EventBufferSIZE; | 156 | EventLast = EventBuffer + EventBufferSIZE; |
| 147 | eventUserCount = (Count)1; | 157 | eventUserCount = (Count)1; |
| 148 | eventInited = TRUE; | 158 | eventInited = TRUE; |