TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Using Uninitialized Memory for Fun and Profit (2008)

46 点作者 frontsideair超过 10 年前

6 条评论

userbinator超过 10 年前
Due to multilevel caches I doubt this would be so applicable to modern systems - the index-set representation takes several times more memory and naturally requires lots of random accesses, which are bad for caches. In some ways, it&#x27;s no longer a time-space tradeoff: smaller <i>is</i> faster.<p>Also, initialising the space doesn&#x27;t take so long; REP STOS on x86 is <i>fast</i> since it can write an entire cache line at once: <a href="http://ptspts.blogspot.ca/2014/10/on-speed-of-memset.html" rel="nofollow">http:&#x2F;&#x2F;ptspts.blogspot.ca&#x2F;2014&#x2F;10&#x2F;on-speed-of-memset.html</a>
评论 #8711242 未加载
评论 #8711930 未加载
gizmo686超过 10 年前
Python uses a similar trick in its internal allocater (pymalloc) [1]. Given a memory address, pymalloc determines if it controls it by computing what would be the base of the arena containing said address. It then finds the index of the arena (or trash) at a constant offset from the base. It then uses the index to check a vector of all the arenas that it controls.<p>[1]<a href="http://svn.python.org/projects/python/trunk/Misc/README.valgrind" rel="nofollow">http:&#x2F;&#x2F;svn.python.org&#x2F;projects&#x2F;python&#x2F;trunk&#x2F;Misc&#x2F;README.valg...</a>
crispweed超过 10 年前
Something in between traditional bit vectors and sparse sets is described here:<p><a href="http://upcoder.com/9/fast-resettable-flag-vector/" rel="nofollow">http:&#x2F;&#x2F;upcoder.com&#x2F;9&#x2F;fast-resettable-flag-vector&#x2F;</a><p>This is designed for a fast clear, but doesn&#x27;t actually have constant time clear, it&#x27;s just O(n) clear with very small (amortized) constant. It&#x27;s a bit more cache friendly, though, I think, and gave us some nice speedups in practice.
mannykannot超过 10 年前
I think I have seen this method used in a data structure called something like a &#x27;B.* set&#x27; or &#x27;B.* index&#x27;, but I can&#x27;t remember the exact name. Does anyone have a clue as to what I am (mis)remembering?<p>Update: I remembered that the algorithm had something to do with checking if an item is not in a set, which quickly led me to Bloom Filter - not particularly similar, as it turns out.
blt超过 10 年前
Ahhhh, I love hacks like this :) But it is super branchy; I would definitely profile before assuming it&#x27;s an improvement.
im3w1l超过 10 年前
Reading from uninitialized memory in C seems to be a bad idea:<p><a href="http://blog.frama-c.com/index.php?post/2013/03/13/indeterminate-undefined" rel="nofollow">http:&#x2F;&#x2F;blog.frama-c.com&#x2F;index.php?post&#x2F;2013&#x2F;03&#x2F;13&#x2F;indetermin...</a>
评论 #8711582 未加载
评论 #8711674 未加载
评论 #8711655 未加载
评论 #8711932 未加载