Zyle Moore
06/08/2025, 9:43 PMBuffer
? (200MB+)Zyle Moore
06/09/2025, 2:01 AMZyle Moore
06/09/2025, 5:19 AMFilipp Zhinkin
06/09/2025, 1:04 PMSystemFileSystem
and for JS it's indeed tremendously slow and could be improved.
But the SystemFileSystem
is not supported for browser.Zyle Moore
06/10/2025, 2:06 AM<input type="file">
. It has an onChange
listener that attaches a FileReader
. The FileReader
has an onLoad
event that reads the file as an ArrayBuffer
. After that, I make an Int8Array(ArrayBuffer)
to get a plain ByteArray
. Then, as a sanity check, I actually iterate through the 249MB file, and xor
every byte with the last. All of that is the fast part.Zyle Moore
06/10/2025, 2:11 AMByteArray
to a ByteString
, and perform the same xor
test. Again, still pretty fast.Zyle Moore
06/10/2025, 2:38 AMByteString
, it takes about 80 seconds. Iterating over every byte, milliseconds. It's a custom format, so I'm sure it's something I'm doing, but running the same code on JVM is like, immediately faster in all ways.Zyle Moore
06/10/2025, 2:41 AM4387994, 50494, 869688, 3467813, 1m 20.358s, 457ms, 6.555s, 5.44s, 22.593s, 0s, 0s
• 4,387,994 4-byte inline strings
• 50,494 4-byte inline ints
• 869,688 different 4-byte inline ints
• 3,467,813 2-byte inline shorts
• 1m20s total time to read 4,387,994 (first)
• 6.555s total time to read 869,688 (third)
• 5.44s total time to read a different group of inline ints
• 22.593s total time to read 3,467,813 (fourth)Zyle Moore
06/10/2025, 2:49 AM4387994, 50494, 869688, 3467813, 1.650348681s, 11.886447ms, 172.236873ms, 304.934099ms, 677.563268ms, 30.814us, 3.202us
Zyle Moore
06/11/2025, 1:47 AMTypedArraySpeciesConstructor
, coming from source.readTo
calls. Gonna try making an implementation that doesn't depend on readTo
Filipp Zhinkin
06/11/2025, 2:54 PMZyle Moore
06/12/2025, 5:37 AMZyle Moore
06/12/2025, 6:25 PM.toInt
methods for the primitives fill the remaining upper bits with the sign bits. Made OR
ing the values require a mask to get the correct values. Additionally, I still needed the stream-like interaction, reading from the first bit to the last in order. But I had to effectively split up this very long ByteString into smaller chunks at certain points, and readTo
would make a copy. So I tried to figure something out without using readTo
or use a copy.