You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I I made a version in swift that runs in ~ 1.7 seconds on a mac studio (the best time observed was 1.633).
The idea is more or less the same as in the other solutions
mmap the file
split into blocks per core, align to newlines
run each block on a core, parse the name first, then the number
a. while parsing the name, accumulate the hash for the hashtable as well
b. while parsing, safe the first 8 bytes of the name, since a lot of names are short, we can implement equality for these by a single compare
c. while parsing the number, save it as int, convert it to float, and divide it by 10 later
use a custom hash table, which can use the predefined hash and expose the index, to save some lookups
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I I made a version in swift that runs in ~ 1.7 seconds on a mac studio (the best time observed was 1.633).
The idea is more or less the same as in the other solutions
a. while parsing the name, accumulate the hash for the hashtable as well
b. while parsing, safe the first 8 bytes of the name, since a lot of names are short, we can implement equality for these by a single compare
c. while parsing the number, save it as int, convert it to float, and divide it by 10 later
the code is available on https://github.com/pfy/1brc/tree/main
Beta Was this translation helpful? Give feedback.
All reactions