|
I could, and indeed I do one small optimization with my Reflect Emit based compiler that isn't possible - at least readily in C#.
if((codepoint>='A' && codepoint<='Z') || codepoint=='_' || (codepoint>='a' && codepoint<='a')
The comparison ranges are in sorted order left to right. So rather than run through all of the || conditions, I short circuit if the minimum of the next range in the series is greater than the codepoint. It's easy to do in IL since all of this is already resolved to a series of jumps. Not so easy in C#.
But I did it there because it was a minor change, and didn't really impact anything. I'd be far more hesitant to create a total fork in my compiler vs. source generator. The performance benefits would have to be compelling.
Fortunately, I didn't need to do that here, because my fears were not realized in the end. The JITter was smart enough to optimize that code. But if it wasn't, I could have reorganized my generated source code to produce more efficient IL, in that it would translate to more efficient native code on most platforms.
I'd have preferred that approach as it keeps things from being black boxed.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
jschell wrote: The C compiler could be configured to emit assembler. I did that, optimized it, then I used that instead of the original C code in the build. Did you do much timing to verify the speed gain at the user level? (E.g. from the moment the user supplies some input up to the next request for input from the user. For some applications, you must use other criteria, such as the time from startup to the first screenful has been drawn.)
There are certainly compilers out there that are build by people not very experienced or knowledgeable about compiler optimization. On the other hand, I guess that the true experts keep some tricks up their sleeves. But I'd guess that 98% of all optimizing tricks that have a measurable effect has been documented in publicly available sources. If the compiler writer reads the proper sources and do what they tell him to, there is so little left for "even better" hand optimizing that it certainly isn't worth the effort.
Usually, the compiler knows a lot more than you do about the instruction set, cache, virtual memory etc. It has a lot more background for making the ideal code than you. If you change its proposed code, you will often just be doing it in a different way, but not measurably faster. In the worst case, your 'optimization' may even slow down the code. In the very best case, you may be able to prove a nanosecond or two faster execution - but you need a bag of tricks (not all of them very clean) to 'prove' a speedup at user level.
I have experience with all three of these alternatives. Back in history, you might get a real speedup. First, because on old CPUs the total execution time could be calculated by adding together the cycle counts for every instruction executed. Second, The Book of Well Known Standard Optimizing Tricks was a lot thinner then. The closer we get to the CPUs of today, with a long list of hardware speedup techniques (all sorts of prefetch and lookahead, caches, execution pipelines, speculative execution, ...), the more blurry the 'Add together the timing of all instructions executed' becomes. And The Book is quite thick.
Implement the tricks in the book, and there is not much left to do. But that implementation is the responsibility of the compiler writer.
If you must dig up a really bad compiler written by someone who has never hear of optimization, in order to prove that you can do hand optimizing that has some effect, then you should rather find a better compiler.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
trønderen wrote: Did you do much timing to verify the speed gain at the user level
Not sure why I did it in the case I remember. Doubt it was speed based though.
trønderen wrote: Back in history, you might get a real speedup.
One I can recall specifically would have been in the 80s.
|
|
|
|
|
Lo and behold, todays newsletter has an article about extracting the assembly that the jit compiler generates, if that's any use ; here[^] if you haven't already seen it.
|
|
|
|
|
Super! Yeah I saw that, but after you posted. Thanks!
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Alister Morton wrote: has an article about extracting the assembly that the jit compiler generates,
Which obviously proves that aliens, spirits and bigfoot all exist.
(And you beat me to posting about that.)
|
|
|
|
|
|
Someone had to do it first. Dave was that guy.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
IMHO
Time is the most objective thing we have. It doesn't give a crap on your origin, race, social status, money, color of the skin, religion, political believes, ideology... whatever.
It it the same for all, it has the same value for all and everyone of us will regret to have wasted it with less important crap in one way or another...
EDIT: after 3 answers...
One tries to say something "nice" or "deep" and you take it apart with logic...
Seriously people... WT ?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
modified 20-Jan-24 16:03pm.
|
|
|
|
|
Except that subjectively, time is very different for all of us, at various 'times' of our lives. If you are waiting for something important, time can seem to go very slowly. When I was a child, time seemed to run very slow. Now the years just fly by... Looking back, the difference seems stark.
|
|
|
|
|
That's the perception of it in your brain. That's a different story.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I suspect you would view that differently while waiting for the results of significant medical operation on a child.
|
|
|
|
|
Why? on the clock the time would be the same for everyone. The perception of it while waiting for the results would be bigger / slower for me, yeah, I give you that, but still the perception of it, not the time itself.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Time is the most objective thing we have.
Not since Einstein's Theory of Relativity was published. Every frame of reference has a different time, and these times cannot, in general, be synchronised (Only frameworks stationary relative to each other can be synchronised.).
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Nitpicky...
On the other hand... time might be different long in case of the relativity, but the effect to people will still be the same under their own perspective / reality / timeframe / however it is called. So what I told before continue applying, only under a different "speed"
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
It may be objective, but it's not the same for everyone. General Relativity says otherwise. GR is correct, because if it weren't GPS and other satellite navigation systems wouldn't work.
|
|
|
|
|
I didn't say it is the same (phisically). I only said that it doesn't care about anything regarding us while doing its job, that it has the same value for all and that most will end regreting having wasted it.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Well, I mean... space doesn't care either. :shrug:
|
|
|
|
|
True.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Wordle 945 4/6*
🟨⬛⬛⬛🟩
⬛⬛🟨🟨🟩
🟨🟩⬛⬛🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 945 5/6
⬛⬛⬛⬛⬛
⬛🟨🟨⬛🟩
⬛🟩🟩🟩🟩
⬛🟩🟩🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
⬜🟨🟨⬜🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 945 4/6
🟨⬜⬜🟨⬜
⬜⬜🟨🟨⬜
🟩🟨🟨🟨⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 945 3/6*
🟨🟨⬜⬜🟩
⬜🟨🟨🟨🟩
🟩🟩🟩🟩🟩
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 945 2/6
🟨🟨⬛⬛🟩
🟩🟩🟩🟩🟩
Lucky second guess!
Ok, I have had my coffee, so you can all come out now!
|
|
|
|