Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/circular-queue.cc

Issue 12592002: Revert "Send SIGPROF signals on the profiler event processor thread" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/circular-queue.h ('k') | src/cpu-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "circular-queue-inl.h" 30 #include "circular-queue-inl.h"
31 31
32 namespace v8 { 32 namespace v8 {
33 namespace internal { 33 namespace internal {
34 34
35 35
36 SamplingCircularQueue::SamplingCircularQueue( 36 SamplingCircularQueue::SamplingCircularQueue(int record_size_in_bytes,
37 int record_size_in_bytes, 37 int desired_chunk_size_in_bytes,
38 int desired_chunk_size_in_bytes, 38 int buffer_size_in_chunks)
39 int buffer_size_in_chunks,
40 bool keep_producer_consumer_distance)
41 : record_size_(record_size_in_bytes / sizeof(Cell)), 39 : record_size_(record_size_in_bytes / sizeof(Cell)),
42 chunk_size_in_bytes_(desired_chunk_size_in_bytes / record_size_in_bytes * 40 chunk_size_in_bytes_(desired_chunk_size_in_bytes / record_size_in_bytes *
43 record_size_in_bytes), 41 record_size_in_bytes),
44 chunk_size_(chunk_size_in_bytes_ / sizeof(Cell)), 42 chunk_size_(chunk_size_in_bytes_ / sizeof(Cell)),
45 buffer_size_(chunk_size_ * buffer_size_in_chunks), 43 buffer_size_(chunk_size_ * buffer_size_in_chunks),
44 // The distance ensures that producer and consumer never step on
45 // each other's chunks and helps eviction of produced data from
46 // the CPU cache (having that chunk size is bigger than the cache.)
47 producer_consumer_distance_(2 * chunk_size_),
46 buffer_(NewArray<Cell>(buffer_size_ + 1)) { 48 buffer_(NewArray<Cell>(buffer_size_ + 1)) {
47 ASSERT(buffer_size_in_chunks > 2); 49 ASSERT(buffer_size_in_chunks > 2);
48 // Clean up the whole buffer to avoid encountering a random kEnd 50 // Clean up the whole buffer to avoid encountering a random kEnd
49 // while enqueuing. 51 // while enqueuing.
50 for (int i = 0; i < buffer_size_; ++i) { 52 for (int i = 0; i < buffer_size_; ++i) {
51 buffer_[i] = kClear; 53 buffer_[i] = kClear;
52 } 54 }
53 buffer_[buffer_size_] = kEnd; 55 buffer_[buffer_size_] = kEnd;
54 56
55 // Layout producer and consumer position pointers each on their own 57 // Layout producer and consumer position pointers each on their own
56 // cache lines to avoid cache lines thrashing due to simultaneous 58 // cache lines to avoid cache lines thrashing due to simultaneous
57 // updates of positions by different processor cores. 59 // updates of positions by different processor cores.
58 const int positions_size = 60 const int positions_size =
59 RoundUp(1, kProcessorCacheLineSize) + 61 RoundUp(1, kProcessorCacheLineSize) +
60 RoundUp(static_cast<int>(sizeof(ProducerPosition)), 62 RoundUp(static_cast<int>(sizeof(ProducerPosition)),
61 kProcessorCacheLineSize) + 63 kProcessorCacheLineSize) +
62 RoundUp(static_cast<int>(sizeof(ConsumerPosition)), 64 RoundUp(static_cast<int>(sizeof(ConsumerPosition)),
63 kProcessorCacheLineSize); 65 kProcessorCacheLineSize);
64 positions_ = NewArray<byte>(positions_size); 66 positions_ = NewArray<byte>(positions_size);
65 67
66 producer_pos_ = reinterpret_cast<ProducerPosition*>( 68 producer_pos_ = reinterpret_cast<ProducerPosition*>(
67 RoundUp(positions_, kProcessorCacheLineSize)); 69 RoundUp(positions_, kProcessorCacheLineSize));
68 producer_pos_->enqueue_pos = buffer_; 70 producer_pos_->enqueue_pos = buffer_;
69 71
70 consumer_pos_ = reinterpret_cast<ConsumerPosition*>( 72 consumer_pos_ = reinterpret_cast<ConsumerPosition*>(
71 reinterpret_cast<byte*>(producer_pos_) + kProcessorCacheLineSize); 73 reinterpret_cast<byte*>(producer_pos_) + kProcessorCacheLineSize);
72 ASSERT(reinterpret_cast<byte*>(consumer_pos_ + 1) <= 74 ASSERT(reinterpret_cast<byte*>(consumer_pos_ + 1) <=
73 positions_ + positions_size); 75 positions_ + positions_size);
74 consumer_pos_->dequeue_chunk_pos = buffer_; 76 consumer_pos_->dequeue_chunk_pos = buffer_;
75 consumer_pos_->dequeue_chunk_poll_pos = buffer_; 77 consumer_pos_->dequeue_chunk_poll_pos = buffer_ + producer_consumer_distance_;
76 // The distance ensures that producer and consumer never step on
77 // each other's chunks and helps eviction of produced data from
78 // the CPU cache (having that chunk size is bigger than the cache.)
79 if (keep_producer_consumer_distance) {
80 consumer_pos_->dequeue_chunk_poll_pos += 2 * chunk_size_;
81 }
82 consumer_pos_->dequeue_pos = NULL; 78 consumer_pos_->dequeue_pos = NULL;
83 } 79 }
84 80
85 81
86 SamplingCircularQueue::~SamplingCircularQueue() { 82 SamplingCircularQueue::~SamplingCircularQueue() {
87 DeleteArray(positions_); 83 DeleteArray(positions_);
88 DeleteArray(buffer_); 84 DeleteArray(buffer_);
89 } 85 }
90 86
91 87
(...skipping 25 matching lines...) Expand all
117 } 113 }
118 114
119 115
120 void SamplingCircularQueue::FlushResidualRecords() { 116 void SamplingCircularQueue::FlushResidualRecords() {
121 // Eliminate producer / consumer distance. 117 // Eliminate producer / consumer distance.
122 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos; 118 consumer_pos_->dequeue_chunk_poll_pos = consumer_pos_->dequeue_chunk_pos;
123 } 119 }
124 120
125 121
126 } } // namespace v8::internal 122 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/circular-queue.h ('k') | src/cpu-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698