-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2146c92
commit c25bd00
Showing
4 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
17 changes: 16 additions & 1 deletion
17
blog/division-is-hard-but-it-does-not-have-to-be/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,36 @@ | |
<copyright>Alisa Sireneva, CC BY</copyright> | ||
<managingEditor>[email protected] (Alisa Sireneva)</managingEditor> | ||
<webMaster>[email protected] (Alisa Sireneva)</webMaster> | ||
<lastBuildDate>Fri, 23 Aug 2024 09:15:10 GMT</lastBuildDate> | ||
<lastBuildDate>Sat, 24 Aug 2024 10:34:36 GMT</lastBuildDate> | ||
<docs>https://www.rssboard.org/rss-specification</docs> | ||
<ttl>60</ttl> | ||
<atom:link href="https://purplesyringa.moe/blog/feed.rss" rel="self" type="application/rss+xml" /> | ||
|
||
<item> | ||
<title>Division is hard, but it doesn't have to be</title> | ||
<link>https://purplesyringa.moe/blog/./division-is-hard-but-it-does-not-have-to-be/</link> | ||
<description>Developers don’t usually divide numbers all the time, but hashmaps often need to compute remainders modulo a prime. Hashmaps are really common, so fast division is useful. | ||
For instance, rolling hashes might compute u128 % u64 with a fixed divisor. Compilers just drop the ball here: | ||
fn modulo(n: u128) -> u64 { | ||
(n % 0xffffffffffffffc5) as u64 | ||
} | ||
|
||
modulo: | ||
push rax | ||
mov rdx, -59 | ||
xor ecx, ecx | ||
call qword ptr [rip + __umodti3@GOTPCREL] | ||
pop rcx | ||
ret | ||
|
||
__umodti3 is a generic long division implementation, and it’s slow and ugly. | ||
I prefer my code the opposite of slow and ugly.</description> | ||
<author>[email protected] (Alisa Sireneva)</author> | ||
|
||
<guid>https://purplesyringa.moe/blog/./division-is-hard-but-it-does-not-have-to-be/</guid> | ||
<pubDate>Sat, 24 Aug 2024 00:00:00 GMT</pubDate> | ||
</item> | ||
|
||
<item> | ||
<title>I sped up serde_json strings by 20%</title> | ||
<link>https://purplesyringa.moe/blog/./i-sped-up-serde-json-strings-by-20-percent/</link> | ||
|
Oops, something went wrong.