File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,8 @@ void SliceSnapshot::IterateBucketsFb(bool send_full_sync_cut) {
154
154
stats_.keys_total += db_slice_->DbSize (db_indx);
155
155
}
156
156
157
+ const uint64_t kCyclesPerYield = base::CycleClock::Frequency () >> 16 ; // ~15usec.
158
+
157
159
for (DbIndex db_indx = 0 ; db_indx < db_array_.size (); ++db_indx) {
158
160
if (!cntx_->IsRunning ())
159
161
return ;
@@ -164,6 +166,7 @@ void SliceSnapshot::IterateBucketsFb(bool send_full_sync_cut) {
164
166
PrimeTable* pt = &db_array_[db_indx]->prime ;
165
167
VLOG (1 ) << " Start traversing " << pt->size () << " items for index " << db_indx;
166
168
169
+ uint64_t start_cycles = base::CycleClock::Now ();
167
170
do {
168
171
if (!cntx_->IsRunning ()) {
169
172
return ;
@@ -172,7 +175,11 @@ void SliceSnapshot::IterateBucketsFb(bool send_full_sync_cut) {
172
175
PrimeTable::Cursor next = pt->TraverseBuckets (
173
176
cursor, [this , &db_indx](auto it) { return BucketSaveCb (db_indx, it); });
174
177
cursor = next;
175
- ThisFiber::Yield ();
178
+ uint64_t now = base::CycleClock::Now ();
179
+ if (now > start_cycles + kCyclesPerYield ) {
180
+ ThisFiber::Yield ();
181
+ start_cycles = base::CycleClock::Now ();
182
+ }
176
183
177
184
PushSerialized (false );
178
185
} while (cursor);
You can’t perform that action at this time.
0 commit comments