beberlei,
@beberlei@phpc.social avatar

How can I achieve a 94% performance boost? In this particular case, by an optimization in the DOM extension. Thanks @nielsdos
Read more about this performance fix in my latest blog post.

https://tideways.com/profiler/blog/measuring-the-dom-namespace-reconciliation-performance-fix?utm_medium=social&utm_source=twitter&utm_campaign=measuring-the-dom-namespace-reconciliation-performance-fix

Crell,
@Crell@phpc.social avatar

@beberlei @nielsdos But what was the actual fix?

nielsdos,
@nielsdos@phpc.social avatar

@Crell @beberlei The important part was avoiding O(n) insertion of the namespace by adding it at the front of the "old namespace" list instead of the back. To be more specific, make sure it's added at the second position within the linked list, the actual front position wouldn't work due to API constraints of libxml (the first namespace must always be the XML namespace).
With the new DOM classes, all of this mess is avoided because we no longer need namespace reconciliation.

Crell,
@Crell@phpc.social avatar

@nielsdos @beberlei Ah, so the same class of issue as array_push() vs array_shift()? Avoid needing to reindex?

timwolla,
@timwolla@phpc.social avatar

@Crell @nielsdos @beberlei No. Looking at the code it's a single-linked list. To insert at the end you need to traverse it in full. Effectively:

$item = $listStart;
while ($item->next !== null) {
$item = $item->next;
}
assert($item->next === null);
$item->next = $newItem;

Reindexing is not a thing for linked lists, because they don't have an index.

timwolla,
@timwolla@phpc.social avatar

@Crell @nielsdos @beberlei With the fix roughly doing:

$item = $listStart;
$newItem->next = $item->next;
$item->next = $newItem;

avoiding the loop.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • ethstaker
  • InstantRegret
  • tacticalgear
  • rosin
  • love
  • Youngstown
  • slotface
  • ngwrru68w68
  • kavyap
  • cubers
  • thenastyranch
  • mdbf
  • megavids
  • cisconetworking
  • GTA5RPClips
  • modclub
  • khanakhh
  • everett
  • Leos
  • osvaldo12
  • normalnudes
  • tester
  • Durango
  • anitta
  • provamag3
  • JUstTest
  • All magazines