Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Brendan Eich’s performance optimization of the properties pattern?

At the end of Steve Yegge’s essay on the prototype pattern, he says,

Brendan Eich came up with astoundingly clever performance optimization for the Properties Pattern, which he told me about back in January. I was ready to publish this article, but I told him I'd hold off until he blogged about his optimization. Every once in a while he'd ping me and tell me "any day now."

Brendan, it's October, dammit!

That note was written almost five years ago, but I can’t seem to find any information on what Eich’s optimization was. Did he or anyone else ever publish the improvement Yegge mentioned?

like image 477
bdesham Avatar asked Aug 12 '13 13:08

bdesham


2 Answers

I went digging, starting from Brendan's tweet referred to in the other answer, and ended up at this blog post from '08. To summarize:

A lot of the benchmarks show that SpiderMonkey is significantly faster than Tamarin. This has been mostly attributed to the way SpiderMonkey accesses object properties. SpiderMonkey has an implementation of the shape idea. A shape is a unique identifier which details the structure of an object, and allows for a quick lookup of a given property. With a few bit operations, given an object's shape and the current program location, we can find a property's address.

Check the blog post for more details and references to the actual code from that time.

like image 141
Vicky Chijwani Avatar answered Nov 12 '22 16:11

Vicky Chijwani


Via Twitter, Brendan said,

it's in SpiderMonkey, kinda known. Property trees => shapes, similar to hidden classes but with more sharing.

So make of that what you will.

like image 25
bdesham Avatar answered Nov 12 '22 16:11

bdesham