Open Bug 2098740 Opened 1 day ago Updated 1 day ago

Map iteration is nearly 4x slower

Categories

(Core :: JavaScript Engine: JIT, defect)

defect

Tracking

()

People

(Reporter: jrmuizel, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Here's a microbenchmark:

function f(m){
  let s=0;
  for(let [k,v] of m){
    if (k.$$version!==v)
      s++;
  }
  return s;
}
let maps=[];
for(let i=0;i<1000;i++){
  let m=new Map();
  for(let j=0;j<(i%5)+1;j++){
    m.set({$$version:j},j)
  }
  maps.push(m)
}
let t=Date.now();let s=0;
for(let it=0;it<20000;it++){for(let i=0;i<maps.length;i++)s+=f(maps[i]);}
print(Date.now()-t, s);
sm: 2307 0
v8: 621 0
jsc: 585 0

This corresponds ctxDepsChanged from the octane framework:

function ctxDepsChanged(block) {
  const reads = block.$$ctxReads;
  if (reads === null) return false;
  for (const [ctx, version] of reads) {
    if (ctx.$$version !== version) return true;
  }
  return false;
}

Match V8 on this function improves this chat-stream-octane test by 7.6%

Blocks: speedometer4

There's a Foofrix patch in bug 2097960 that gets 2-5% on this subtest (depending on platform) by allocating Map/Set iterators in jitcode. It gets 1298 0 on my machine, compared to 2473 for unpatched SM, 593 for V8, and 757 for JSC.

Depends on: 2097960
You need to log in before you can comment on or make changes to this bug.