ultimate storage hack

a year ago by einfach_orangensaft to c/programmer_humor

MTK 167 points a year ago

If you have a tub full of water and a take a sip, you still have a tub full of water. Therefore only drink in small sips and you will have infinite water.

Water shortage is a scam.

path: 0 16984635, hotness: undefined, score: 167, children: 5
Aux 15 points a year ago

There is a water shortage?

path: 0 16984635 16986471, hotness: undefined, score: 15, children: 3
MTK 22 points a year ago

Exactly!

path: 0 16984635 16986471 16986550, hotness: undefined, score: 22, children: 0
Feyter 7 points a year ago

Out of context, but this video showing the amount of freshwater on the planet in perspective was eye opening for me... I see water availability different since.

https://youtu.be/b3_Abb2Vqnc

path: 0 16984635 16986471 16988914, hotness: undefined, score: 7, children: 1
rickyrigatoni 5 points a year ago

Don't worry, global warming is desalinating the water so it will all be fresh in time πŸ™

path: 0 16984635 16986471 16988914 16993665, hotness: undefined, score: 5, children: 0
Kiuyn 6 points a year ago
path: 0 16984635 17008001, hotness: undefined, score: 6, children: 0
wizzim 116 points a year ago

Awesome idea. In base 64 to deal with all the funky characters.

It will be really nice to browse this filesystem...

path: 0 16981873, hotness: undefined, score: 116, children: 2
Aurenkin 88 points a year ago

The design is very human

path: 0 16981873 16982224, hotness: undefined, score: 88, children: 0
CorvidCawder 10 points a year ago path: 0 16981873 16983857, hotness: undefined, score: 10, children: 0
lemon 92 points a year ago

Broke: file names have a max character length.

Woke: split b64-encoded data into numbered parts and add .part-1..n suffix to each file name.

path: 0 16982169, hotness: undefined, score: 92, children: 7
tetris11 16 points a year ago

each file is minimum 4kb

(base64.length/max_character) * min_filesize < actual_file_size

For this to pay off

path: 0 16982169 16983691, hotness: undefined, score: 16, children: 4
Venator 2 points a year ago

Just use folders instead 😏

path: 0 16982169 16983691 17044222, hotness: undefined, score: 2, children: 0
lord_ryvan 2 points a year ago

each file is minimum 4kb

$ touch empty_file
$ ls -l
total 8
-rw-rw-r-- 1 user group 0 may 14 20:13 empty_file
$ wc -c empty_file 
0 empty_file

Huh?

path: 0 16982169 16983691 17050892, hotness: undefined, score: 2, children: 2
tetris11 1 point a year ago

Oh, I'm thinking folders aren't I. Doy....

path: 0 16982169 16983691 17050892 17051860, hotness: undefined, score: 1, children: 1
lord_ryvan 2 points a year ago

It seems those are 4 KiB on Linux, interesting to know.

path: 0 16982169 16983691 17050892 17051860 17509657, hotness: undefined, score: 2, children: 0
mmddmm 10 points a year ago

I'd go with a prefix, so it's ls-friendly.

path: 0 16982169 16987319, hotness: undefined, score: 10, children: 0
psud 2 points a year ago

Browse your own machine as if it's under alt.film.binaries but more so

path: 0 16982169 16994547, hotness: undefined, score: 2, children: 0
Thorry84 81 points a year ago

It's all fun and games until your computer turns into a black hole because there is too much information in too little of a volume.

path: 0 16983803, hotness: undefined, score: 81, children: 6
proti 41 points a year ago

Even better! According to no hiding theorem, you can't destroy information. With black holes you maybe possibly could be able to recover the data as it leaks through the Hawking radiation.
Perfect for long term storage

path: 0 16983803 16984307, hotness: undefined, score: 41, children: 5
Klear 35 points a year ago

Can't wait to hear news about a major site leaking user passwords through hawking radiation.

path: 0 16983803 16984307 16986642, hotness: undefined, score: 35, children: 1
einfach_orangensaft 8 points a year ago

i love this comment

path: 0 16983803 16984307 16986642 16990256, hotness: undefined, score: 8, children: 0
mmddmm 10 points a year ago

Really-long term storage :)

path: 0 16983803 16984307 16987289, hotness: undefined, score: 10, children: 2
limerod 1 point a year ago

Longer than your lifespan, too.

path: 0 16983803 16984307 16987289 16997118, hotness: undefined, score: 1, children: 1
mmddmm 1 point a year ago

Longer than the life span of the most long-lived star. By orders of magnitude.

path: 0 16983803 16984307 16987289 16997118 16997197, hotness: undefined, score: 1, children: 0
kryptonianCodeMonkey 59 points a year ago

I had a manager once tell me during a casual conversation with complete sincerity that one day with advancements in compression algorithms we could get any file down to a single bit. I really didn't know what to say to that level of absurdity. I just nodded.

path: 0 16997272, hotness: undefined, score: 59, children: 14
friendlymessage 26 points a year ago

That's the kind of manager that also tells you that you just lack creativity and vision if you tell them that it's not possible. They also post regularly on LinkedIn

path: 0 16997272 16999356, hotness: undefined, score: 26, children: 0
SpaceCadet 12 points a year ago

You can give me any file, and I can create a compression algorithm that reduces it to 1 bit. (*)

spoiler

(*) No guarantees about the size of the decompression algorithm or its efficacy on other files

path: 0 16997272 17001656, hotness: undefined, score: 12, children: 1
lord_ryvan 1 point a year ago

Here's a simple command to turn any file into a single b!

echo a > $file_name
path: 0 16997272 17001656 17050916, hotness: undefined, score: 1, children: 0
einfach_orangensaft 10 points a year ago

u can have everthing in a single bit, if the decompressor includes the whole universe

path: 0 16997272 16999338, hotness: undefined, score: 10, children: 0
pressanykeynow 9 points a year ago

Well he's not wrong. The decompression would be a problem though.

path: 0 16997272 17014187, hotness: undefined, score: 9, children: 1
groet 7 points a year ago

Yeah with lossy compression the future is today!

path: 0 16997272 17014187 17021076, hotness: undefined, score: 7, children: 0
schnurrito 9 points a year ago path: 0 16997272 16998973, hotness: undefined, score: 9, children: 0
Valmond 8 points a year ago

Send him your work: 1 (or 0 ofc)

path: 0 16997272 16999309, hotness: undefined, score: 8, children: 0
bluemellophone 5 points a year ago

That’s precisely when you bet on it.

path: 0 16997272 16997353, hotness: undefined, score: 5, children: 0
calcopiritus 4 points a year ago

Just make a file system that maps each file name to 2 files. The 0 file and the 1 file.

Now with just a filename and 1 bit, you can have any file! The file is just 1 bit. It's the filesystems that needs more than that.

path: 0 16997272 16998943, hotness: undefined, score: 4, children: 0
Randelung 3 points a year ago

It's an interesting question, though. How far CAN you compress? At some point you've extracted every information contained and increased the density to a maximum amount - but what is that density?

path: 0 16997272 17001285, hotness: undefined, score: 3, children: 2
Couldbealeotard 3 points a year ago

I think by the time we reach some future extreme of data density, it will be in a method of storage beyond our current understanding. It will be measured in coordinates or atoms or fractions of a dimension that we nullify.

path: 0 16997272 17001285 17002136, hotness: undefined, score: 3, children: 0
maxwellfire 2 points a year ago

This is a really good question!

I believe the general answer is, until the compressed file is indistinguishable from randomness. At that point there is no more redundant information left to compress. Like you said, the 'information content' of a message can be measured.

(Note that there are ways to get a file to look like randomness that don't compress it)

path: 0 16997272 17001285 17014020, hotness: undefined, score: 2, children: 0
VineGram 3 points a year ago

Maybe they also believe themselves to be father of computing

path: 0 16997272 17078022, hotness: undefined, score: 3, children: 0
JamonBear 51 points a year ago path: 0 16998309, hotness: undefined, score: 51, children: 5
nibbler 10 points a year ago

that's awesome! I'm just migrating all my data to Ο€fs. finally mathematics is put to a proper use!

path: 0 16998309 17000218, hotness: undefined, score: 10, children: 0
needanke 7 points a year ago

Finally someone uses the fact that compute time is so much cheaper than storage!

path: 0 16998309 17013288, hotness: undefined, score: 7, children: 0
And009 5 points a year ago

Breakthrough vibes

path: 0 16998309 17000394, hotness: undefined, score: 5, children: 0
qnvx 3 points a year ago
path: 0 16998309 16999270, hotness: undefined, score: 3, children: 0
groet 2 points a year ago

Easy, just replace each byte of data with multiple bytes of metadata. I see no problem here

path: 0 16998309 17021071, hotness: undefined, score: 2, children: 0
iknowitwheniseeit 43 points a year ago path: 0 16985092, hotness: undefined, score: 43, children: 7
4grams 9 points a year ago

That story is immediately what came to mind.

path: 0 16985092 16986961, hotness: undefined, score: 9, children: 0
QuazarOmega 6 points a year ago

This was too damn funny for what I expected it to be

path: 0 16985092 16989204, hotness: undefined, score: 6, children: 0
ulterno 5 points a year ago

Nice stuff.

I got sold on the :

EOF does not consume less space than "5"

because, even though the space taken by the filesystem is the fault of the filesystem, one needs to consider the minimum information requirements of stating starts and ends of files, specially when stuff is split into multiple files.

I would have actually considered the file size information as part of the file size instead (for both the input and the output) because, for a binary file, which can include a string of bits which might match an EOF, causing a falsely ended file, would be a problem. And as such, the contestant didn't go checking for character == EOF, but used the function that truly tells whether the end of file is reached, which would, then be using the file system's file size information.

Since the input file was a 3145728 bytes and the output files would have been smaller than that, I would go with 22 bits to store the file size information. This would be in favour of the contestant as:

  1. That would be the minimum (hyh) number of bits required to store the file size, making it as easy as possible for the contestant to make more files
  2. You could actually go with 2 bits, if you predefine MiB to be the unit, but that would make it harder for the contestant, because they will be unable to present file sizes less than 1 MiB, and would have to increase the file size information bits

On the other hand, had the contestant decided to break the file between bits (instead at byte ends), instead of bytes (which, from the code, I think they didn't) the file size information would require an additional 3 bits.


Now, using this logic, if I check the result:

From the result claimed by the contestant, there were 44 extra bytes (352 bits) remaining.

+ 22 bits for the input file size information - 22*219 bits for the output file size information because 219 files

so the contestant succeeds by 352 + 22 βˆ’ (22 Γ— 219) = βˆ’4444 bits. In other words, fails by 4444 bits.

Now of course, the output file size information might be representable in a smaller number of bits, but to calculate that, I would require downloading the file (which I am not in the mood for.
And in that case, you would require additional information to tell the file size bits. So;

  • 5 bits for the number 22 in the input
  • 5 bits for the size of the file size information (I am feeling this won't give significant gains) and rest of the bits as stated in the first 5 bits, as the file size bits
    • you waste bits for every file size requiring more than 16 bits to store the file size information
    • it is possible to get a net gain with this, as qalc says, log(3145728 / 219, 2) = (ln(1048576) βˆ’ ln(73)) / ln(2) β‰ˆ 13.81017544

But even then, you have 352 + 5 + 22 βˆ’ (5 + (14 Γ— 219)) = βˆ’2692 for the best case scenario in which all output file sizes manage to be under 14 bits of file size informations. More realistically, it would be something around 352 + 5 + 22 βˆ’ ((5 + 14) Γ— 219) = βˆ’3782 because you will the the 5 bits for every file, separately, with the 14 in this case, be a changing value for every file, giving a possibly smaller number.


If instead going with the naive 8 bit EOF that the offerer desired, well, going with 2 consecutive characters instead of a single one, seems doable. As long as you are able to find enough of said 2 characters.
After going on a little google search, I seem to think that in a 3MiB file, there would be either 47 or 383 (depending upon which of my formulae was correct) possible occurrences of the same 2 character combination. Well, you'd need to find the correct combination.

But of course, that's not exactly compression for a binary file, as I said before, as an EOF is not good enough.

path: 0 16985092 16992438, hotness: undefined, score: 5, children: 0
skisnow 4 points a year ago

I was sort of on Mike Goldman (the challenge giver)'s side until I saw the great point made at the end that the entire challenge was akin to a bar room bet; Goldman had always set it up as a kind of scam from the start and was clearly more than happy to take $100 from anyone who fell for it, and so should have taken responsibility when someone managed to meet the wording of his challenge.

path: 0 16985092 16997318, hotness: undefined, score: 4, children: 1
Cratermaker 3 points a year ago

Yeah, he was bamboozled as soon as he agreed to allow multiple separate files. The challenge was bs from the start, but he could have at least nailed it down with more explicit language and by forbidding any exceptions. I think it's kind of ironic that the instructions for a challenge related to different representations of information failed themselves to actually convey the intended information.

path: 0 16985092 16997318 16999774, hotness: undefined, score: 3, children: 0
MBM 1 point a year ago

Both people sound obnoxious lol

path: 0 16985092 17001749, hotness: undefined, score: 1, children: 0
Valmond 1 point a year ago

Nice read, thanks!

path: 0 16985092 16999303, hotness: undefined, score: 1, children: 0
Typewar 39 points a year ago

Reminds me of a project i stumbled upon the other day using various services like Google drive, Dropbox, cloudflare, discord for simultaneous remote storage. The goal was to use whatever service that has data to upload to, to store content there as a Filesystem.

I only remember discord being one of the weird ones where they would use base512 (or higher, I couldn't find the library) to encode the data. The thing with discord, is that you're limited by characters, and so the best way to store data in a compact way is to take advantage of whatever characters that are supported

path: 0 16982690, hotness: undefined, score: 39, children: 8
astrsk 41 points a year ago path: 0 16982690 16982994, hotness: undefined, score: 41, children: 0
ChairmanMeow 29 points a year ago

I remember a project where someone booted Linux off of Google Drive. Cursed on many levels.

path: 0 16982690 16984254, hotness: undefined, score: 29, children: 0
jjagaimo 14 points a year ago

"Harder Drive"

Store the data in pings that constantly get resent to keep the data in the internet

path: 0 16982690 16988667, hotness: undefined, score: 14, children: 2
fnrir 1 point a year ago path: 0 16982690 16988667 17002030, hotness: undefined, score: 1, children: 0
bitfucker 1 point a year ago

I was looking for this comment. I knew someone from Lemmy would have seen that

path: 0 16982690 16988667 17000962, hotness: undefined, score: 1, children: 0
psud 4 points a year ago

GmailFS was a thing

path: 0 16982690 16994563, hotness: undefined, score: 4, children: 0
kate 1 point a year ago path: 0 16982690 17096991, hotness: undefined, score: 1, children: 1
Typewar 1 point a year ago

Yep, that looks like it!

path: 0 16982690 17096991 17096992, hotness: undefined, score: 1, children: 0
Little8Lost 33 points a year ago

Stupid BUT: making the font in LibreOffice bigger saves space. so having 11 is readible but by changing the font size to like 500 it can save some mb per page
I dont know how it works, i just noticed it at some point

Edit: i think it was kb, not mb

path: 0 16986525, hotness: undefined, score: 33, children: 3
SkaveRat 18 points a year ago

per page

I mean, yes. obviously.

If you had 1000 bytes of text on 1 page before, you now have 1byte per page on 1000 pages afterwards

path: 0 16986525 16994756, hotness: undefined, score: 18, children: 0
Jankatarch 11 points a year ago

Have a macro that decreases all font size on opening and then increases all again before closing.

Follow me irl for more compression techniques.

path: 0 16986525 16997306, hotness: undefined, score: 11, children: 0
InFerNo 6 points a year ago

You could always diff the XML before and after to see what's causing it.

path: 0 16986525 16994029, hotness: undefined, score: 6, children: 0
Honytawk 32 points a year ago

Good luck with your 256 characters.

path: 0 17001141, hotness: undefined, score: 32, children: 6
SpaceCadet 32 points a year ago

When you run out of characters, you simply create another 0 byte file to encode the rest.

Check mate, storage manufacturers.

path: 0 17001141 17001619, hotness: undefined, score: 32, children: 1
PieMePlenty 14 points a year ago

File name file system! Looks like we broke the universe! Wait, why is my MFT so large?!

path: 0 17001141 17001619 17001702, hotness: undefined, score: 14, children: 0
barsoap 15 points a year ago

255, generally, because null termination. ZFS does 1023, the argument not being "people should have long filenames" but "unicode exists", ReiserFS 4032, Reiser4 3976. Not that anyone uses Reiser, any more. Also Linux' PATH_MAX of 4096 still applies. Though that's in the end just a POSIX define, I'm not sure whether that limit is actually enforced by open(2)... man page speaks of ENAMETOOLONG but doesn't give a maximum.

It's not like filesystems couldn't support it it's that FS people consider it pointless. ZFS does, in principle, support gigantic file metadata but using it would break use cases like having a separate vdev for your volume's metadata. What's the point of having (effectively) separate index drives when your data drives are empty.

path: 0 17001141 17001547, hotness: undefined, score: 15, children: 3
Brahvim 1 point a year ago

...Just asking, just asking: Why is the default FILENAME_MAX on Linux/glibc 4096?

path: 0 17001141 17001547 17007551, hotness: undefined, score: 1, children: 2
barsoap 2 points a year ago

Because PATH_MAX is? Also because it's a 4k page.

FILENAME_MAX is not safe to use for buffer allocations btw it could be INT_MAX.

path: 0 17001141 17001547 17007551 17013056, hotness: undefined, score: 2, children: 1
Brahvim 1 point a year ago

Thanks! Got an answer and not 200 downvotes. This is why I love Lemm-Lemm.

path: 0 17001141 17001547 17007551 17013056 17039717, hotness: undefined, score: 1, children: 0
anhkagi 29 points a year ago

this is actually a joke compression algorithm that compresses your data by one byte by appending it to the filename. (and you can execute it as many time as you want)

Too bad I can't remember the name.

path: 0 16982732, hotness: undefined, score: 29, children: 8
badcommandorfilename 42 points a year ago

path: 0 16982732 16982910, hotness: undefined, score: 42, children: 7
gnutrino 18 points a year ago

Obligatory "pi hasn't been proved to be normal"

path: 0 16982732 16982910 16983486, hotness: undefined, score: 18, children: 5
Sonotsugipaa 4 points a year ago

Relatable tbh

path: 0 16982732 16982910 16983486 16984682, hotness: undefined, score: 4, children: 1
SkaveRat 3 points a year ago

Pi being irrational and not normal makes it the most relatable number

path: 0 16982732 16982910 16983486 16984682 16994832, hotness: undefined, score: 3, children: 0
palordrolap 3 points a year ago

Oh, I guarantee that pi is 100% normal. Just not necessarily in the base you want it to be normal in.

path: 0 16982732 16982910 16983486 16985214, hotness: undefined, score: 3, children: 2
gnutrino 8 points a year ago

I don't know of a proof that pi is normal in any base (even non-integer bases) so I'd be interested to see on what basis you can guarantee it.

path: 0 16982732 16982910 16983486 16985214 16986377, hotness: undefined, score: 8, children: 1
lime 4 points a year ago path: 0 16982732 16982910 16983928, hotness: undefined, score: 4, children: 0
bstix 22 points a year ago

It's like that chip tune webpage where the entire track is encoded in the url.

path: 0 16994265, hotness: undefined, score: 22, children: 3
LemmyFeed 11 points a year ago

Link?

path: 0 16994265 16996039, hotness: undefined, score: 11, children: 2
skisnow 9 points a year ago

Are you trying to get rickrolled?

path: 0 16994265 16996039 16997195, hotness: undefined, score: 9, children: 0
PoolloverNathan 9 points a year ago path: 0 16994265 16996039 16998476, hotness: undefined, score: 9, children: 0
hades 16 points a year ago
path: 0 17000685, hotness: undefined, score: 16, children: 1
grrgyle 4 points a year ago

Ah memories. That was an interesting lesson.

path: 0 17000685 17001605, hotness: undefined, score: 4, children: 0
tatterdemalion 7 points a year ago path: 0 17015465, hotness: undefined, score: 7, children: 0
some_guy 1 point a year ago

Name all your files *.

path: 0 17017251, hotness: undefined, score: 1, children: 0
WorldsDumbestMan 1 point a year ago

Let me guess, over 30 years old.

path: 0 16998377, hotness: undefined, score: 1, children: 0
InnerScientist 1 point a year ago
path: 0 16984148, hotness: undefined, score: 1, children: 0
programmer_humor
programmer_humor

@programming.dev

login for more options
33631
2561
7551

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn't find it funny, you're banned. Ha-ha!... For real: do not use the community for "statements". There are other places for such content. Keep it chill and funny.

go to feed...