The N54 is almost a "bullet proof" engine. They were built with forged internals so the engine (I.e block & heads) will generally have 0 issues if maintained properly. But it is a "high performance" engine so IT MUST be maintained meticulously. (FYI the N54 is a 5 time "Engine of the year" award winner). There are 335i's hitting 6-700 #'s and the valve cover has never been removed- the N54 is that solid.
You will noticed that the big issues are NOT with the engine but with all the bits feeding the engine such as the fuel pump & water pump. This is why maintenance records are important because most have had the fuel pump replaced under warranty.
There are a few complaints with the turbos going out but this is almost always with modified cars that are driven hard and or raced.
Being BMW's these cars are simply more expensive to maintain. The parts are just twice as expensive as mass production cars. You must factor that part in, especially the walnut blasting, but an oil catch can & tier 1 fuel will help a lot with that. Many daily drivers have simply never had the vales cleaned. You need to verify you can access Walnut blasting in your area & the cost. ESPECIALLY if you, as you say, are planning on any serious upgrades. Carbon build up on valves is just a side effect of Direct Injection. I know cars with over 100k miles that have never had this done and run "fine". But the're also babied and never driven aggressively. Many ppl never realize they are missing 20 hp. But many performance shops will not touch you car until this has been done because none of the aftermarket parts will work to there full potential if the car isn't breathing properly.
The biggest issue with a car over 100k is just how many miles do YOU drive. The ENGINE will easily last 200k +, but how soon will you see that. 20k a year, no problem. 40 or more may be a problem.
Back to the maintenance. Please prepare for at least $1-2k your first year, especially if you can't verify that the fuel pump was replaced and that the 100k mile service wasn't completed. The 100k mile maintenance is paramount as everything (plugs, fuel filter, etc) were basically designed for 100k miles & ALL will need to be replaced, many requiring special tools. If you don't have those tools or are not mechanically inclined you may be looking at a money pit. And all this will need to be done before you start throwing performance parts at it and increase your power.
There is a reason these cars are called the "super cars" of the compact world. But "super cars" are notoriously moody. I like to say my 335i is like a high maintenance porn star girl friend. She looks great and will do anything you ask but she requires CONSTANT Love, Affection & MONEY, lol. So you better have a good job and big credit card!
If you don't look forward to being under your car on weekends or don't have a few grand laying around, a high mileage 335 is NOT your car. But your question was how long will the engine last. The answer is as long as you keep it maintained.
That all being said, after your initial $1-2k to get it back to 100%, you can hit the 450-500 #'s your talking about for a little over $1500 (not including exhaust) in parts if your savy and can do a lot of the work yourself. Then it's pretty smooth sailing & you'll have that "porn star girl friend", lol.