mirror of
https://github.com/Noratrieb/blog.git
synced 2026-01-14 12:35:00 +01:00
deploy: 51573c9e72
This commit is contained in:
parent
73d8f12885
commit
f9229ee20a
5 changed files with 24 additions and 2 deletions
|
|
@ -148,6 +148,11 @@ So if box stayed unique, people could also just pick up that crate as a dependen
|
||||||
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
||||||
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
||||||
don&rsquo;t think this can reasonable be changed.</p>
|
don&rsquo;t think this can reasonable be changed.</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>One thing was just pointed out to me after releasing the post: Mutation usually goes through <code>&amp;mut T</code> anyways, even when the value
|
||||||
|
is stored as a <code>Box&lt;T&gt;</code>. Therefore, all the guarantees of uniqueness are already present when mutating boxes, making the uniqueness
|
||||||
|
of box even less important.</p>
|
||||||
|
</blockquote>
|
||||||
<h1 id="noalias-noslow">noalias, noslow</h1>
|
<h1 id="noalias-noslow">noalias, noslow</h1>
|
||||||
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
||||||
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<!doctype html><html lang=en><head><title>Box Is a Unique Type :: nilstriebs blog</title><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="About better aliasing semantics for `Box`"><meta name=keywords content="box,noalias"><meta name=robots content="noodp"><link rel=canonical href=/posts/box-is-a-unique-type/><link rel=stylesheet href=/assets/style.css><link rel=apple-touch-icon href=/img/apple-touch-icon-192x192.png><link rel="shortcut icon" href=/img/favicon/orange.png><meta name=twitter:card content="summary"><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="og:title" content="Box Is a Unique Type"><meta property="og:description" content="About better aliasing semantics for `Box`"><meta property="og:url" content="/posts/box-is-a-unique-type/"><meta property="og:site_name" content="nilstriebs blog"><meta property="og:image" content="/img/favicon/orange.png"><meta property="og:image:width" content="2048"><meta property="og:image:height" content="1024"><meta property="article:published_time" content="2022-07-23 00:00:00 +0000 UTC"></head><body class=orange><div class="container center headings--one-size"><header class=header><div class=header__inner><div class=header__logo><a href=/><div class=logo>nilstriebs blog</div></a></div></div></header><div class=content><div class=post><h1 class=post-title><a href=/posts/box-is-a-unique-type/>Box Is a Unique Type</a></h1><div class=post-meta><span class=post-date>2022-07-23</span>
|
<!doctype html><html lang=en><head><title>Box Is a Unique Type :: nilstriebs blog</title><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="About better aliasing semantics for `Box`"><meta name=keywords content="box,noalias"><meta name=robots content="noodp"><link rel=canonical href=/posts/box-is-a-unique-type/><link rel=stylesheet href=/assets/style.css><link rel=apple-touch-icon href=/img/apple-touch-icon-192x192.png><link rel="shortcut icon" href=/img/favicon/orange.png><meta name=twitter:card content="summary"><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="og:title" content="Box Is a Unique Type"><meta property="og:description" content="About better aliasing semantics for `Box`"><meta property="og:url" content="/posts/box-is-a-unique-type/"><meta property="og:site_name" content="nilstriebs blog"><meta property="og:image" content="/img/favicon/orange.png"><meta property="og:image:width" content="2048"><meta property="og:image:height" content="1024"><meta property="article:published_time" content="2022-07-23 00:00:00 +0000 UTC"></head><body class=orange><div class="container center headings--one-size"><header class=header><div class=header__inner><div class=header__logo><a href=/><div class=logo>nilstriebs blog</div></a></div></div></header><div class=content><div class=post><h1 class=post-title><a href=/posts/box-is-a-unique-type/>Box Is a Unique Type</a></h1><div class=post-meta><span class=post-date>2022-07-23</span>
|
||||||
<span class=post-author>:: Nilstrieb</span>
|
<span class=post-author>:: Nilstrieb</span>
|
||||||
<span class=post-reading-time>:: 12 min read (2381 words)</span></div><span class=post-tags>#<a href=/tags/rust/>rust</a>
|
<span class=post-reading-time>:: 12 min read (2429 words)</span></div><span class=post-tags>#<a href=/tags/rust/>rust</a>
|
||||||
#<a href=/tags/unsafe-code/>unsafe code</a> </span><div class=post-content><div><p>We have all used <code>Box<T></code> before in our Rust code. It’s a glorious type, with great ergonomics
|
#<a href=/tags/unsafe-code/>unsafe code</a> </span><div class=post-content><div><p>We have all used <code>Box<T></code> before in our Rust code. It’s a glorious type, with great ergonomics
|
||||||
and flexibility. We can use it to put our values on the heap, but it can do even more
|
and flexibility. We can use it to put our values on the heap, but it can do even more
|
||||||
than that!</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rust data-lang=rust><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>Fields</span> {
|
than that!</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rust data-lang=rust><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>Fields</span> {
|
||||||
|
|
@ -114,7 +114,9 @@ provide an aliasable version of <code>Box<T></code>, which is used by the sel
|
||||||
So if box stayed unique, people could also just pick up that crate as a dependency and use the aliasable box from there instead of
|
So if box stayed unique, people could also just pick up that crate as a dependency and use the aliasable box from there instead of
|
||||||
having to write their own. Interestingly, this crate also provides a <code>Vec<T></code>, even though <code>Vec<T></code> can currently be aliased in practice and
|
having to write their own. Interestingly, this crate also provides a <code>Vec<T></code>, even though <code>Vec<T></code> can currently be aliased in practice and
|
||||||
in the current version of stacked borrows. just fine, although it’s also not clear whether we want to keep it like this, but I
|
in the current version of stacked borrows. just fine, although it’s also not clear whether we want to keep it like this, but I
|
||||||
don’t think this can reasonable be changed.</p><h1 id=noalias-noslow>noalias, noslow<a href=#noalias-noslow class=hanchor arialabel=Anchor>⌗</a></h1><p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn’t exist for fun, it’s something
|
don’t think this can reasonable be changed.</p><blockquote><p>One thing was just pointed out to me after releasing the post: Mutation usually goes through <code>&mut T</code> anyways, even when the value
|
||||||
|
is stored as a <code>Box<T></code>. Therefore, all the guarantees of uniqueness are already present when mutating boxes, making the uniqueness
|
||||||
|
of box even less important.</p></blockquote><h1 id=noalias-noslow>noalias, noslow<a href=#noalias-noslow class=hanchor arialabel=Anchor>⌗</a></h1><p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn’t exist for fun, it’s something
|
||||||
that can bring clear performance wins (for <code>noalias</code> on <code>&mut T</code>, those were measureable). So the only question remains:
|
that can bring clear performance wins (for <code>noalias</code> on <code>&mut T</code>, those were measureable). So the only question remains:
|
||||||
<strong>How much performance does <code>noalias</code> on <code>Box<T></code> give us now, and how many potential performance improvements could we get in the
|
<strong>How much performance does <code>noalias</code> on <code>Box<T></code> give us now, and how many potential performance improvements could we get in the
|
||||||
future?</strong> For the latter, there is no simple answer. For the former, there is. <code>rustc</code> has <a href=https://github.com/rust-lang/rust/pull/99527><em>no</em> performance improvements</a>
|
future?</strong> For the latter, there is no simple answer. For the former, there is. <code>rustc</code> has <a href=https://github.com/rust-lang/rust/pull/99527><em>no</em> performance improvements</a>
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,11 @@ So if box stayed unique, people could also just pick up that crate as a dependen
|
||||||
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
||||||
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
||||||
don&rsquo;t think this can reasonable be changed.</p>
|
don&rsquo;t think this can reasonable be changed.</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>One thing was just pointed out to me after releasing the post: Mutation usually goes through <code>&amp;mut T</code> anyways, even when the value
|
||||||
|
is stored as a <code>Box&lt;T&gt;</code>. Therefore, all the guarantees of uniqueness are already present when mutating boxes, making the uniqueness
|
||||||
|
of box even less important.</p>
|
||||||
|
</blockquote>
|
||||||
<h1 id="noalias-noslow">noalias, noslow</h1>
|
<h1 id="noalias-noslow">noalias, noslow</h1>
|
||||||
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
||||||
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,11 @@ So if box stayed unique, people could also just pick up that crate as a dependen
|
||||||
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
||||||
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
||||||
don&rsquo;t think this can reasonable be changed.</p>
|
don&rsquo;t think this can reasonable be changed.</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>One thing was just pointed out to me after releasing the post: Mutation usually goes through <code>&amp;mut T</code> anyways, even when the value
|
||||||
|
is stored as a <code>Box&lt;T&gt;</code>. Therefore, all the guarantees of uniqueness are already present when mutating boxes, making the uniqueness
|
||||||
|
of box even less important.</p>
|
||||||
|
</blockquote>
|
||||||
<h1 id="noalias-noslow">noalias, noslow</h1>
|
<h1 id="noalias-noslow">noalias, noslow</h1>
|
||||||
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
||||||
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,11 @@ So if box stayed unique, people could also just pick up that crate as a dependen
|
||||||
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
having to write their own. Interestingly, this crate also provides a <code>Vec&lt;T&gt;</code>, even though <code>Vec&lt;T&gt;</code> can currently be aliased in practice and
|
||||||
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
in the current version of stacked borrows. just fine, although it&rsquo;s also not clear whether we want to keep it like this, but I
|
||||||
don&rsquo;t think this can reasonable be changed.</p>
|
don&rsquo;t think this can reasonable be changed.</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>One thing was just pointed out to me after releasing the post: Mutation usually goes through <code>&amp;mut T</code> anyways, even when the value
|
||||||
|
is stored as a <code>Box&lt;T&gt;</code>. Therefore, all the guarantees of uniqueness are already present when mutating boxes, making the uniqueness
|
||||||
|
of box even less important.</p>
|
||||||
|
</blockquote>
|
||||||
<h1 id="noalias-noslow">noalias, noslow</h1>
|
<h1 id="noalias-noslow">noalias, noslow</h1>
|
||||||
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
<p>There is one clear potential benefit from this box behaviour: ✨Optimizations✨. <code>noalias</code> doesn&rsquo;t exist for fun, it&rsquo;s something
|
||||||
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
that can bring clear performance wins (for <code>noalias</code> on <code>&amp;mut T</code>, those were measureable). So the only question remains:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue