Ministry of Russophobia
[Most Recent Entries] [Calendar View] [Friends]

Below are the 20 most recent journal entries recorded in sadkov's LiveJournal:

    [ << Previous 20 ]
    Sunday, February 17th, 2030
    4:07 pm
    Russian Language is Banned from Now On
    Today I switched my blog completely to English.

    No Russian language is allowed anymore. This applies to transliterated Russian and nicknames too. Although English transliterated into Cyrillic is acceptable.

    Anonymous comments are screened, with only comments in English will be unscreened. Non-anonymous comments in Russian will be deleted, repeated offenders - gulaged.

    a_n_d_r_u_s_h_a and similar discussion-hijacking posts in the vein of "forget Russia, in Africa they are lynching negroes" aren't welcome either. If you care about Africa so much, then go to African blogs. This isn't "" after all.

    New rule: bots like [info]losos_pidaras are going to be banned. LJR is not Wikipedia. He would have also been banned for a Russian nickname. Should have picked "salmon gay" or something instead. Shame there is no way to ban twice.

    Deal with it, Russian scum.

    Imagine one day you wake up, brush your teeth, turn on a TV, make a breakfast, and suddenly notice that something is missing on that map behind the TV news host. You go to Internet, and ask people where is that nasty country, but immediately notice that there is not a single user with Aquafresh colored flag in chat, while people just don't know what you're talking about: they never heard about World War II, Communism or Nazism. Hitler was just an architect. There are no Muslims in Europe, or Israel, Jews still live in Poland, while Middle East became a rich Caliphate and now opposes both America, Europe and Asia. Then you open window shutters, and find that you're on a colonial Mars base, because without two World Wars Germany has managed to be the first country to send a man into space, and then colonized Mars. Well, that was just a dream, but what if?..

    Current Mood: accomplished
    Current Music: Carl Gustav & The 84's ‎- I Want To Kill Russians
    Tuesday, August 20th, 2019
    10:16 am
    Address Space Layout Randomization Considered Harmful
    Ever wonder why software in general becomes slower with time?

    One reason for the slowdown is that modern operating systems enforce the so called ASLR (Address Space Layout Randomization) to mitigate superficial security flaws that could be inside software. There is no way to opt-out from ASLR today (a few years ago it was an option), just like there is no way to opt-out from the use of MMU and protected mode, which also incurs great performance hit, due to context switching between user and system code, in addition to the latency of address translation. The classic example of this "Microsoft/Apple/LinuxFoundation knows better than you" trope.

    The ASLR technique greatly increases startup time of your programs, because now loader can't just mmap the executable into memory, like it did during Windows 95 reign, it has to dynamically re-link it to patch all memory reference with dynamic addresses. That also incurs some great runtime costs, because compilers are now forced to expose these references in plain format for the OS dynamic linker. Because of ASLR, all modern apps are basically compiled as position independent (which means 20% or worse slowdown). Additionally, compiler loses the ability to use profiler statistics for optimizations, since profiler address space will now be different from the runtime one.

    Why they did that? Obviously to sell newer hardware and OS versions, nobody needs, while "security" is just a formal excuse for that. Nobody needs security on a gaming machine. It is also funny how developers silently accept all these training wheels attached to their otherwise lightning fast mountain bike. Even more, with the advent of LLVM, soon there will be enforced JIT (managed code), with no access to x86 inline assembly, which will further slowdown any C/C++ code. "Those who sacrifice liberty for security deserve neither."

    Current Mood: amused
    7:49 am
    C/C++ snippet performance
    Wrote an utility to measure C/C++ code speed.

    The CPU of typical contemporary x86 laptop can do around 17,253,000,000 square roots per second (with SQRTSD instruction). For comparison, the display has 4,096,000 pixels. Given that we can sqrt as much as we want - it isn't any more costly than other basic arithmetic operations.

    Current Mood: amused
    7:24 am
    Monday, August 19th, 2019
    7:55 pm
    Got ubanned at Facebook today
    I immediately got banned again. Because I tell truth.

    Current Mood: amused
    5:33 pm
    Настоящая Мама / Good Mothers
    Сейчас в магазине «Сільпо», женщина с сыном, приехали в гости. Сама говорит с акцентом, а сын только по английски - русского вообще не знает (а зачем?). Притом сын на человека похож, видна нормальная генетика, у него стильная прическа, он модно одет, и интересы человеческие - математика и комиксы, в сравнении с его русскоязычными сверстниками. Вот это настоящая мама. А тех кто рожает в русской стране, да еще и от русских, надо уничтожать вместе с выблядками. Никакой жалости - русское говно только смывать.

    Now at the «Ciльпo» store: a Jewish woman with her son, came to visit her old mom in Ukraine. She speaks with an accent, while her son speaks only English - he does not know Russian at all (and why should he?). Moreover, the son looks like a human being, white man genetics is visible, he has a nice hairstyle, he is fashionably dressed, and has humane interests in mathematics and anime, compared to his Russian-speaking peers. That is the real mom! All while those who give birth in a Russia, and, even more, from Russian fathers, must be destroyed along with their bantlings. No mercy to the scum - Russian shit can only be flushed off.

    Current Mood: amused
    12:50 pm
    Mean Median
    While median is useful for eliminating edge cases, when sampling is expensive, we can average half of sampled values in the middle, instead of taking single median. That should help it converging quicker, just like usual mean. Obviously when more than 1/2 population consists of edge cases, then we are not doing good anyway, so averaging median should be safe enough.

    Current Mood: contemplative
    8:17 am
    Socialism is when everyone has to use state provided square wheels, while round wheels are banned, and everyone who tries to invent a round wheel for himself gets charged with high treason.

    Current Mood: amused
    7:24 am
    After a few days, I already got blocked at Stackoverflow for asking politically loaded questions annoying people, like what is the best way to access Intel CPU intrinsic performance counters, why Clang is inferior to GCC for some code, and if there are any reason to avoid using x86 assembly, when ARM is dying, x86 CISC opcodes are smaller and cache friendly, and even smartphones now have x86 support. At they don't like my questions either:

    Moreover, they tell me to go to Stackoverflow, where I'm banned. They also get irritated by optimization questions, due to most of them using some pre-made crap for non-programming retards, like Gamemaker or Godot, and then asset swap some pre-made game in it. So obviously they consider people making their own game engines with software rendering crazy. What a Nazi community! It seems at early days they were a bit more welcoming, but then the site got infested with _THIS_ kind of people, who need "TRIGGER WARNING: ACTUAL PROGRAMMING!" for everything, and now all questions are in the vein of "How to do X in RPGMaker?". And they were also brainwashed that accessing arrays past bounds is a bad idea, worse being only dynamically generated x86 code to emulate shaders on CPU.

    Current Mood: amused
    Sunday, August 18th, 2019
    9:29 pm
    How to Measure Program Speed
    Ok. When optimizing a program, it is rather important to know how fast each of its parts executes, so one can find bottlenecks and see that changes to the code if changes actually solved them.

    The usually way to measure how fast some piece of code executes, is to first pre-run it several times with random datasets, so branch prediction gets trained, caches get filled and pages loaded. And then use the clock() function, which should return user_time on the Unix system. The first thing one tries to do, is naively taking clock_after-clock_before, but the problem is that on modern operating systems this user time fluctuates/deviates wildly from run to run, giving different timing on each run, especially if code between clock_before and clock_after samplings executes too fast.

    Testing on bare metal would be too time-consuming, complicated and unrealistic - afterwards programs are usually intended to run inside real OSes. So the only way to measure the execution speed is to use statistics. Simplest statistical tools is just running that piece of code in loop for an hour, hoping to get enough clock() samples, and then computing a mean, using samples_sum/n, where n is the total number of loop iterations. Yet code execution time on modern operating system actually fluctuates really hard at times, so one has to use median, instead of mean. Median is produced by sorting the samples, and then picking the middle one. That would throw away extreme deviations from any side.

    Guess one could try to analyze the deviation itself, using something like mean squares and also monitoring processes list to exclude the samples, which were sampled when say antivirus raped your program.

    So yeah, properly measuring performance is hard, but running some code under a hour using this method should give the same result each time up to 10 digits after 0. I'm still searching for a faster way to measure the shit. I'm sure there shouldn't be easier and industry standard way to simply measure a piece of C/C++ code, just nobody knows about it.

    Intel representative says they have special paid suit to measure time:
    That said, the tools can be found in Intel's Parallel Studio product and in particular vtune and inspector (which are included in the suite ) - which I think may do what you want out of the box as it were {you can get a 30 day trial of same: at and if you are a qualifying student using Linux, you can get it for free at:

    It is free only if you're a university student and use Linux, otherwise it costs $700. VTune uses Intel intrinsic instructions to measure stuff and includes some nice GUI browser, which shows exactly how much time each part takes and provides tip for reorganizing the code. Still not something I would spend $700 on. In Ukraine human life costs less :D

    Current Mood: contemplative
    2:29 pm
    Eat your pineapples. Chew your grouse. Your last day is coming. You bourgeois louse.
    Военное время, тяжелейшее для страны, не стало исключением. Ставка Верховного Главнокомандования точно не голодала в суровые годы и, более того, даже не сужала многообразие блюд на своих столах. Если Сталину хочется обедать шестью первоклассными блюдами, то так оно и будет. А если в гости пожаловали главы союзных стран, например, Черчилль, Рузвельт, де Голль и другие, то тем более следует показать, что в стране Советов все хорошо, по крайней мере с продовольствием. А если есть какие-то трудности на фронте, то только из-за того, что враг слишком хитёр и силён.

    Столы буквально ломились от молочных поросят, чёрной и красной икры, нескольких видов редких солёных и копчёных рыб, а также множества других изысканных закусок и блюд. Сталину нравилась французская кухня, и витиеватые названия классических для неё блюд постоянно слышались среди гостей. Было много блюд из дичи — тетеревов, рябчиков и куропаток. Такие сейчас, наверное, подают только в ресторанах со звёздами Мишлена. Официанты уносили старые закуски, подносили новые. Это был поистине королевский пир.

    Current Mood: amused
    Saturday, August 17th, 2019
    7:51 pm

    Without RLE I get 196370 sprites/second (or 865M pixels/second);
    With RLE rle - 554059 sprites/second (or 2442M pixels/second).

    That is on a single core of 2.7 GHz Intel Core i5. So if one uses one core for game logic and other for rendering, targeting 30 frames per second, he/she can get around 18468 medium sized sprites per frame.

    That applies only to directly copied pixels. Blending reduces that number of sprites to 2114 per frame. Generally alpha blending appears to be rather costly operation, because I'm currently doing it properly - with gamma correction. With improper gamma, it is 5202 sprites/frame.

    So there is a large difference between
        sr = (((dr-sr)*sa)>>8) + sr;
        sg = (((dg-sg)*sa)>>8) + sg;
        sb = (((db-sb)*sa)>>8) + sb;

        st = pab_lut[255-sa];
        dt = pab_lut[sa];
        sr = piglut[int2cfp(st[sr]+dt[dr])];
        sg = piglut[int2cfp(st[sg]+dt[dg])];
        sb = piglut[int2cfp(st[sb]+dt[db])];

    Current Mood: annoyed
    3:12 pm
    RLE Blitting
    Ok. Transitioning to RLE blitting haven't improved the performance that much in general case - just 20% speedup (70% when drawing fully opaque sprites, without any blending or effects), but code complexity greatly increased. Still most of my sprites are opaque. Also, for blitter, GCC compiled code is 30% faster than the Clang one.

    One thing I noticed while measuring performance (for both rle and non-rle code) was that at times my code completed two times faster, which is impossible because test used all static data (a single sprite which it blitted a million of times in a loop), with only variables being branch prediction, while I have 0% CPU load, and it doesn't make any syscall inside measured code. What does that even mean? Branch misprediction does affect performance, but not two times in the long run, because it would quickly retrain the cache on thousandth iteration.

    Broken scheduling or OSX intentionally slowing down the code? Or maybe the Intel CPU itself does that? My MacBook is relatively old, so if it has any time bomb, it would be activated by now. Or maybe that is the infamous Meltdown fix slowing down my code two times? How does one disable the Meltdown patch? For Linux there is, but what about OSX? I don't care about security - it is overrated.

    Another interesting finding, with GCC __builtin_expect makes code faster, but in Clang the same __builtin_expect makes the same code slower. As if Clang intentionally uses that info to incur misprediction. WTF?

    There is also an article,

    Current Mood: annoyed
    8:28 am
    Rotozoomer Source Code

    It is under a free license, so I could use it as a template to implement a particle system. Although doing actual polygonal rendering would allow for nicer effects. You can't make say a lightning effect with rotozoomer, only simple particles. But doing polygonal rendering properly is rather tricky. otherwise there would be nasty seams between triangles. Triangle rendering also require some clipping code, but any clipping of a triangle creates a quadrilateral, which then must future be split into two triangles. A lot of code to write and debug. Unfortunately there is no free and simple drop in renderer, which can be modified for my needs (i.e. HDR format, instead of RGB).

    He also explains a trick to draw a 3d sphere without polygonal tesselation or raytracing:

    It is fast enough even for JavaScript:

    That trick was actually used for the original XCOM. I could probably use it too for a less detailed global map, as an alternative to scrolling.

    Current Mood: amused
    Friday, August 16th, 2019
    6:30 pm
    Colored Lights P2
    Haven't found a way to do proper colored lights, but the simple (a+b)/2 should do for now, even despite the hue shift is somewhat subtle (i.e. light from explosion on that dragon's nose).

    Current Mood: annoyed
    11:41 am
    Difference Between Naive and Less Naive Light System
    The animated GIF shows difference between naive and less naive colored light system. I still find it hard to grasp how to properly color-filter the light, because obviously when energy is too high, the light becomes white and the color filter isn't working anymore. And the naive approach shows solid red, even if it ugly and oversaturated, it clearly says "THIS HIGHLIGHT IS RED!!!"

    Current Mood: amused
    9:28 am
    Today's fascists have stamped synthwave and vaporwave with a swastika and swirled them together to concoct a new electronic music subculture called fashwave (the "fash" stands for "fascism"), and another related microgenre called Trumpwave. The aesthetic of both might be summed up as Triumph of the Will on a Tron grid.
    Fashwave is almost entirely instrumental, and wholly unoriginal. If it weren't for the jarring track titles—"Demographic Decline," "Team White," "Death to Traitors," to cite a few by fashwave artist Xurious—you might not be able to tell the difference between fashwave and the microgenres from which it draws inspiration. Occasionally, though, a track will interrupt its celestial synth atmospherics or arcade-like 8-bit bloops with a sample of Adolf Hitler ranting at a rally, or President Trump's speeches spliced together to make him boom, "The heroes are those who kill Jews!" The effect is a hammy nightmare—think Jane Fonda leading one of her 80s exercise routines at a Nuremberg rally.

    Current Mood: amused
    8:08 am
    Korea Before and After Japan
    After Japan, South Korea kept following the Japanese way, while North Korea returned to its communist/russian roots.

    Current Mood: amused
    Thursday, August 15th, 2019
    9:45 pm
    Negative Light
    Just like there is negative saturation, there is negative light. In my example I made the luminescence property of that knight sprite set to minus infinity, and drawn it over the transparent blue background. Now while the knight sprite has a transparent hole inside of it, it doesn't show that blue background, because linearly interpolating the light of background and the light of knight's transparent pixels still results in -infinity.

    Now you will tell me that is not how one does HDR! And you will be right. True -infinity knight will suck in all colors in the universe. So to handle HDR properly, for large light magnitude pixels we need to distribute that light magnitude to other pixels in the range. In case of the -infinity knight all pixels on screen.

    Note that the hole looks gray, and not truly black, because after the image got saved from my game, it was converted to RGB=0,0,0, instead of -infinity,-infinity,-infinity (PNG doesn't support infinities), so it is displayed as gray, due to blending with background.

    Ok. Now you know what is HDR (something PNG cant store).

    Current Mood: amused
    12:24 pm
    Putin implements Stomakhin's Program
    >Убивать, убивать, убивать! Залить кровью всю Россию, не давать ни малейшей пощады никому

    >постараться непременно устроить хотя бы один ядерный взрыв на территории РФ — вот какова должна быть программа радикального Сопротивления, и русского, и чеченского, и любого!

    >Пусть русские по заслугам пожинают то, что они плодили».

    Go-go-go, Mr Putin! Death to the Russian scum! Completely destroy Russia!!!!

    Current Mood: amused
[ << Previous 20 ]
Цитаты о Родине   About