Memory & CPU Caches

This week and last weekend I was primarily focusing on memory pools, allocators, CPU caches. I now probably know how allocators work, simply separating memory allocation & objects initialization, for example, reserve() function in std::vector, it doesn’t initialize the allocated data segment, thus permitting better performance when we don’t need initialize the data immediately.

CPU cache is another very interesting & important aspect that can (hugely) influence the performance of our programs, as it’s much faster than main memory (RAM). Smaller is faster. A great resource I found on Tuesday evening was a YouTube video – Scott Meyers’s presentation on code::drive conference 2014, a very humorous & high-quality speech!! Really awesome!

Here are a few slides screenshots, the complete presentation pdf version can be downloaded from here.

There are some interesting tops contained within it: cache lines, false sharing, data-oriented design, etc. Very practical and constructive.

From Wednesday and later, I reviewed my qsort vs std::sort problem in terms of cpu cache and cache lines. I found a hug bug (typo) in my qsort function call (embarrassed). Then I further developed that, added a few more tests (for instance, indirect sort), and drew some charts. The details can be found here.

Supplemented on Nov 24, 2020

About cache associativity: see, a very detailed intuitive demonstration.

Additional resource: Gallery of Processor Cache Effects by Igor Ostrovsky.

Completing in Communication

This week I had a discussion about error estimates for FEM with Miss White on Wednesday evening. While in communication about our ideas, I found a few things that I had deemed almost perfect, but it turned out that it was never meant to be perfect if you don’t have an in-depth discussion with someone of your profession yet. As well as subsequent interchange of ideas, we inspired and completed each other in the process of communication in an unconscious way.

Reviewing FEM

This week did actually only one thing, reviewing FEM. I found a lot of C++ numerical libraries, as well as some with FEM, like deal.II, MFEM, FreeFEM. FEM is soooo important in engineering, geophysics, CAD, etc. FEM is fun & powerful.

Thanks to Miss White, I could go over the knowledge in respect to numerical analysis and FEM again. Meanwhile, I want to apologize to Miss White that I didn’t prepare at all for how to teach her programming. Plus I don’t actually use MATLAB much. I’m working on C++, Linux stuff, etc. Truly sorry about that.

Next week, I’m planning to work on some string algorithms (trie, data compression), as well as Computer Vision (which is gonna take a few coming weeks).

Letter To Miss White

Hey, Miss White, how U doin’? It’s quite conflicting whether to write this to ya. (Well, I suck in writing, in turn, there might be some words won’t make sense. So please don’t mind ^_@ )

Last Friday (Oct 2) was really an exceptional day, the whole thing was like a dream, I’d never imagined I could hang out with one of my favorite girls (also my crush) for a whole day. Words failed me. Altogether the time being with you was incredible. But the interesting thing was the day before I was soooo feared, that what if you don’t like there, or don’t like rowing, or whatever. I’m just afraid of upsetting you, which is the last thing I wanna do. I would try everything to make you happy 😉 … I think I’m just in the middle of falling in love with YOU, and I can’t help thinking about YOU all the time. To me, you are perfect. I know it’s way too soon, and this isn’t love. But I need to tell you something: I really really really really really really like you. And I want you, do you want me, do you want me, too.

——- October 22 ——-

I’m always holding the view that people who are told that they’re being loved are happier than those who are not. So I want to be sincere in my feelings and tell you: I LIKE YOU, REALLY REALLY DO.

Actually, you’ve been one of my favourite girls since the first time I saw you when I was trying to audit on an exercise class of mathematical analysis after the major-transferring exam. You were just way too prominent, tall, gorgeous, adorable, a very lovely girl.. And you took all my atention, in turn, I didn’t really listen into anything, but merely remembered one incredible girl that I’d a huge crush on, who was also the only girl I had an image for after the end of the class. It was YOU – Miss White. I’m tickled pink to see you.

I just want to tell you I’M SO INTO YOU. YOU’RE MY LOBSTER. Every minute being with you was peerless. You mean everything to me.

The Secrets


I had a very intense dream this morning, and I was crying, a crying sensation from the deep bottom of my heart, so desperate, … and when I woke up soon afterward I found tears really filled my eyes, like little pearls, running down on both cheeks; yeah, ’cause I was really way too touched and into the dream scenario.

It should have something to do with the film I watched last night – The Secrets, a 2007 Israeli drama film. I just found the rebellious Michelle in this film so appealing ( MARVELOUS;) ). I dreamed a few people, they were all familiar faces, but I can’t confidently identify them (bizarreness of dreams). Those girls in my dream seemed to be my junior school classmates, but the girl I fell in love with should be an image of Michelle (though likely portrayed by a girl in C15, who also lived in my hometown, named Linna Zhao? Or the fantastic girl Hongyang Wang, with whom once we went hiking while we were freshmen during the National Day holidays. Who was the girl is really not that much matter).

She was a tall, gorgeous girl; straightforward, sincere, vivacious, enthusiastic, cheerful, really agreeable! Besides her extremely charming disposition, she was also in possession of some sort of artistic abilities, like sewing – an ingeniously designed bag was sewed for me, which was perfect and I treasured it tremendously as my life.

We had truly a wonderful time, the short but incredible time being with her was one of my happiest. Then kind of we established a relationship, I initiated it – it seemed I had known it was a dream, thus I became the bravest guy I ever thought I could be, then subconsciously kissed her on the cheek and confessed my love to her. When I told her it was my first kiss (though NOT on the lips) and I was incredibly ecstatic about it, my heart was racing fast, emotions ran high, she was kind of surprised. Yeah, I myself do feel stunned as well. After a few flirting words, an unstoppable desire of feeling struggled out and we kissed with tremendous ardor for a few minutes. Recall back now, the feeling of kissing was really something else though not genuine. The truth is I was hopelessly, irretrievably fell in love with her.

Yet, the ending is quite dramatic, there were a bunch of bastards (seemed to be Japs?) attempting to kill us, and sadly, my Miss Right got shot. All of a sudden, my heart turned into a fallen glass bottle, broken. The heart-broken moment was by no means describable. I clasped her tightly in my arms, ran to the beach, golden dusk light shed softly on the sea surface. There seemed to have endless words I want to say to her, but I didn’t manage to. Instead, I could somehow feel her heart beating and the warm blood flowing through her body, bringing me traveling through the fond memories in my mind…