January 12, 2024
std::vector<std::string> list; // populate my list with strings, suppose this is in a loop std::string s = ...; list.push_back(s);then later on decide to pass this list to a function:
void dosomething(std::vector<std::string> list) { // does something }
...but nobody will tell them that each call of dosomething() will execute a std::string copy constructor for each item in the list, allocating (and subsequently freeing) memory for each string. There are just so many ways to get bitten here. Yes, I know, make list 'const &' etc, but it's very easy not to know that (or somewhat less easy but still possible to forget), and multiply this by 1,000 times (I know one person who was sufficiently burned by pre-increment vs post-increment having massive performance implications that they always use pre-increment in for loops, even if it's a basic type -- not that there's anything wrong with that, I guess post-increment is an odd thing to see as normal anyway)..
And we wonder why modern software generally sucks?
Recordings:
Yes, Exactly, Yes! - 1 - Sandwich Terrier (I) -- [4:47]
Yes, Exactly, Yes! - 2 - Sandwich Terrier (II) -- [3:45]
Yes, Exactly, Yes! - 3 - Sandwich Terrier (III) -- [3:38]
Yes, Exactly, Yes! - 4 - Virgins Again (Bad at Math) -- [3:27]
Yes, Exactly, Yes! - 5 - Prelude to the River -- [7:47]
Yes, Exactly, Yes! - 6 - The River -- [4:36]
Yes, Exactly, Yes! - 7 - Vertical Integration (I) -- [5:51]
Yes, Exactly, Yes! - 8 - Vertical Integration (II) -- [5:07]
Yes, Exactly, Yes! - 9 - May 29 Track 6 -- [6:34]
Yes, Exactly, Yes! - 10 - Las Vegas -- [3:57]
Yes, Exactly, Yes! - 11 - Terms of Service -- [5:32]
Yes, Exactly, Yes! - 12 - Hindenburg -- [8:19]
Yes, Exactly, Yes! - 13 - Chosen by the Few -- [5:20]
Yes, Exactly, Yes! - 14 - Self Imposed (I) -- [7:40]
Yes, Exactly, Yes! - 15 - Self Imposed (II, slower) -- [7:23]
5 Comments
extern int gv, bar(); template<class T> class saver { public: T save, *ptr; saver(T *p) : ptr(p) { save = *p; } ~saver() { *ptr = save; } }; void foo_c() { int save = gv; gv = 1; bar(); gv = save; } void foo_cxx() { saver<int> s(&gv); gv = 1; bar(); }When compiled with -O2 -fomit-frame-pointer -fno-exceptions, would foo_c() and foo_cxx() differ meaningfully? Output (x86-64 gcc 4.7.4, newer gcc versions are all similar):
foo_c(): push rbx mov ebx, DWORD PTR gv[rip] mov DWORD PTR gv[rip], 1 call bar() mov DWORD PTR gv[rip], ebx pop rbx ret foo_cxx(): push rbx mov ebx, DWORD PTR gv[rip] mov DWORD PTR gv[rip], 1 call bar() mov DWORD PTR gv[rip], ebx pop rbx ret
So yeah, the optimizer does perfectly.
Recordings:
Yes, Exactly, Yes! - 1 -- [8:53]
Yes, Exactly, Yes! - 2 - Private Life -- [7:20]
Yes, Exactly, Yes! - 3 - Watch Your Step -- [2:46]
Yes, Exactly, Yes! - 4 - Watch Your Step (II) -- [2:05]
Yes, Exactly, Yes! - 5 - Self Imposed -- [4:39]
Yes, Exactly, Yes! - 6 - Dogs Will Rule the World -- [3:04]
Yes, Exactly, Yes! - 7 - Virgins Again -- [2:53]
Yes, Exactly, Yes! - 8 - Virgins Again (Again) -- [3:14]
Yes, Exactly, Yes! - 9 - The River -- [4:31]
Yes, Exactly, Yes! - 10 - Cosmic Background -- [3:32]
Yes, Exactly, Yes! - 11 -- [5:20]
Yes, Exactly, Yes! - 12 - Hindenburg -- [6:42]
Yes, Exactly, Yes! - 13 - Chosen by the Few -- [3:48]
Yes, Exactly, Yes! - 14 - Las Vegas -- [4:04]
Yes, Exactly, Yes! - 15 - No Big Benefactor -- [4:06]
Yes, Exactly, Yes! - 16 - Now We Understand -- [4:14]
Yes, Exactly, Yes! - 17 - Cast Iron Candy Bandit -- [3:10]
Yes, Exactly, Yes! - 18 - Dogs Will Rule the World (reprise) -- [3:37]
Yes, Exactly, Yes! - 19 - Find Me -- [5:01]
Yes, Exactly, Yes! - 20 - Old as Coal -- [4:33]
Yes, Exactly, Yes! - 21 -- [11:36]
Yes, Exactly, Yes! - 22 - Charlie (feat Cory Choy) -- [4:35]
Comment...
In one of our REAPER development branches (and thus the latest +dev builds), there's now support for generating EEL2 code on the fly (for EEL reascripts, JSFX, video processors), using EEL2. I find this immensely pleasing.
To use this functionality, you can create an embedded script, using <? script code ?>, and that script has a separate variable/memory space, and can generate code using printf().
EEL2 often requires a lot of repetitive code to produce fast DSP code.
So for example, our loudness meter has a sinc filter that gets coefficients generated. Here's a before and after:
function sinc_gen_slice(cs, o*) instance(sinc_gen_val slice_pos) global() ( slice_pos = cs; - o.v00 = sinc_gen_val(); o.v01 = sinc_gen_val(); o.v02 = sinc_gen_val(); o.v03 = sinc_gen_val(); - o.v04 = sinc_gen_val(); o.v05 = sinc_gen_val(); o.v06 = sinc_gen_val(); o.v07 = sinc_gen_val(); - o.v08 = sinc_gen_val(); o.v09 = sinc_gen_val(); o.v10 = sinc_gen_val(); o.v11 = sinc_gen_val(); - o.v12 = sinc_gen_val(); o.v13 = sinc_gen_val(); o.v14 = sinc_gen_val(); o.v15 = sinc_gen_val(); + <? loop(x=0;sinc_sz, printf("o.v%02d = sinc_gen_val();%s",x,(x&3)==3?"\n": " "); x += 1) ?> );
There's some extra logic in there to produce identical output (including newlines) which isn't necessary, but added so I could test the output to make sure it didn't differ. The nice thing is, not only is this more readable and smaller, if you want to increase the filter size, you can without a ton of tedious and error-prone copy/paste.
Update, other tricks. If you want to make this code optional, you can do:
/* <? printf("%s/","*"); printf("code which will only be executed on new jsfx/etc"); printf("/%s","*"); ?> */and if you want either/or (new code vs legacy), you can do:
/* <? printf("%s/","*"); _suppress=1; printf("code which will only be executed on new jsfx"); printf("/%s","*"); ?> */ legacy code which will only be executed on old jsfx /* <? _suppress=0; ?> */(Forgot to mention earlier, you can set _suppress to have the preprocessor not output regular text)
I flew into LAX on the Thursday. Decided to walk from the terminal to the rental car place. It's about a mile and a half, which if you've packed light is infinitely preferable to walk, especially in 55 degree weather, than to pile onto a rental car bus. Especially these days. I rented a car (brand new Kia sedan ftw), wandered my way around, got some lunch using a gift card I purchased in early 2020, mmm french toast, went for an easy run in Griffith Park to waste some time, it was really tough to not go more than a few miles. Checked into the guest house airbnb, went to bed at 7pm or so.
Friday involved going to Tacos Delta for chilaquiles. I'll leave this here. Kept to myself, worked a bit, went to bed around 7pm again.
Got up at 2:30am, left the airbnb at a little before 4am. Drove the long way to Malibu. Got to see places I occasionally went as a kid. Met Steve and Edward (and their friend Alex) at the start around 5:15am. There are other pictures with less fantastic lighting but really why when you have this one?
Something like 80 people, I guess? We start at 6am.
I should point out that the organizers mention that the course is well marked, but there is one turn that it's very important that the 50-mile runners make (there's also a 50k starting an hour later), and if you don't make the turn you'll end up running a bit over 50k. Why did I mention this?
The first few miles are a singletrack climb, which means the start position is very important. We held back, letting the faster people go ahead. Maybe we let too many. A little running, but a lot of fast hiking. Which was good, the last thing I wanted to do is go out too fast. I never know how these things will go, I mean usually it's fine but things will hurt and there will be suffering so better try to minimize it. And I'm on a low-mileage year. Anyway.
It starts getting light on the climb, 6:19am. Steve wants to go faster, runs a little bit of the climb, I somewhat keep up (catching up on the level bits or when he stops to take pictures).
It levels out a bit, there's some running, 6:40am. The aid station will come in another 20 minutes or so.
After the aid station (which was about 5 miles), some oranges, watermelon, water fillup, maybe some other snacks I forget now, we start a 6 mile loop with a little mud. Steve's in front of me here, at about 7:20am.
Ah the views, 7:28am.
The view ahead from the last shot, I love those shots of the trail ahead (or behind -- and more accurately the experience of seeing them in real life -- at home there's nothing more satisfying than seeing the Brooklyn Bridge ahead of you a mile away, and 1 WTC in the distance behind it, then finding yourself there by your feet). I'll try to point the trail shots out, if we can see with these low quality images I uploaded.
This one I could've left out, but hey 5 minutes passed and I can still see the ocean.
We head inland and it gets really muddy, I'm told this is due to rain. Tons of mud stick to your shoes, you end up tweaking your gait in order to try to shake it off as you go. Activating strange muscles. It gets a bit warm. Only a little bit. 7:49am. Another 10-15 minutes and you're back at the same aid station as before.
I left the aid station before Steve. As a result I was in front of him. There was a climb. I was not faster.
Oxnard, in the background, I assume! Our friend Fritz was always obsessed with that name. I meant to text him about that but didn't have much cell service. 8:26am.
After that climb, there was a pretty amazing descent, which I had a lot of fun on. Steve seemed to be on a phone call while he was running so I thought I'd give him his space. Near the bottom of the descent was the Valley of the Spiders[tm][cc](Andy). The spiders were considerate in marking their territory and I didn't feel threatened. 8:50am.
Just down the road a 100' from the spider web, it got really cold, this valley trapped that cold air, and the with the humidity there were these clouds forming. It was cool but didn't photograph well, just looks like dust here.
A short 10 minutes later, you pay the price of that descent, with a pretty steep fire road climb. I walked this (I walked all of the climbing really). As I was hiking up this, the leader for the 50k race ran past me. RAN. That did not look easy to do for a 10k let alone a 50k. At the top of that hill was the same aid station again (16 miles, 9:05am or so). Where I filled my water, ate some more, and left as soon as possible. Then about 100' down the road I stopped to clean out the mud from my sock which was messing with my big toe. Oh such stupid timing...
After that there was some nice downhill, then I ended up in a valley which was very warm and humid. This was probably as hot as I was all day, and it was at 9:30am.
On the climb out of the riverbed valley, it got cooler, but my hip was doing something funny, popping with each step that I walked (didn't have the issue running). I stopped to stretch a little, which didn't help, then found that I could adjust my gait slightly in order to avoid the popping. The popping didn't hurt but it also didn't seem like a good thing. The climb was nice, here's the view after crossing a gravel path that people were bicycling on (you can see them barely). It looked like a really nice place to ride. I do get jealous of California this time of year. 10:00am or so, 20 miles in.
I had a 10 minute stop at a NEW aid station, at 10:35-10:45 or so. At this point in addition to the eating and getting water (and watered down coke), I took my socks off, put some ointment and bandaids on my toes, which had been giving me problems (somewhat due to my mismanagement of them 4 weeks before at the NY marathon, another story which will not get documented). I also snugged my shoes slightly to try to keep some of the pressure off my toes (this ended up being an oops that I'm still paying for). Anyway 10-15 minutes after that aid station is this picture, mountains pretty. I like them. I start to climb them.
I go up what I thought was a really big hill (Strava tells me it was about 750'. OK not that big). At the top is this left turn. The one they mentioned at the start. It's a little tempting to just miss the turn and do a 50k. 11:15am, about 26 miles. I take the turn.
Side note: the course was very well marked, especially compared to the races in NJ I've done, but this is sort of the exception. They really should have a sign that says "50 mile runners: if you're not at mile 40 or so, turn around and make the turn!" Maybe missing turns and getting lost is a rite of passage for trail runners...
The climb continues! You can see the trail below... wait, shit, you can't. OK how about I "ENHANCE":
That's a person, I'm 79.3% sure. It could be Steve! I could easily check that in the days of Strava and GPS data but it's better not to know.
More climbing. 45 minutes and 2.5 miles later, nearing the top. This will be fun to go back down (we go out 7 miles or so and back another 7 miles to an aid station).
After that climb, there's still hills, some up, some down. I liked it better when the aid stations were closer together. You occasionally pass groups of tourists, which always feels odd, such differences in current experiences.
Still headed to the aid station, there's a view to the Northeast of some lake. I ponder whether it is artificial. 12:40pm, 31 miles, about to descend to the aid station.
Crow (or as I'm told, Raven), seen from the descent to the aid station.
Soon after, I arrive at the 33-ish mile aid station, and put on the best thing ever -- fresh socks. Long overdue. I try to eat some but it's getting more difficult. Sitting is nice. I arrive at around 12:50pm, leave around 1:05pm.
Out and back not so interesting, same thing in reverse. I see Edward before the big descent. Take a video of him running the other way. Share some ginger candy. He says Steve should be not too far behind him. We go our separate ways.
Take this video of running at the start of the big descent -- "Coming down the mountain" (around mile 38, 2:05pm)
I didn't mention it until now, but this whole race I've had songs from The Verve's "A Storm in Heaven" in my head. Butterfly, "The Sun, The Sun", Star Sail. I wondered if "The Sun, The Sea" is a reference to l'etranger. I'm not listening to anything but damn those songs just burn a hole in my ears. Maybe I get sick of them, or just my general starting-to-feel-awfulness projects to them (I still love that album and have happily listened to it since!).
I don't see Steve on the descent. I start to guess he missed the turn. D'oh.
The section of the climb that took 50 minutes to go up takes about 30 minutes to go down. Fun. My weak left calf starts feeling not great with every left step. Still fun though.
After that descent, some new territory. 2:30pm, around 39 miles. Eating ginger candies. So far between aid stations.
Nice trails though.
Ah another canyon, 3:15pm.
I think this was soon after the last one. The photographer was like "you're almost to the last aid station!" But those 3 or so miles took FOREVER. Boring flat jeep trail.
Get to the aid station, eat some stale Chipotle chips (they had water and gels and offered to make some soup but eh). Did some more toe management. This is the part of the race where I usually end up complaining and then after the fact regret the complaining. But anyway only like 4 miles to go, just one small climb and descent then it's done.
That climb went on way too long. The small climb is still 1000'. I talked to another person who was also complaining, though his excuse was that since September he had only run two 7 mile runs. pfft! and then he proceeded to go ahead and beat me by a solid 5-10 minutes. Ah, youth.
The climb kept going. More complaining.
Looking back.
My goal was to finish. Bonus to not finish in the dark. 4:30pm.
Damn, magic hour, 4:38pm. After taking this I enjoyed the descent, passed various hikers taking sunset pictures, we all agreed it was beautiful. Finished at something like 4:52pm. Took a few minutes before I could eat anything, had some quesadillas, chili, couldn't really stomach much. It was getting cold, so I took off. Saw in my text messages that Steve did in fact miss the turn (bummer).
Drove back to LA. Got back to the airbnb, ate some snacks, realized I didn't have enough of them, oops, took a shower, got chills, got in bed, felt really good under the covers. Whenever I'd get up to pee, massive shiver shiver chills.
7am Sunday, return to Tacos Delta. Glorious breakfast burrito made me whole. A few hours later, beer with salt and kebabs at Edward's. That was also amazing.
Thus concludes my story.
1 Comment