What exactly do the 'allow-discards' and 'root_trim' Linux parameters do?

From my understanding the boot parameter root_trim=yes is Gentoo specific. Within genkernel there is a script which looks for the parameter and sets the option --allow-discards with cryptsetup (see their git repository). Furthermore I found many reports of Ubuntu or Debian users which said that it worked without the root_trim parameter. I also found no lines in Ubuntus update-initramfs script.

So all in all it is no boot parameter, but more a parameter to cryptsetup. The documentation of --allow-discards can be found in the manpage of cryptsetup(8):

--allow-discards
Allow using of discards (TRIM) requests for device. This option is only relevant for create, luksOpen or loopaesOpen.

WARNING: Assess the specific security risks carefully before enabling this option. For example, allowing discards on encrypted devices may lead to the leak of information about the ciphertext device (filesystem type, used space etc.) if the discarded blocks can be located easily on the device later.

Kernel version 3.1 or more recent is required. For older versions is the option ignored.

Based on this blog on TRIM & dm-crypt, TRIM is operation where upper layer (e.g. filesystem) informs the device which sectors are no longer used (do not contain valid data anymore) and that the device does not need to keep that data content.

In Linux terminology is this operation called discard. In the SCSI world it's be referred to as the UNMAP command.

The discard operation can be used for two purposes: thin Provisioning (informs that data area can be returned to allocation pool) and for SSD operation optimization.

Discards is most useful for SSD optimization since the internal architecture uses larger blocks than sectors and that the blocks must be erased before a write operation can be performed. Information about sectors which do not need to keep data is very useful since the filesystem would be able to more effectively organize blocks in such a way that data fragmentation is minimized and also the disk lifetime would increase.