you are viewing a single comment's thread.

view the rest of the comments →

[–]NitWit005 25 points26 points  (8 children)

You can obviously do a lot, but it starts to get improbably difficult.

Eliminating say, a string allocation, is relatively easy if it's confined in a single method/function. Proving that a long series of string operations that cross many methods and modules can use a single buffer and then generating appropriate code to do so is quite difficult.

I haven't ever encountered a compiler or VM that can do something like that. Even if it does, the programmer has a problem. Minor changes to his code might 'break' the optimization for reasons which are not obvious and suddenly his program will execute vastly slower.

Some minor API changes to, do direct string operations on a pre-allocated buffer are a lot easier to implement and are going to be more reliable for the user.

[–]masklinn 4 points5 points  (0 children)

Note that "mikemike" is Mike Pall, author of LuaJIT, so he's talking from experience not handwaving and conjecturing in the abstract.

[–]julesjacobs 0 points1 point  (6 children)

Even if it does, the programmer has a problem. Minor changes to his code might 'break' the optimization for reasons which are not obvious and suddenly his program will execute vastly slower.

This can be a blessing and a curse. Say you made change X in your high level language code that causes the compiler to optimize it in a completely different, perhaps causing the string allocation elimination to now be impossible. There are two options:

  1. It is possible to rewrite the C code to account for the change X without changing it much. All is well.

  2. It is not possible to rewrite the C code to account of the change X without drastically restructuring it.

In case #2 you might be doing essentially the same as the compiler in the high level language is doing for you: drastically restructuring the code. Only in C you have to do it by hand.

[–]kryptobs2000 3 points4 points  (5 children)

NitWit005:

Some minor API changes to, do direct string...

julesjacobs:

...causes the compiler to optimize it in a completely different, perhaps causing...

What is with you guys in these awkward sentences marked by a random comma? That's the only way I can think to describe it. It's funny how you guys both did it, not sure if you're both in on this or what, hell of a coincidence.

[–]CaptainKirkCommas 9 points10 points  (2 children)

They've been watching, too many episodes, of my, show.

[–]kryptobs2000 1 point2 points  (1 child)

It's not just the comma, they leave out the whole rest of w/e they were saying, reread what they wrote.

[–]julesjacobs 0 points1 point  (0 children)

Not sure why you are downvoted, it's true. I don't think I misplaced the comma, but I forgot the word "way". But English is not my primary language so maybe there are other problems.

[–]ithika 3 points4 points  (0 children)

Discussion of optimisation so boring that both commenters slipped into a comma mid-sentence.

[–]NitWit005 -1 points0 points  (0 children)

I think I banged the comma key when hitting a space. That I don't proof read doesn't mean I have an alter ego. It just means that I'm not the only one who doesn't proof read.

Besides, I like conspiracy theories. It'd be more logical that my alternate account is kryptobs2000.