https://stackoverflow.com/questions/33051108/how-to-get-around-the-linux-too-many-arguments-limit/33278482

> I have to pass 256Kb of text as an argument to the "aws sqs"

what, uhhh, what

> MAX_ARG_STRLEN is defined as 32 times the page size in linux/include/uapi/linux/binfmts.h:
> The default page size is 4 KB so you cannot pass arguments longer than 128 KB.
> I modified linux/include/uapi/linux/binfmts.h to #define MAX_ARG_STRLEN (PAGE_SIZE * 64), recompiled my kernel and now your code produces

casually patching the kernel to send a quarter megabyte as a *single* argument oh my god i'm laughing hard
@navi well in the early rust for Linux days we hit this limit with the passing kconfig options to rustc. Fun times

@kloenk @navi Back when 128 kB was the limit for argv+envp, Google was hitting it too because they passed all the configuration for their whole software stack on the command line as --long-option=value switches.

Their solution? Compress the command line. So every binary started by ungzipping argv[1] and parsing it to get the configuration.

The person explaining this to me saw my horrified face, and said with the perfect Hide The Pain Harold smile: "a series of individually completely rational and reasonable decisions led to this." and I have been thinking a lot about it since.

@ska @kloenk @navi
I love one of the first rational decisions here: command-line arguments in scripts should be long-form to minimize reader confusion. Things go off the rails well before you hit 128kB of args though. You need to throw that in a config file or something, folks.

@c0dec0dec0de @kloenk @navi Actually, *that* particular decision made sense: when you have a huge software stack with configuration switches, you have to use long options because you just don't have enough characters for short options. And when you have a cluster manager running a command line on thousands of machines, you don't want to have to copy a config file, it's good to have the config on the command line.

The questionable decisions were upstream (is it good to have a whole software stack with configuration switches in every binary? hmmm) and downstream (what to do if we hit the command line limit), but *that one* was sound. 😅

@ska @c0dec0dec0de @kloenk

i would honestly take the configuration from stdin at that point, and it can even look similar to the bazillion flags in a script by using here-doc

wouldn't work if they need stdin for something else, but i kinda doubt that a program that has this many flags actually uses stdin directly
@[email protected] @c0dec0dec0de @ska @kloenk if it needs stdin also and "compressing argv with gzip that the binary begins by uncompressing" is a reasonable option, wouldn't it also be equally reasonable to just pass the config in an extra file descriptor, since you're already patching the binary to accept arcane configuration hacks?

@sodiboo @navi @c0dec0dec0de @kloenk Remember the context: it's a cluster manager that needs to execute the same program with the same config on N machines, so it sends a command line to local agents.

Anything that sounds reasonable *locally*, such as reading from a file descriptor, omits the fact that now you need to transfer the config to the agent, and the agent has to pass the file descriptor to the program, etc.

I understand why the whole system was designed the way it was. As the person said, every step was rational and reasonable (more or less). The issue is that, contrary to their habits, they did not reconsider their design when they found it could not scale.

@ska @sodiboo @navi @kloenk and this necessarily predates k8s mechanisms like ConfigMaps that become a file in the local context before the local program actually runs
@c0dec0dec0de @sodiboo @navi @kloenk Absolutely. And it is likely that when k8s came out, Googlers looked at it and what it was supposed to do and at what scale, and thought: "Haha. Cute."
@ska @c0dec0dec0de @sodiboo @navi @kloenk uh what? K8s originated at Google. It was written by former Borg devs

@fraggle @c0dec0dec0de @sodiboo @navi @kloenk Oh was it? Good to know, thanks.

It would have been great if these former Borg devs had learned a bit more from the experience about the value of simplicity 😜