It depends on how many items stacks it takes before the game engine can't effectively handle it. I'll reiterate that any item with a script attached will
never stack inside of a container, which is the source of the problem. It makes perfect sense why this happens, long lists take more time to process than short lists, and take up more memory etc.
This
is limited to shipments, unless you have lots of other scripted items, or items with hidden metadata that might stack weird. It is completely unfounded to say that a totally inert item, like a piece of food or bit of normal scrap or whatever has any more impact when you have 1 item or 1 million items in a container, there is no difference between these two cases in memory other than a stack size variable being different.
This is easy to test yourself; select a container in the console and spam this command a bunch until you have millions of components:
additem 248aaf 1000
For good measure, spawn in millions of crops too, e.g. enter:
help "crops" 4 flst
(to find Sim Settlement's crop list), then enter
additem xx004f31 32000 (adjusting xx with whatever Sim Settlement's load order ID is)
Spam that a hundred times too. You'll notice that there is absolutely no performance impact from doing this. Try the same thing with shipments, however, and you'll probably crash your game.
There are some exceptions to this, for example if you pick up some ammo with ownership data on it saying it belongs to some faction or another, this ammo will form a different stack in a container from the rest of your unowned ammo. So, you might have a stack of 20,000 totally normal fusion cells, and a second stack of 400 fusion cells which were originally stolen from the Brotherhood, but the inventory interface abstracts this away so you can't readily tell. Other "hidden" stacks would include persistent references, moddable items where object mod data might be stored in a different order internally (like, the sights are in the mod data list after the muzzle brake on one item and reversed on the other or whatever, but all the mods are the same so it looks like it stacks), items that had extra keyword data added to them by a script, and probably some other things I don't know about or can't think of.
This also means that if you spawn in 1,000,000 items in exactly the same way, and they're the same base item type, the base item does not have an associated script, and they aren't coming from a leveled list that might be adding metadata to the item, they
will all go into the same stack, and cannot cause performance issues. This applies to, for example, any item spawned by the vanilla surplus system, or by my mod, Uncapped Settlement Surplus.
I will note that the game
can have issues when stack sizes exceed 32768, because Bethesda can't seem to decide if item stacks should behave as signed shorts, unsigned shorts or unsigned ints. From experience, it seems that the console uses signed shorts, the inventory interface and most Papyrus functions (the native C++ code, anyway) use unsigned shorts, and containers use unsigned ints. For example, if you try moving exactly 65537 items in one go using the container interface or Papyrus's RemoveItem function, it'll cause a variable overflow and only 1 item will be moved, the other 65536 items being voided. This is an unrelated issue, however, and not one that can cause crashes.
On the topic of the last paragraph, I realize that there are some functions in my Logistics Station mod I'm going to need to rewrite slightly to take this into account, since some of the current functions (currently) can potentially cause item loss when you have very large item stacks. That's easy to do, but I hadn't ever considered it before.
Update:
Here's my UFO4P report about the ShipmentScript issue, in case anyone is curious. That should keep the most common source of this issue from cropping up, provided that my proposed fix is integrated, and users have UFO4P.