TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Memory Copy Hunting

136 pointsby polyrandalmost 2 years ago

8 comments

loegalmost 2 years ago
&gt; One particular issue we fixed a couple of times in TigerBeetle is replacing by-value with by-pointer loops:<p>I don&#x27;t know about other tools and places, but one nice thing about working at Facebook is the internal Infer linter tool[1] is generally good about producing warnings for &quot;this copy could be a ref instead&quot;[2] (in the majority C++ codebase) at code review time, without manually combing the LLVM IR for memcpys. (Internally, Infer is using several handwritten analyses on C++ AST.)<p>Reading further, it seems like they are essentially looking for the pattern where a memcpy call is generated with a large constant size parameter at compile time. Things of this nature <i>should</i> be somewhat easy to write a static analyzer pass for, if you&#x27;ve got an existing AST&#x2F;SSA level framework. I believe there is already an Infer pass for this for C++, but it might be a different internal analyzer.<p>[1]: <a href="https:&#x2F;&#x2F;fbinfer.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;fbinfer.com&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;infer&#x2F;blob&#x2F;main&#x2F;infer&#x2F;documentation&#x2F;issues&#x2F;PULSE_UNNECESSARY_COPY.md">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;infer&#x2F;blob&#x2F;main&#x2F;infer&#x2F;documentat...</a> (and related warnings, e.g., <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;infer&#x2F;blob&#x2F;main&#x2F;infer&#x2F;documentation&#x2F;issues&#x2F;PULSE_CONST_REFABLE.md">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;infer&#x2F;blob&#x2F;main&#x2F;infer&#x2F;documentat...</a> )
评论 #36879797 未加载
评论 #36878183 未加载
评论 #36884888 未加载
AndyKelleyalmost 2 years ago
Related: this pull request that was merged last night: <a href="https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;pull&#x2F;16558">https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;pull&#x2F;16558</a><p>Currently only enabled for debug builds of the compiler, but there&#x27;s talk there about making it a more general purpose tool for finding where the costly generic function instantations are.
packetlostalmost 2 years ago
Man, I want to work at TigerBeetle so bad. So much cool stuff comes out of that company, exactly the type of stuff that I love thinking about and working on.<p>On a semi-related note, if you want to look into compiler backends&#x2F;IRs, there&#x27;s QBE[0], which is far simpler than LLVM IR, but gets most of the point across<p>[0]: <a href="https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;</a>
eatonphilalmost 2 years ago
By the way, if you&#x27;re in the Amsterdam area next week, almost the whole TigerBeetle team will be there on Monday&#x2F;Tuesday.<p>We&#x27;ll be hosting a happy hour on Tuesday August 1st at 5pm. If you&#x27;d like to join, RSVP below and you&#x27;re invited! Among others, some friends from the Zig communities will be coming through, and a DuckDB developer or two may be there. :)<p><a href="https:&#x2F;&#x2F;tigerbeetle.com&#x2F;amsterdam23&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;tigerbeetle.com&#x2F;amsterdam23&#x2F;</a>
评论 #36880735 未加载
muizelaaralmost 2 years ago
I&#x27;ve also written something like this: <a href="https:&#x2F;&#x2F;github.com&#x2F;jrmuizel&#x2F;memcpy-find">https:&#x2F;&#x2F;github.com&#x2F;jrmuizel&#x2F;memcpy-find</a><p>It uses debug info to get a full stack including inline information which is especially helpful when running on Rust code.
smarx007almost 2 years ago
A bit off-topic, but would be good to read what TigerBeetle folks think of the tech behind the recently released FedNow.
JonChesterfieldalmost 2 years ago
This would be a bad thing.<p>It&#x27;s taking code written in terms of value semantics, copying stuff around, and replacing it with more efficient code that avoids the copy.<p>Doing that by improving the compiler is a win. Doing it by changing the source to be easier to compile is a loss. You&#x27;re trading readability for performance when instead you should fix the compiler and get both.
评论 #36878359 未加载
评论 #36878282 未加载
评论 #36880286 未加载
评论 #36878495 未加载
评论 #36887742 未加载
vientalmost 2 years ago
&gt; shaves off 300 bytes from the release binary<p>I wonder if it should be &quot;kilobytes&quot;, 300 bytes are nothing considering that fs block size is usually 4KB.