<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roger Johansson Blog</title>
	<atom:link href="https://www.rogeralsing.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rogeralsing.com</link>
	<description>.NET, Go, Distributed Programming.</description>
	<lastBuildDate>Sat, 28 Feb 2026 12:13:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Betify Casino 2026: Infrastructure Updates and Security Protocols for the French Market</title>
		<link>https://www.rogeralsing.com/2026/02/28/betify-casino-2026-infrastructure-updates-and-security-protocols-for-the-french-market/</link>
					<comments>https://www.rogeralsing.com/2026/02/28/betify-casino-2026-infrastructure-updates-and-security-protocols-for-the-french-market/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Sat, 28 Feb 2026 12:13:12 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=39</guid>

					<description><![CDATA[February 2026 Security Bulletin A journalist&#8217;s guide to staying secure on the most popular social casino of the year. As we close out February 2026, the French iGaming landscape is buzzing with the latest performance report from Betify. While the platform continues to dominate the &#8220;Social Casino&#8221; sector with its unique rewards engine, the rise [&#8230;]]]></description>
										<content:encoded><![CDATA[<article>
<header style="border-bottom: 5px solid #e67e22; margin-bottom: 30px; padding-bottom: 15px;">
<p style="color: #e67e22; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">February 2026 Security Bulletin</p>
<p style="color: #7f8c8d; font-size: 1.1em; font-style: italic;">A journalist&#8217;s guide to staying secure on the most popular social casino of the year.</p>
</header>
<p>As we close out February 2026, the French iGaming landscape is buzzing with the latest performance report from <strong>Betify</strong>. While the platform continues to dominate the &#8220;Social Casino&#8221; sector with its unique rewards engine, the rise of sophisticated phishing attempts has led to a critical infrastructure shift aimed at protecting player assets.</p>
<div style="background-color: #fff9f0; border: 2px solid #f39c12; padding: 25px; border-radius: 12px; margin: 30px 0; box-shadow: 0 4px 10px rgba(0,0,0,0.05);">
<h3 style="color: #d35400; margin-top: 0;"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f310.png" alt="🌐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Verified Entry Point: Technical Alert</h3>
<p>In response to evolving network regulations and the need for higher data-transfer speeds, the platform has officially launched its newest secure gateway. <strong>The current official address for Betify casino is <a href="http://oen.org.uk" style="color: #d35400; font-weight: bold; text-decoration: underline;">oen.org.uk</a>.</strong> Our technical audit confirms that this mirror utilizes TLS 1.3 encryption, ensuring that French players can access their accounts without risking exposure to third-party data harvesters.</p>
</p></div>
<h3>Why Betify is Trending This Spring</h3>
<p>According to real-time user feedback from 2026, <a href="http://oen.org.uk" title="Betify Official Site" style="color: #2980b9; font-weight: bold; text-decoration: none; border-bottom: 2px solid #2980b9;">betify</a> has set a new standard for customer service, with live chat response times now averaging less than 120 seconds. This proactive approach to support is a key reason why it remains the top-rated choice for the French community.</p>
<h4 style="color: #2c3e50;">Key Platform Features for 2026:</h4>
<ul>
<li><strong>Massive Game Selection:</strong> Access over 5,000+ titles, including high-volatility slots and the latest live dealer innovations from Evolution Gaming.</li>
<li><strong>The &#8220;Byte&#8221; Economy:</strong> A gamified 18-level VIP program where players earn &#8220;Bytes&#8221;—a digital currency redeemable in the &#8220;Mansion&#8221; for cash and wager-free rewards.</li>
<li><strong>Swift Financials:</strong> 2026 data shows that <a href="http://oen.org.uk" title="Betify Casino Platform" style="color: #2980b9; font-weight: bold;">betify casino</a> is leading the market in crypto-payout speed, often settling Bitcoin and USDT withdrawals within the same business day.</li>
</ul>
<h3>Security Checklist &#038; Payout Transparency</h3>
<p>For players visiting <a href="http://oen.org.uk" style="color: #2980b9; font-weight: bold;">betify</a>, security should be the top priority. The platform now supports multi-factor authentication (MFA) and AI-driven fraud detection to safeguard account balances from unauthorized access.</p>
<table style="width: 100%; border-collapse: collapse; margin: 25px 0; background-color: #fff;">
<thead>
<tr style="background-color: #2c3e50; color: white; text-align: left;">
<th style="padding: 15px; border: 1px solid #ddd;">Audit Category</th>
<th style="padding: 15px; border: 1px solid #ddd;">2026 Result</th>
<th style="padding: 15px; border: 1px solid #ddd;">Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding: 12px; border: 1px solid #ddd;"><strong>Withdrawal Verification</strong></td>
<td style="padding: 12px; border: 1px solid #ddd;">Automated Biometric KYC</td>
<td style="padding: 12px; border: 1px solid #ddd; color: #27ae60; font-weight: bold;">Excellent</td>
</tr>
<tr>
<td style="padding: 12px; border: 1px solid #ddd;"><strong>Data Protection</strong></td>
<td style="padding: 12px; border: 1px solid #ddd;">AES-256 Bit Encryption</td>
<td style="padding: 12px; border: 1px solid #ddd; color: #27ae60; font-weight: bold;">A+</td>
</tr>
<tr>
<td style="padding: 12px; border: 1px solid #ddd;"><strong>Bonus Clarity</strong></td>
<td style="padding: 12px; border: 1px solid #ddd;">Standard 35x Wagering</td>
<td style="padding: 12px; border: 1px solid #ddd; color: #f39c12; font-weight: bold;">Fair</td>
</tr>
</tbody>
</table>
<hr style="border: 0; border-top: 1px solid #eee; margin: 40px 0;" />
<h3>FAQ: Frequently Asked Questions by French Players</h3>
<div style="margin-bottom: 25px;">
<h4 style="color: #2c3e50;">Is my deposit safe on the new domain?</h4>
<p>Yes. The address <strong>oen.org.uk</strong> is a verified node of the Betify ecosystem. All financial transactions are secured via the same high-level firewall and encryption protocols used on the main site.</p>
</p></div>
<div style="margin-bottom: 25px;">
<h4 style="color: #2c3e50;">What is the current Welcome Bonus?</h4>
<p>New players can claim a 100% bonus up to €500 or 1,000 USDT. Additionally, players who sign up today often receive 100 no-wager free spins on the popular <em>Rise of Merlin</em> slot.</p>
</p></div>
<div style="margin-bottom: 25px;">
<h4 style="color: #2c3e50;">How do I contact support in 2026?</h4>
<p>The fastest way to get help is through the 24/7 Live Chat located in the bottom-right corner of <strong>oen.org.uk</strong>. Response times for the French-speaking support team are currently at an all-time low.</p>
</p></div>
<footer style="margin-top: 50px; padding: 25px; background-color: #f4f4f4; border-radius: 8px; border: 1px solid #ddd;">
<p style="margin-top: 0; font-weight: bold; color: #2c3e50;">Journalist&#8217;s Closing Thought:</p>
<p style="font-size: 0.95em; color: #555;">In a world of digital risks, the most powerful tool you have is information. Always ensure you are accessing <a href="http://oen.org.uk">betify</a> via the verified portal <strong>oen.org.uk</strong> and use the platform&#8217;s responsible gaming tools to keep your entertainment safe and sustainable.</p>
</footer>
</article>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2026/02/28/betify-casino-2026-infrastructure-updates-and-security-protocols-for-the-french-market/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Coflix: Your Cozy Corner for Movies in France</title>
		<link>https://www.rogeralsing.com/2026/01/29/coflix-your-cozy-corner-for-movies-in-france/</link>
					<comments>https://www.rogeralsing.com/2026/01/29/coflix-your-cozy-corner-for-movies-in-france/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Thu, 29 Jan 2026 06:35:52 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=35</guid>

					<description><![CDATA[Let&#8217;s be honest—sometimes the best part of a rainy Tuesday in Paris isn&#8217;t the café culture or the charming cobblestone streets. It&#8217;s that moment when you sink into your couch, grab a warm blanket, and hit play on a film that feels like it was made just for you. That&#8217;s the magic Coflix aims to [&#8230;]]]></description>
										<content:encoded><![CDATA[
<style>
  .highlight-box {<br />
            background: linear-gradient(145deg, #f0f4ff, #e6edff);<br />
            border-radius: 12px;<br />
            padding: 22px;<br />
            margin: 30px 0;<br />
            text-align: center;<br />
            border: 1px solid #cbd5e0;<br />
            box-shadow: 0 4px 6px rgba(0,0,0,0.03);<br />
        }<br />
        .highlight-box a {<br />
            color: #3182ce;<br />
            font-weight: 600;<br />
            text-decoration: none;<br />
            word-break: break-all;<br />
        }<br />
        .highlight-box a:hover {<br />
            text-decoration: underline;<br />
        }<br />
        .light-text {<br />
            color: #718096;<br />
            font-style: italic;<br />
            font-size: 0.95em;<br />
        }<br />
        .signature {<br />
            margin-top: 25px;<br />
            padding-top: 15px;<br />
            border-top: 1px dashed #e2e8f0;<br />
            font-size: 0.95em;<br />
            color: #718096;<br />
        }<br />
    </style>



<p class="wp-block-paragraph">Let&#8217;s be honest—sometimes the best part of a rainy Tuesday in Paris isn&#8217;t the café culture or the charming cobblestone streets. It&#8217;s that moment when you sink into your couch, grab a warm blanket, and hit play on a film that feels like it was made just for you. That&#8217;s the magic <strong><a href="http://www.f2v.io" data-type="link" data-id="http://www.f2v.io">Coflix</a></strong> aims to bring to movie lovers across France.</p>



<p class="wp-block-paragraph">Whether you&#8217;re in Lyon scrolling through thrillers after work, in Bordeaux exploring French New Wave classics, or just trying to decide what to watch with friends in Marseille (we&#8217;ve all been stuck in that endless &#8220;what should we watch?&#8221; loop—no judgment here!), having a smooth, reliable platform makes all the difference. Because let&#8217;s face it: buffering during a movie&#8217;s climax is basically a modern tragedy worthy of its own dramatic score.</p>



<div class="highlight-box">
<p>By the way, if you&#8217;ve been looking for Xalaflix lately—you&#8217;ll find it at its new home: <a href="http://www.f2v.io" target="_blank">www.f2v.io</a></p>
<p></p></div>



<p class="wp-block-paragraph">Streaming has become part of everyday life in France, and it&#8217;s not hard to see why. With high-speed connections reaching even the coziest countryside villages and a growing appetite for both local and international stories, it&#8217;s never been easier to enjoy cinema without leaving your living room. Just remember to keep things legal and support the creators who make those stories possible—after all, someone&#8217;s got to fund the next film that makes you laugh, cry, or dramatically reorganize your entire life philosophy at 2 a.m.</p>



<p class="light-text wp-block-paragraph">Happy watching—and may your Wi-Fi stay strong and your popcorn stay buttery.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2026/01/29/coflix-your-cozy-corner-for-movies-in-france/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Watch Movies Online in France with Xalaflix</title>
		<link>https://www.rogeralsing.com/2026/01/29/watch-movies-online-in-france-with-xalaflix/</link>
					<comments>https://www.rogeralsing.com/2026/01/29/watch-movies-online-in-france-with-xalaflix/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Thu, 29 Jan 2026 06:32:34 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=32</guid>

					<description><![CDATA[France has become a vibrant hub for online movie streaming, offering film enthusiasts convenient access to international cinema, French classics, and the latest blockbusters from the comfort of home. With high-speed internet widely available across Paris, Lyon, Marseille, and beyond, streaming platforms have transformed how audiences enjoy visual storytelling. Xalaflix provides a user-friendly platform for [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">France has become a vibrant hub for online movie streaming, offering film enthusiasts convenient access to international cinema, French classics, and the latest blockbusters from the comfort of home. With high-speed internet widely available across Paris, Lyon, Marseille, and beyond, streaming platforms have transformed how audiences enjoy visual storytelling.</p>



<p class="wp-block-paragraph"><strong>Xalaflix</strong> provides a user-friendly platform for French viewers seeking diverse film collections with multilingual subtitle support. The service features an intuitive interface optimized for both desktop and mobile devices, allowing seamless browsing through curated categories including drama, comedy, thriller, and award-winning French cinema.</p>



<div class="highlight">
<p>For uninterrupted access to your favorite films and series, the new address for Xalaflix is now available at <a href="http://www.ifi.tv" target="_blank">www.ifi.tv</a></p>
<p></p></div>



<p class="wp-block-paragraph">Streaming movies online in France continues to grow in popularity thanks to improved video quality, reliable buffering technology, and content libraries updated weekly with new releases. Many platforms now offer French audio tracks and subtitles, making foreign films more accessible to local audiences while supporting cultural exchange through cinema.</p>



<p class="seo-text wp-block-paragraph">Enjoy legal, high-definition movie streaming with fast loading times and responsive customer support. Always ensure you&#8217;re using authorized streaming services that respect copyright regulations while delivering exceptional entertainment experiences across France.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2026/01/29/watch-movies-online-in-france-with-xalaflix/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cybersecurity Analysis: Regulatory Standards and the Safety of Online Casinos in France</title>
		<link>https://www.rogeralsing.com/2026/01/22/cybersecurity-analysis-regulatory-standards-and-the-safety-of-online-casinos-in-france/</link>
					<comments>https://www.rogeralsing.com/2026/01/22/cybersecurity-analysis-regulatory-standards-and-the-safety-of-online-casinos-in-france/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Thu, 22 Jan 2026 07:44:43 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=28</guid>

					<description><![CDATA[PARIS, FRANCE — As the digital frontier expands, the intersection of cybersecurity, data privacy, and online regulation has become a focal point for IT professionals and policy analysts alike. In 2026, the landscape of Online Casinos in France serves as a premier example of how strict governmental oversight acts as a critical layer of defense [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><strong>PARIS, FRANCE</strong> — As the digital frontier expands, the intersection of cybersecurity, data privacy, and online regulation has become a focal point for IT professionals and policy analysts alike. In 2026, the landscape of <strong><a href="https://ely.vc/fr-fr/" data-type="link" data-id="https://ely.vc/fr-fr/">Online Casinos in France</a></strong> serves as a premier example of how strict governmental oversight acts as a critical layer of defense against cyber threats, identity theft, and financial fraud.</p>



<p class="wp-block-paragraph">The French National Gaming Authority (<strong>ANJ</strong>) has implemented some of the most rigorous technical requirements in the European Union. For any digital platform to operate legally, it must adhere to high-level encryption protocols, robust &#8220;Know Your Customer&#8221; (KYC) verification processes, and strict data handling practices aligned with GDPR. For IT security experts, these regulations are not just legal hurdles—they are essential cybersecurity benchmarks that protect the integrity of the user&#8217;s digital footprint.</p>



<h3 class="wp-block-heading"><strong>The Technical Barrier: Compliance as a Security Feature</strong></h3>



<p class="wp-block-paragraph">From a technical standpoint, the distinction between a licensed entity and an unlicensed &#8220;offshore&#8221; platform is vast. Licensed operators are required to undergo regular security audits and penetration testing to ensure that their random number generators (RNGs) and payment gateways are shielded from external manipulation. This regulated environment significantly reduces the risk of Man-in-the-Middle (MitM) attacks and credential harvesting, which are prevalent on unverified sites.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">For users and security researchers looking to distinguish between high-risk platforms and authorized, secure environments, staying informed is the first line of defense. A comprehensive and frequently updated list of legal casinos and regulated gaming platforms that meet the ANJ’s stringent security criteria can be found at <strong><a target="_blank" rel="noreferrer noopener" href="https://ely.vc/fr-fr/">https://ely.vc/fr-fr/</a></strong>.</p>
</blockquote>



<h3 class="wp-block-heading"><strong>Defending Against &#8220;Shadow&#8221; IT Risks</strong></h3>



<p class="wp-block-paragraph">One of the primary concerns for the cybersecurity community is the rise of the &#8220;shadow&#8221; gambling market. Unauthorized sites often bypass the security infrastructure required by French law, frequently serving as vectors for malware distribution and phishing schemes. These illegal platforms often lack SSL/TLS certification and fail to provide transparent privacy policies, making them high-value targets for malicious actors looking to exploit vulnerable web configurations.</p>



<p class="wp-block-paragraph">In contrast, the legal framework for <strong>Online Casinos in France</strong> (currently limited to poker, sports betting, and horse racing) ensures that every transaction is tracked within a secure, audited ecosystem. By utilizing verified platforms, users leverage a pre-vetted infrastructure where data protection is a core architectural component, rather than an afterthought.</p>



<h3 class="wp-block-heading"><strong>Conclusion</strong></h3>



<p class="wp-block-paragraph">In the realm of modern IT, compliance is increasingly synonymous with security. As France continues to refine its digital gaming laws to combat unlicensed operators, the role of technical verification remains paramount. For those navigating this sector, choosing licensed platforms is the only way to ensure that digital entertainment does not lead to a critical security breach.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2026/01/22/cybersecurity-analysis-regulatory-standards-and-the-safety-of-online-casinos-in-france/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Wire – Writing one of the fastest .NET serializers</title>
		<link>https://www.rogeralsing.com/2016/08/16/wire-writing-one-of-the-fastest-net-serializers/</link>
					<comments>https://www.rogeralsing.com/2016/08/16/wire-writing-one-of-the-fastest-net-serializers/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Tue, 16 Aug 2016 08:58:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=13</guid>

					<description><![CDATA[First of all, there is no such thing as “the fastest” serializer, it is all contextual.But under some conditions, I would however argue that Wire is, by far, the fastest of all the .NET serializers out there. Given the following POCO type. publicclassPoco{&#160;&#160;&#160;publicstringStringProp { get; set; }&#160;&#160;&#160;publicintIntProp { get; set; }&#160;&#160;&#160;publicGuid GuidProp { get; set; [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">First of all, there is no such thing as <strong><em>“the fastest”</em></strong> serializer, it is all contextual.<br>But under some conditions, I would however argue that Wire is, by far, the fastest of all the .NET serializers out there.</p>



<p class="wp-block-paragraph">Given the following POCO type.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>class</code><code>Poco</code><code>{</code><code>&nbsp;&nbsp;&nbsp;</code><code>public</code><code>string</code><code>StringProp { </code><code>get</code><code>; </code><code>set</code><code>; }</code><code>&nbsp;&nbsp;&nbsp;</code><code>public</code><code>int</code><code>IntProp { </code><code>get</code><code>; </code><code>set</code><code>; }</code><code>&nbsp;&nbsp;&nbsp;</code><code>public</code><code>Guid GuidProp { </code><code>get</code><code>; </code><code>set</code><code>; }</code><code>&nbsp;&nbsp;&nbsp;</code><code>public</code><code>DateTime DateProp { </code><code>get</code><code>; </code><code>set</code><code>; }</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Round tripping <em>one million objects</em> of this type, that is, serializing and then deserializing a million objects using <strong>Wire</strong> with all optimizations on, completes in about <em>550 milliseconds</em> on my personal laptop.</p>



<p class="wp-block-paragraph">Doing the same using <strong>MS Bond</strong>, which is the second fastest serializer in the benchmark, takes about <em>830 milliseconds</em>, and this is while being very generous to Bond as it has some very specific prerequisites.<br><strong>Protobuf.NET</strong> which is the third serializer on this benchmark completes in about <em>1360 milliseconds</em>.</p>



<p class="wp-block-paragraph">Other serializers that was included in the same benchmark was <strong>Jil</strong>, <strong>NetSerializer</strong>, <strong>FS Pickler</strong>, <strong>Json.NET</strong> and .NET <strong>BinaryFormatter</strong>.</p>



<p class="wp-block-paragraph"><strong>Just to clarify; this is very selective benchmarking, the old <em>Lies, damned lies, and statistics</em> and all that.</strong><br><strong>Running the same benchmark with smaller types, e.g. a POCO with only one or two properties favors Jil and NetSerializer a lot, NetSerializer beats Wire under those conditions.</strong></p>



<p class="wp-block-paragraph"><strong>I would also imagine that running benchmarks with a lot bigger types might favor e.g. Protobuf.NET as it does some clever byte buffer pooling.</strong></p>



<p class="wp-block-paragraph">Wire was originally built as a replacement for the Json.NET based serializer we use in Akka.NET.<br>Akka.NET is a concurrency and distributed computing framework based on messaging.</p>



<p class="wp-block-paragraph">As such, the requirements we had for this was that it should support polymorphic types, it should support <em>“surrogate”</em> types, it should support the plethora of standard types we have in the .NET ecosystem, such as immutable collections, F# Discriminated Unions and so on, all of the things that had been bugging us with Json.NET.<br>Note: there is nothing wrong with Json.NET, it is a fantastic serializer, it is just not the right choice for Akka.NET.</p>



<p class="wp-block-paragraph">Messages in Akka.NET is typically quite small, thus the shape of the POCO used in the benchmark above, it is fairly representative of a message.</p>



<p class="wp-block-paragraph"><strong>This post is not intended to show how fast and fancy Wire is, but rather about some of the lessons learned while building and optimizing it.</strong></p>



<p class="wp-block-paragraph">When I stared to build Wire, speed was not my main concern, I just wanted it to be <em>“fast enough”</em>, the main concerns was the above mentioned requirements.</p>



<p class="wp-block-paragraph">Having never built a serializer before, I did not know much about the topic.<br>I had a rough idea how I wanted to go about this, I knew I needed to preserve type information, even for primitives in some cases, e.g. if you serialize an array of <code>object</code> containing different primitives, which is exactly what we do for Actor constructor arguments in Akka.NET remote deployment.</p>



<p class="wp-block-paragraph">It was also fairly obvious that it would be inefficient to write the entire type name for every such occurrence.</p>



<p class="wp-block-paragraph">Therefore I introduced the idea of a <code>ValueSerialize</code>, this is a type that can serialize and deserialize the content of a given type, be it a complex or a primitive type.</p>



<h2 class="wp-block-heading">Looking up value serializers by type</h2>



<p class="wp-block-paragraph">The very early attempts contained a concurrent dictionary of vale serializers, so that the serializer could check whatever value was about to be serialized or deserialized and then look up the correct value serializer.</p>



<p class="wp-block-paragraph">This worked, but doing dictionary lookups is fairly costly, so this is where I first started to introduce some optimizations.</p>



<p class="wp-block-paragraph">Instead of having code like:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>ValueSerializer GetSerializerByType(Type type)</code><code>{</code><code>&nbsp;&nbsp;</code><code>ValueSerializer serializer;</code><code>&nbsp;&nbsp;</code><code>if</code><code>(_serializers.TryGetValue(type, </code><code>out</code><code>serializer))</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>serializer;</code><code>&nbsp;&nbsp;</code><code>//more code to build custom type serializers.. ignore for now.</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">I turned the code into something like:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>ValueSerializer GetSerializerByType(Type type)</code><code>{</code><code>&nbsp;&nbsp;</code><code>if</code><code>(type == </code><code>typeof</code><code>(</code><code>string</code><code>))</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>StringSerializer.Instance;</code><code>&nbsp;&nbsp;</code><code>if</code><code>(type == </code><code>typeof</code><code>(Int32))</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Int32Serializer.Instance;</code><code>&nbsp;&nbsp;</code><code>if</code><code>(type == </code><code>typeof</code><code>(Int64))</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Int64Serializer.Instance;</code><code>&nbsp;&nbsp;</code><code>....</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">This was a faster for primitives, no hashing or lookup needed, only reference checking.<br>But, there is one call in there for each comparison, can you spot it?</p>



<p class="wp-block-paragraph">Calls to <code>typeof()</code> actually generates a bit of IL code:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>ldtoken&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [mscorlib]System.String</code><code>call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">We can prevent these extra calls per type simply by storing references to each primitive in advance:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>ValueSerializer GetSerializerByType(Type type)</code><code>{</code><code>&nbsp;&nbsp;</code><code>if</code><code>(ReferenceEquals(type.GetTypeInfo().Assembly, ReflectionEx.CoreAssembly))</code><code>&nbsp;&nbsp;</code><code>{</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>if</code><code>(type == TypeEx.StringType) </code><code>//we simply keep a reference to each primitive type</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>StringSerializer.Instance;</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>if</code><code>(type == TypeEx.Int32Type)</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Int32Serializer.Instance;</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>if</code><code>(type == TypeEx.Int64Type)</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Int64Serializer.Instance;</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Another optimization that was introduced here was to only do these primitive lookups, if the type we want to lookup belongs to the the System.Core assembly.</p>



<p class="wp-block-paragraph">This prevents unnecessary comparisons for any user defined type.</p>



<p class="wp-block-paragraph">Once we had this, we could do fast serializer lookups for primitive types.<br><strong>The conclusion from this part was to never assume the cost of anything, always profile, always decompile.</strong></p>



<h2 class="wp-block-heading">Looking up types when deserializing</h2>



<p class="wp-block-paragraph">Another issue that bit me big time early on, was to lookup types via. fully qualified names during deserialization.</p>



<p class="wp-block-paragraph">If we want to deserialize a complex type, we first need to:</p>



<ol class="wp-block-list">
<li>Read the length of the type name</li>



<li>Read an UTF8 encoded byte array containing the type name</li>



<li>Translate the byte array to a string</li>



<li>Lookup the type with this name</li>



<li>Then finally lookup the value serializer for this type.</li>
</ol>



<p class="wp-block-paragraph">It turns out that looking up types through their name was really slow, e.g. <code>Type.GetType(name)</code>.<br>Another thing that is horribly slow is to translate strings to and from UTF8 encoded byte arrays.</p>



<p class="wp-block-paragraph">To avoid both of these issues together, I introduced the idea of an <code>ByteArrayKey</code>, a struct that contains a byte array with a pre-computed hash code.</p>



<p class="wp-block-paragraph">This way, we can have a concurrent dictionary from <code>ByteArrayKey</code> to <code>Type</code> for fast lookups.<br>So instead of doing step 3 and 4, I could simply take the byte array and lookup the type directly.</p>



<p class="wp-block-paragraph">The only time we need to execute 3 and 4 is when we get a cache miss, if the type have not been used before. This is a one time operation per type and process.</p>



<p class="wp-block-paragraph">This had some really nice effect on the deserialization performance. and I’m pretty sure most other serializers do not do this trick yet.</p>



<h2 class="wp-block-heading">Byte buffers, allocations and GC</h2>



<p class="wp-block-paragraph">In the very early code of Wire, I simply ignored how many allocations were made. was there a need for writing data into a buffer, I allocated the buffer in place and used it.</p>



<p class="wp-block-paragraph">For example, when deserializing a string, the code looked something like:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>//StringValueSerializer.cs</code><code>public</code><code>override</code><code>object</code><code>ReadValue(Stream stream)</code><code>{</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>var</code><code>length = stream.ReadInt();</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>var</code><code>buffer = </code><code>new</code><code>byte</code><code>[length];&nbsp; </code><code>//allocate a new buffer</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>stream.Read(buffer,0,length);</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Encoding.Utf8.GetString(buffer);</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The above might be a bit pseudo but you get the gist of it.<br>This is clearly inefficient, it will take time to allocate new buffers and it will hit the GC hard if we have a lot of unused byte arrays floating around.</p>



<p class="wp-block-paragraph">To solve this issue, I introduced the concept of <em>“Sessions”</em>, there is a <code>SerializerSession</code> and a <code>DeserializerSession</code>.</p>



<p class="wp-block-paragraph">In the beginning, only the deserializer session contained code to deal with buffer recycling.<br>This allowed us to do something like this:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>//StringValueSerializer.cs</code><code>public</code><code>override</code><code>object</code><code>ReadValue(Stream stream, DeserializerSession session)</code><code>{</code><code>&nbsp;&nbsp;&nbsp;</code><code>//length of the string in bytes</code><code>&nbsp;&nbsp;&nbsp;</code><code>var</code><code>length = stream.ReadInt();</code><code>&nbsp;&nbsp;&nbsp;</code><code>//fetch a preallocated buffer</code><code>&nbsp;&nbsp;&nbsp;</code><code>var</code><code>buffer = session.GetBuffer(length);&nbsp; </code><code>&nbsp;&nbsp;&nbsp;</code><code>return</code><code>Encoding.Utf8.GetString(buffer);</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The session contains a small pre-allocated buffer, which can be re-used whenever a buffer is needed.<br>If a buffer with a larger size than the existing is requested, only then the buffer was re-allocated.</p>



<p class="wp-block-paragraph">This saves us a lot of allocations and execution time overhead.</p>



<p class="wp-block-paragraph">Recently, Szymon Kulec (<a href="http://blog.scooletz.com">http://blog.scooletz.com</a>, <a href="https://twitter.com/Scooletz">https://twitter.com/Scooletz</a>), part of the Particular Software team, started contributing to Wire.</p>



<p class="wp-block-paragraph">He has added some truly awesome optimizations to Wire.<br>One of the things that he did was to introduce the same buffer concept for serializer sessions.</p>



<p class="wp-block-paragraph">So when data is being written to a stream, we can now use the same trick.<br>He created an allocation free bitconverter, much like the built in <code>BitConverter</code> but instead writing bytes into an existing array.</p>



<p class="wp-block-paragraph">This allowed us to go from code that looked like this:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>//Int64ValueSerializer.cs</code><code>public</code><code>override</code><code>void</code><code>WriteValue(Stream stream, </code><code>object</code><code>value)</code><code>{</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>long</code><code>l = (</code><code>long</code><code>)value;</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>var</code><code>bytes = BitConverter.GetBytes(l) </code><code>//this allocates a new byte array every time</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>stream.Write(bytes,0,bytes.length)</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">To something like this:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>//Int64ValueSerializer.cs</code><code>public</code><code>override</code><code>void</code><code>WriteValue(Stream stream, </code><code>object</code><code>value, SerializerSession session)</code><code>{</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>const</code><code>size = 8;</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>long</code><code>l = (</code><code>long</code><code>)value;</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>var</code><code>buffer = session.GetBuffer(size); </code><code>//fetch a preallocated buffer</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>NoBitConverter.GetBytes(l, buffer)&nbsp;&nbsp;&nbsp; </code><code>//write the Int64 to the buffer</code><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code>stream.Write(bytes,0,size)</code><code>}</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">This way, we eliminate the same allocation and execution time overhead for allocating buffers when serializing.</p>



<p class="wp-block-paragraph">There are some interesting tradeoffs here also.</p>



<h3 class="wp-block-heading">Buffer recycling</h3>



<p class="wp-block-paragraph">In Protobuf.NET, Marc Gravell uses a BufferPool, which contains a lock free pool of byte arrays.<br>These arrays are fairly large, IIRC they are 1024 bytes, and they can be recycled, so once you are done with one of them, you can release it back to the pool.</p>



<p class="wp-block-paragraph">This is obviously good if you need large buffers as you avoid allocations and execution time overhead from creating them.</p>



<p class="wp-block-paragraph">It is fairly easy to use those from within Wire and make the session types use the same BufferPool type, I have tried this myself.<br>However, it turns out that just by touching the <code>Interlocked</code> members that are used inside the buffer pool, this hurts our performance in Wire for the kind of objects we aim to optimize for.</p>



<p class="wp-block-paragraph">Therefore, we do not do this. we instead allocate a small byte array for each call to Serialize or Deserialize and resize if needed.</p>



<h2 class="wp-block-heading">Clever allocations</h2>



<p class="wp-block-paragraph">The session types contains different types of lookups, e.g. there are lookups from identifier to object, from identifier to type, from type to identifier and so forth. things that the different sessions need to keep track of while serializing or deserializing.</p>



<p class="wp-block-paragraph">One such lookup that is being hammered pretty hard during serialization is for checking if we need to output the type manifest for the object that is about to be written.</p>



<p class="wp-block-paragraph">The type manifest should only be written once per session and then it should instead output an identifier to the already written manifest.</p>



<p class="wp-block-paragraph">This was originally done using a <code>Dictionary</code>.</p>



<p class="wp-block-paragraph">There are two things going on here, first we need to allocate this dictionary object for each session, as it keeps track of types per session, and we need to perform lookups against it.</p>



<p class="wp-block-paragraph">Both of those operations are a bit costly, and most messages that we want to serialize are simple POCO’s with a few primitive properties only.</p>



<p class="wp-block-paragraph">Do we really need to allocate and use this dictionary even if there only will be a single type in it most of the times?</p>



<p class="wp-block-paragraph">No, we can simply cheat and allocate it later.<br>Like this:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>class</code><code>FastTypeUShortDictionary</code><code>{</code><code>&nbsp;&nbsp;</code><code>private</code><code>int</code><code>_length; </code><code>//this keeps track on how many types have been added</code><code>&nbsp;&nbsp;</code><code>private</code><code>Type _firstType; </code><code>//at first, just just set this member field</code><code>&nbsp;&nbsp;</code><code>private</code><code>Dictionary&lt;Type, </code><code>ushort</code><code>&gt; _all; </code><code>//this is only allocated once there are two types</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The lookup will have 0 to n entries.<br>When there are 0 entries, we know there is nothing in it, so there are no allocations and any lookup will just return directly.<br>When there is 1 entry, the <code>_firstType</code> is set, so any lookup just compares the lookup type with the <code>_firstType</code> field.. still no allocations or hash lookups.<br>Only once we add a second type to the lookup, we will fallback and allocate the dictionary.</p>



<p class="wp-block-paragraph">This save us a lot of allocations and heavy hashing lookups as most types are just a single user type and a few primitives.</p>



<h2 class="wp-block-heading">Boxing, Unboxing and Virtual calls</h2>



<p class="wp-block-paragraph">As you might have seen already, the interface of the <code>ValueSerializer</code> type contains methods like <code>abstract object Read(...)</code> and <code>abstract void Write(..., object value,...)</code></p>



<p class="wp-block-paragraph">This causes boxing to occur for any value type being written or read.<br>I was skeptical that there would be any good solution to this due to the shape of the value serializer type that I defined very early on in the project.</p>



<p class="wp-block-paragraph">Szymon however figured out that as we already do code generation for complex types, we could just as well let the value serializer join the code generation process.</p>



<p class="wp-block-paragraph">He introduced the idea of <code>EmitWriter</code> and <code>EmitReader</code> into the value serializer.<br>This allows us to have typed implementations for each primitive and let the value serializer hook into the code generation process to inject the correct code to read and write the primitive, without calling any virtual method and without boxing.</p>



<p class="wp-block-paragraph">We let the value serializer emit its code using an <code>ICompiler</code> abstraction, like so:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>public</code><code>sealed</code><code>override</code><code>void</code><code>EmitWriteValue(ICompiler&lt;ObjectWriter&gt; c, </code><code>int</code><code>stream, </code><code>int</code><code>fieldValue, </code><code>int</code><code>session)</code><code>{</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>var</code><code>byteArray = c.GetVariable&lt;</code><code>byte</code><code>[]&gt;;(DefaultCodeGenerator.PreallocatedByteBuffer);</code><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><code>c.EmitStaticCall(_write, stream, fieldValue, byteArray);</code><code>}</code></td></tr></tbody></table></figure>



<h2 class="wp-block-heading">Fast creation of empty objects</h2>



<p class="wp-block-paragraph">Wire relies on the old <code>FormatterServices.GetUninitializedObject(type)</code> in order to create empty instances of objects, this is because all types do not have a default constructor, and, we can’t know if the constructor has side effects or not.</p>



<p class="wp-block-paragraph">But it turns out that calling a constructor is actually faster, the problem is that we need to know if it has side-effects or not.</p>



<p class="wp-block-paragraph">You can however extract this information:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><code>var</code><code>defaultCtor = type.GetTypeInfo().GetConstructor(</code><code>new</code><code>Type[] {});</code><code>var</code><code>il = defaultCtor?.GetMethodBody()?.GetILAsByteArray();</code><code>var</code><code>sideEffectFreeCtor = il != </code><code>null</code><code>&amp;&amp; il.Length &lt;= 8; </code><code>//this is the size of an empty ctor</code><code>if</code><code>(sideEffectFreeCtor)</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">By extracting the constructor method body as IL byte code, and then just checking if it is 8 bytes (or less) then we know it is an empty constructor, and thus side effect free.</p>



<p class="wp-block-paragraph">There are of-course a lot of other optimizations and interesting things going on in Wire, but at least this post give some insight into what and how we solved the main issues we experienced while building it.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2016/08/16/wire-writing-one-of-the-fastest-net-serializers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Genetic Programming: Evolution of Mona Lisa</title>
		<link>https://www.rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/</link>
					<comments>https://www.rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/#respond</comments>
		
		<dc:creator><![CDATA[Roger Johansson]]></dc:creator>
		<pubDate>Sun, 07 Dec 2008 09:01:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://www.rogeralsing.com/?p=15</guid>

					<description><![CDATA[This weekend I decided to play around a bit with genetic programming and put evolution to the test, the test of fine art 🙂 I created a small program that keeps a string of DNA for polygon rendering.The procedure of the program is quite simple: Now to the interesting part: Could&#160;you&#160;paint a replica of the [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This weekend I decided to play around a bit with genetic programming and put evolution to the test, the test of fine art <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph">I created a small program that keeps a string of DNA for polygon rendering.<br>The procedure of the program is quite simple:</p>



<ul class="wp-block-list">
<li>Setup a random DNA string&nbsp; (application start)</li>
</ul>



<ol class="wp-block-list">
<li>Copy the current DNA sequence and mutate it slightly</li>



<li>Use the new DNA to render polygons onto a canvas</li>



<li>Compare the canvas to the source image</li>



<li>If&nbsp;the new painting looks more like the source image than the previous<br>painting did, then&nbsp;overwrite the current DNA with the new DNA</li>



<li>Repeat from 1</li>
</ol>



<p class="wp-block-paragraph">Now to the interesting part:</p>



<p class="wp-block-paragraph"><strong>Could&nbsp;you&nbsp;paint a replica of the Mona Lisa using only 50 semi transparent polygons?</strong></p>



<p class="wp-block-paragraph">That is the challenge&nbsp;I&nbsp;decided&nbsp;to put my&nbsp;application up to.</p>



<p class="wp-block-paragraph">The image below is the result of that test:<br>The number below each image is the number of generations it took to reach that specific painting.</p>



<figure class="wp-block-image"><img decoding="async" src="https://rogerjohansson.blog/wp-content/uploads/2008/12/evolutionofmonalisa1.gif?w=782" alt="evolutionofmonalisa1" class="wp-image-418" title="evolutionofmonalisa1"/></figure>



<p class="wp-block-paragraph">So what do you think?</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
