<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
<head>
  <title>
    .mischief.mayhem.soap.
  </title>

  <link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="content-type" content="text/html; charset=utf-8">


<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<meta name="generator" content="Hugo 0.36.1" />

  <meta property="og:title" content=".mischief.mayhem.soap." />
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_US" />
<meta property="og:url" content="http://msinilo.pl/blog2/" />


  
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/pure/0.5.0/base-min.css">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/pure/0.5.0/pure-min.css">
  
  
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/pure/0.5.0/grids-responsive-min.css">
  
  

  <link rel="stylesheet" href="http://msinilo.pl/blog2/css/redlounge.css">
  <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
  <link href='//fonts.googleapis.com/css?family=Raleway:400,200,100,700,300,500,600,800' rel='stylesheet' type='text/css'>
  <link href='//fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic' rel='stylesheet' type='text/css'>

  
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/touch-icon-144-precomposed.png">
  <link rel="shortcut icon" href="/favicon.png">

  
  <link href="http://msinilo.pl/blog2/index.xml" rel="alternate" type="application/rss+xml" title=".mischief.mayhem.soap." />

  

  

  

  

  
</head>

<body>
    <div id="layout" class="pure-g">
        <div class="sidebar pure-u-1 pure-u-md-1-4">
  <div class="header">
    

	

    <h1 class="brand-title">.m.m.s.</h1>
    <h2 class="brand-tagline">Maciej Sinilo</h2>

    <nav class="nav">
      <ul class="nav-list">
        <li class="nav-item"><span class="nav-item-separator">//</span><a href="http://msinilo.pl/blog2">Home</a></li>
        
          <li class="nav-item"><span class="nav-item-separator">//</span><a href="/blog2/about/about">About</a></li>
        
          <li class="nav-item"><span class="nav-item-separator">//</span><a href="/blog2/projects/projects">Projects</a></li>
        
      </ul>
    </nav>

    
    <div class="social-buttons">
      
        
        <a href="http://www.github.com/msinilo" target="_blank"><i class='fa fa-github'></i></a>
        
      
        
        <a href="http://www.linkedin.com/in/maciejsin" target="_blank"><i class='fa fa-linkedin'></i></a>
        
      
        
        <a href="https://mastodon.gamedev.place/@msinilo" target="_blank"><i class='fa fa-twitter'></i></a>
        
      
      
    </div>
    

  </div>
</div>


        <div class="content pure-u-1 pure-u-md-3-4">
            <a name="top"></a>
            

          <div class="posts">
            
            
            
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/tovectorize-or-not/">To vectorize or not to vectorize...</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>31</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Dec</span> <span class="post-date-year">2025</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>3 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  If you ever looked at optimized code generated by Clang, you might have noticed it loves vectorizing. It is enabled by default at higher optimization levels/when not minimizing the size. Clang is a great compiler and it knows what it&rsquo;s doing, but I was curious about two things:
 is it worth the increased binary size what functions are the most &lsquo;affected&rsquo;  The first question could be answered by profiling, but the results were a bit inconclusive, if there were gains they were mostly &ldquo;noise&rdquo; level (both frametimes and CPU counters).
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/tovectorize-or-not/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/chasing-a-hitch/">Chasing a hitch</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>30</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Nov</span> <span class="post-date-year">2025</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>8 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  (I had a more catchy post title, but it&rsquo;d spoil a surprise). Last week we had an interesting debugging session, trying to find a source of a mysterious hitch that suddenly started plaguing one of our tools. Admittedly, the setup is maybe a bit exotic, but it has been working for fine. It&rsquo;s a 3rd party Windows application that supports Lua plugins for custom commands. Some of our commands use os.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/chasing-a-hitch/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/compilers-are-too-smart/">Compilers are (too) smart</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>6</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Jun</span> <span class="post-date-year">2024</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>5 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Last week I noticed some unexpected assembly code in a function calling std::unordered_map::find (yes, I know, friends don&rsquo;t let friends use STL, but that is a topic for another discussion). I decided to investigate a bit and it turned out to be quite a journey. It was a Clang compiler, ARM-based platform, I will use x64 here as behavior is similar and it is easier to repro in the Compiler Explorer.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/compilers-are-too-smart/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/streaky-locks/">Streaky locks</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>4</sup></span><span class="post-date-separator">/</span><span class="post-date-month">May</span> <span class="post-date-year">2024</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>5 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I have been comparing how locks (critical sections) behave on different platforms recently and noticed Windows seemed to be quite different than others. The behavior is consistent across two PC machines I tried (desktop and a laptop), test code is a bit too long to include it in the post, but it is linked here. The gist of it is really simple though - we have multiple threads (even 2 is enough) fighting for access to a shared resource, guarded by a critical section.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/streaky-locks/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/know_your_asm_partn1/">Know your assembly (part N&#43;1)</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>21</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Apr</span> <span class="post-date-year">2024</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>5 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-crazy-snippets" href="http://msinilo.pl/blog2/categories/crazy-snippets">Crazy snippets</a>
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Recently we have updated some of our compilers (Clang) and started running into mysterious problems, mostly in the physics code. We were able to narrow it down to raycasts failing to hit&hellip; sometimes. What made it a bit more annoying - it was only happening on 1 platform I had no easy access too. It was ARM based, but another ARM platform was fine. It seemed like the problem was deep in the guts of PhysX, code is publicly available, so I can link it here (rayAABBIntersect2).
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/know_your_asm_partn1/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/not-all-dot-products-are-equal/">Not all dot products are equal</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>16</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Jun</span> <span class="post-date-year">2023</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>6 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I had another interesting debugging session recently with quite an unexpected conclusion. It all started when we received a new crash report - a certain platform (and 1 platform only) was crashing in a fairly old and seemingly innocent fragment of code:
someModule-&gt;GetElements(elements);std::sort(elements.begin(), elements.end(),[&amp;origin](const Element* a, const Element* b){return a-&gt;pos.DistSqr(origin) &lt; b-&gt;pos.DistSqr(origin);}); Crash was fairly rare although quite consistent in a particular location in the game, release build only, crashing on access violation inside the predicate.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/not-all-dot-products-are-equal/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/operator-considered-harmful/">operator[] considered harmful</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>28</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Oct</span> <span class="post-date-year">2022</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>4 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I&rsquo;ve always felt conflicted about the subscription operator[] in standard containers. It makes sense for random access structures like vectors, but it gets a little bit problematic elsewhere.
Consider this seemingly innocent piece of code (it&rsquo;s not 1:1, but this is code you can easily find in many codebases):
if(someMap[key].value &lt; x){someMap[key].value = x;} 2 lines of actual code, but more than 1 problem, this snippet is potentially incorrect and inefficient.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/operator-considered-harmful/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/know-your-assembly-part-5/">Know your assembly (part 5)</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>28</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Sep</span> <span class="post-date-year">2021</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>2 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  The other day I was looking at a crash dump for a friend. A discussion that followed made me realize it might be worth to write a short post explaining why sometimes 2 seemingly almost identical function calls behave very differently. Consider the following code snippet (simplified): 1struct Foo2{3 __declspec(noinline) const int&amp; GetX() const { return x; }4 virtual const int&amp; GetY() const { return y; }56 int x, y;7};89int Cat(int);10int Lol(Foo* f)11{12 const int&amp; x = f-&gt;GetX();13 const int&amp; y = f-&gt;GetY(); // ***1415 return Cat(x+y);16}
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/know-your-assembly-part-5/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/simple-multithreading-tricks/">Simple multithreading tricks</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>1</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Sep</span> <span class="post-date-year">2021</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>2 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Today I&rsquo;d like to share a simple multithreading trick you can use to minimize &ldquo;bubbles&rdquo; in your pipeline. &ldquo;Simple&rdquo; because it applies mostly to &ldquo;oldschool&rdquo; threading systems, ie. the ones with main thread concept that kicks jobs and eventually flushes them. Cool kids using proper task graphs where everything just flows beautifully should not need it. Imagine we have a simple scenario, our thread produces some work, continues with whatever it&rsquo;s doing, eventually waits for the job to finish (ideally this overlaps the work from previous point, so not much to do here) and processes results.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/simple-multithreading-tricks/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/zig-pathtracer/">Zig pathtracer</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>1</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Aug</span> <span class="post-date-year">2021</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>8 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  If you&rsquo;ve been reading this blog for a bit, you might know that when I experiment with new programming languages, I like to write a simple pathtracer, to get a better &ldquo;feel&rdquo;. It&rsquo;s very much based on smallpt (99-line pathtracer in C++), but I do not want to make it as short as possible. I am more interested in how easily I can get it to run and what language &lsquo;features&rsquo; I can use.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/zig-pathtracer/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/debugger-barrier/">A debugger barrier</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>1</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Jun</span> <span class="post-date-year">2021</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>4 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I&rsquo;ve recently been asked by a friend for a little help with debugging a problem he was running into. Occasionally the program would freeze while trying to process a chunk of data and never moved on to the next one. Application is heavily threaded and processing is done by thread B, while thread A does its own job and periodically checks if work has been finished. If so, it sends it for further transformations and queues more work for thread B.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/debugger-barrier/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/grafana-for-dummies/">Grafana for dummies</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>26</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Dec</span> <span class="post-date-year">2020</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>3 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Grafana is a very popular &ldquo;analytics platform&rdquo; or in more professional terms - a system to create pretty graphs. It&rsquo;s very popular for monitoring system metrics, but really can be used for any timeseries data. It supports plethora of data sources and there is a decent chance you can use one of the off-the-shelf solutions to do 99% of the work for you (for example for some basic system metrics, especially on Linux).
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/grafana-for-dummies/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/microcorruption-writeup/">Microcorruption writeup</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>7</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Jun</span> <span class="post-date-year">2020</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>6 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Microcorruption is my ongoing &ldquo;distraction&rdquo; &ndash; it&rsquo;s an online CTF. I&rsquo;m way late to the party and have been doing it on and off since&hellip; 2013. How does it work exactly? To use their own description: &ldquo;tl;dr: Given a debugger and a device, find an input that unlocks it. Solve the level with that input. You&rsquo;ve been given access to a device that controls a lock. Your job: defeat the lock by exploiting bugs in the device&rsquo;s code.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/microcorruption-writeup/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/api-granularity/">API granularity</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>4</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Dec</span> <span class="post-date-year">2019</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>3 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I&rsquo;d be the first to admit I don&rsquo;t have much experience designing public APIs. I typically work on code that&rsquo;s fairly specific to the game we&rsquo;re making and while some of it is expected to be reused, our potential user pool is very limited, we&rsquo;re still talking just one team, so &lt;40 people and definitely not thousands. I&rsquo;m still successfully using some little utilities/helpers I designed/coded 10+ years ago, but every now and then I run into a situation where decisions taken back then catch up with me and force to rewrite the API.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/api-granularity/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/range-based-for-story/">Ranged based &#34;for&#34; story</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>3</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Oct</span> <span class="post-date-year">2019</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>2 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Consider the following, seemingly innocent (and completely made up) fragment of code:
typedef std::map&lt;int, std::string&gt; MyMap;void foo(const MyMap&amp; m){for(const std::pair&lt;int, std::string&gt;&amp; i : m){if(i.first){printf(&#34;%s\n&#34;, i.second.c_str());}}} Looks simple enough, right? Just iterate over all elements of the map and print the value for non-zero keys. We use range-based for construct, use references, so do not expect any copies. Let&rsquo;s just quickly make sure it all works as expected and consult Compiler Explorer.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/range-based-for-story/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/two-stage-push-pop/">Two Stage Push &amp; Pop</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>14</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Apr</span> <span class="post-date-year">2019</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>3 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I probably mentioned this before, but SPSC (single producer, single consumer) queue is one of my favorite structures. If implemented correctly, it&rsquo;s actually 100% lock-free and is also surprisingly versatile (not all problems require MPMC!). I typically use a slightly modified version of this or an unbounded version, based on code by Dmitry Vyukov.
Both implementations are very simple and possibly lack some of the modern C++ bells and whistles, like emplace, but these should not be hard to add.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/two-stage-push-pop/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/circular-buffers/">Circular buffers (to the rescue)</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>22</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Dec</span> <span class="post-date-year">2018</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>3 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Circular buffers are one (if not the) of my favorite data structures for some quick&amp;dirty debugging. A simple, not production ready version can be implemented in a few lines of code (not ashamed to admit, I usually just copy paste these and remove when I&rsquo;m done) and they&rsquo;re a great tool to &ldquo;record&rdquo; a history of generic events. Any time I run into a seemingly random/unpredictable issue that might take a long time to repro, they&rsquo;re on my short list.
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/circular-buffers/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/vanishing-warning/">Vanishing warning</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>6</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Aug</span> <span class="post-date-year">2018</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>2 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Yet another MSVC story. Visual Studio has a nice compile-time warning when trying to access a static array with invalid index - C4789. According to documentation it&rsquo;s mostly meant for various &lsquo;copy&rsquo; functions (memcpy/strcpy etc), but it seems to work on &lsquo;simple&rsquo; accesses as well. Consider (here&rsquo;s a Godbolt link):
struct Tab{float tab[2];};void Foo(const Tab&amp;);void Bar(float forward){Tab tab;tab.tab[0] = forward;tab.tab[2] = forward; // OOB access!
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/vanishing-warning/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/compilers-are-smart/">Compilers are smart</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>22</sup></span><span class="post-date-separator">/</span><span class="post-date-month">Jul</span> <span class="post-date-year">2018</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>4 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-gamedev" href="http://msinilo.pl/blog2/categories/gamedev">Gamedev</a>
                    
                    <a class="post-category post-category-general-programming" href="http://msinilo.pl/blog2/categories/general-programming">General programming</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  I recently transitioned to Visual Studio 2017 and while it went relatively painless, the new and improved optimizer uncovered some subtle issues lurking in the code (to be fair, Clang/GCC has been behaving same way for a long time now). The code in question was actually quite ancient and originated from this Devmaster forum post (gone now, but found if using The Wayback Machine): Fast and accurate sine/cosine. To be more precise, it was this version with &lsquo;fast wrapping&rsquo;:
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/compilers-are-smart/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
            <section  class="post">
                <header class="post-header">
                    
                    <h1 class="post-title">
                      <a href="/blog2/post/yellowknife/">Yellowknife</a>
                  </h1>
              </header>
              <p class="post-meta">
                  
                  <span class="post-date">
                    <span class="post-date-day"><sup>6</sup></span><span class="post-date-separator">/</span><span class="post-date-month">May</span> <span class="post-date-year">2018</span>
                </span>
                
                
                    By <a class="post-author" >admin</a>
                
                
                    <span class="post-reading-time"><i class="fa fa-clock-o"></i> <em>5 min. read</em></span>
                
                
                <div class="post-categories">
                    
                    <a class="post-category post-category-photography" href="http://msinilo.pl/blog2/categories/photography">Photography</a>
                    
                </div>
                
            </p>
            <article class="post-summary">
                  Ever since I was a kid I was always fascinated by the northern lights and hoped to see them in person one day. Poland is too far south/densely populated to spot them, though, so it wasn&rsquo;t a very realistic dream. In 2009 I did move to Sweden, but still, this was Stockholm area, so my chances might have been bigger, but not by much (plus only been there for a year).
              </article>
              <div class="read-more-link">
                  <a href="/blog2/post/yellowknife/"><span class="read-more-slashes">//</span>Read More...</a>
              </div>
          </section>
          
        </div>

        <nav id="pagenavi">
            <hr class="thin" /> 
              <div class="next-prev-link">

              
              
              
                  <a href="http://msinilo.pl/blog2/page/2" class="next">Next</a>
               
            </div>
        </nav>

        <div class="footer">
	<hr class="thin" />
	<div class="pure-menu pure-menu-horizontal pure-menu-open">
		<ul class="footer-menu">
		
			<li><a href="/blog2/post">Archives</a></li>
		
		</ul>
	</div>

</div>
        </div>
    </div>

    
</body>
</html>
