Changeset f55d54d for libcfa/src


Ignore:
Timestamp:
May 5, 2021, 12:58:55 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f302d80
Parents:
d653faf
Message:

Removed call to polymorphic 'min' which caused MASSIVE slowdown.

File:
1 edited

Legend:

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

    rd653faf rf55d54d  
    398398
    399399                if(proc->rdq.target == -1u) {
    400                         proc->rdq.target = __tls_rand() % lanes.count;
    401                         unsigned it1  = proc->rdq.itr;
    402                         unsigned it2  = proc->rdq.itr + 1;
    403                         unsigned idx1 = proc->rdq.id + (it1 % READYQ_SHARD_FACTOR);
    404                         unsigned idx2 = proc->rdq.id + (it2 % READYQ_SHARD_FACTOR);
     400                        _Static_assert(READYQ_SHARD_FACTOR == 2);
     401                        unsigned idx1 = proc->rdq.id + 0;
     402                        unsigned idx2 = proc->rdq.id + 1;
    405403                        unsigned long long tsc1 = ts(lanes.data[idx1]);
    406404                        unsigned long long tsc2 = ts(lanes.data[idx2]);
    407                         proc->rdq.cutoff = min(tsc1, tsc2);
    408                         if(proc->rdq.cutoff == 0) proc->rdq.cutoff = -1ull;
     405                        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;
    409409                }
    410410                else {
     
    418418
    419419                for(READYQ_SHARD_FACTOR) {
    420                         unsigned i = proc->rdq.id + (--proc->rdq.itr % READYQ_SHARD_FACTOR);
     420                        unsigned i = proc->rdq.id + (proc->rdq.itr++ % READYQ_SHARD_FACTOR);
    421421                        if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t;
    422422                }
Note: See TracChangeset for help on using the changeset viewer.