russellallen / self

Making the world safe for objects
http://selflanguage.org
707 stars 76 forks source link

Disappointing performance on a simple loop #128

Closed stacksmith closed 5 years ago

stacksmith commented 5 years ago

I am curious if I am doing something terribly wrong...

|  in. out |
in: (times cpu).
200000000 do: [ ].
out: (times cpu).
^ (out - in)

returns 1071 or so. That's 200 million iterations in a second on a 4.6GHz Skylake with gobs of ram. I do not mean to be an asshole - I just want to make sure something is not terribly wrong here. From everything I've read I was expecting not too-far-from-c performance - not 15 times slower without any polymorphic stuff... Thanks

doublec commented 5 years ago

I don't know the cause of your timings but I wrote some stuff on benchmarking in Self that might help you to track it down.

stacksmith commented 5 years ago

Thanks, I will take a look...

stacksmith commented 5 years ago

I suppose that's what the current compiler does. As a proof of concept that's great, but I suspect a clean threaded interpreter with PICs and whatnot can do as well or better, especially if the derivation hierarchy can be cleaned up.
Honestly, if you are going to compile anything in an environment like this, I strongly suspect compiling data - not code - will bring biggest performance gains. By which I mean leave the code interpreted, and spend equivalent effort instrumenting slots to isolate mutable slots that are polymorphic and flattening the rest so it's basically a single vtable-like dispatch. Recompile object and dependent objects when needed - perhaps just-in-time. But that's a whole different phd thesis.

russellallen commented 5 years ago

If you're interested in this, I'd recommend the mailing list. it's very low volume and has most of the people who have worked on Self over the years subscribed to it.

stacksmith commented 5 years ago

Thanks, I will sign up. Thank you for keeping it alive. I've been a fan since last century, and it's wonderful to actually see it in action.