Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/ready_queue.cfa

    r8cd5434 r69914cbc  
    398398
    399399                if(proc->rdq.target == -1u) {
    400                         unsigned long long min = ts(lanes.data[proc->rdq.id]);
    401                         for(int i = 0; i < READYQ_SHARD_FACTOR; i++) {
    402                                 unsigned long long tsc = ts(lanes.data[proc->rdq.id + i]);
    403                                 if(tsc < min) min = tsc;
    404                         }
    405                         proc->rdq.cutoff = min;
     400                        _Static_assert(READYQ_SHARD_FACTOR == 2);
     401                        unsigned idx1 = proc->rdq.id + 0;
     402                        unsigned idx2 = proc->rdq.id + 1;
     403                        unsigned long long tsc1 = ts(lanes.data[idx1]);
     404                        unsigned long long tsc2 = ts(lanes.data[idx2]);
    406405                        proc->rdq.target = __tls_rand() % lanes.count;
     406
     407                        // WARNING: std::min is polymorphic and therefore causes 500% slowdown instead of the expected 2%
     408                        proc->rdq.cutoff = tsc1 < tsc2 ? tsc1 : tsc2;
    407409                }
    408410                else {
     
    552554}
    553555
    554 static void assign_list(unsigned & value, dlist(processor, processor) & list, unsigned count) {
     556static void assign_list(unsigned & value, dlist(processor) & list, unsigned count) {
    555557        processor * it = &list`first;
    556558        for(unsigned i = 0; i < count; i++) {
     
    702704        /* paranoid */ verify( ready_mutate_islocked() );
    703705}
    704 
    705 #if !defined(__CFA_NO_STATISTICS__)
    706         unsigned cnt(const __ready_queue_t & this, unsigned idx) {
    707                 /* paranoid */ verify(this.lanes.count > idx);
    708                 return this.lanes.data[idx].cnt;
    709         }
    710 #endif
Note: See TracChangeset for help on using the changeset viewer.