In her first few months as CEO, Marissa Mayer has changed Yahoo in ways that will, in the short term, cost the company money.

There's the free food, the lights she's keeping on later, an expensive Christmas party she's planning, and even talk of giving employees new smartphones.

Most Yahoo employees are thrilled with these changes, and believe that they are already improving company culture.

But rumor has it that some Yahoo employees on CFO Tim Morse's finance staff have been quietly grumbling about the expenditures.

Well, these people haven't seen anything yet.

Yesterday, Mayer made a huge, risky bet on one of Yahoo's businesses. This bet will use up a lot more cash than free food ever will.

She put hundreds of millions of dollars—if not billions—at stake, having Yahoo's chief revenue officer, Michael Barrett, announce that Yahoo will not sell its ad-tech business, Right Media, as Yahoo had been planning to do before Mayer's arrival in July.

Yahoo's ad tech helps the company make money off of non-premium advertising inventory (websites where the banner ads are not sold by a sales person calling an agency and making a deal, but by a marketer using a computer). Yahoo's ad-tech business, Right Media, also does this for third-party publishers, though a lot of that business has gone to Google or independent companies like PubMatic or AppNexus.

The other reason this is such a risky bet is that Yahoo's ad-tech business costs the company a lot of money to run. Selling it would have freed up a lot of cash for Mayer to play with.

One former senior Yahoo still in the ad tech space tell us the no-brainer move for Yahoo was to sell the properties to Google, and, in the process, outsource Yahoo's remnant advertising sales to Google's ad exchange as well.

This source, speculating, says Yahoo would be able to cut 2,000 jobs and, because Google is so good at selling ads, increase EBITDA by as much as 50%.

Yahoo's EBITDA over the last 12 months has been $1.31 billion, so we're talking about an extra $650 million per year for Mayer to invest in Yahoo's other businesses (or in acquisitions).

Tack on the hundreds of millions of dollars Mayer now says she plans to invest in Right Media, throw in the $500 million or so she could have sold the business for, and the size of this wager comes in well above $1 billion.

WATCH: What Marissa Mayer Needs To Do At Yahoo

Is it worth it?

The upside for Yahoo in keeping its "ad stack," as its portfolio of ad technologies is called by industry types, is that the technology could help the company get more out of its non-premium inventory.

Currently, non-premium inventory makes up 60% or so of Yahoo's display advertising revenues, according to research from Evercore Partners.

Even a small lift in the rates Yahoo can charge for its non-remnant advertising goes a long way. Yahoo display revenues were $1.2 billion last quarter. Evercore estimates that as much as $760 million of that was remnant. If Yahoo's ad stack can improve its ad rates by 10% to 15%, there is the potential for an incremental $100-$200 million in the company's annual revenues.

If Yahoo could start increasing the ad rates of third-party publishers/partners/clients by 10% to 15%, it would, of course, have a very big business on its hands.

One former Right Media executive told us Mayer's plan is a "great idea" and that "the market will be rooting for them." But this source said that Mayer needs to focus on improving Yahoo's ad tech where it can be better than Google's. He suggested premium display and video ads.

That's a good thing for Yahoo, this source says, because "the reality is, premium display, branded entertainment and premium content on video are much larger markets to own vs. remnant display and non premium video."

Another former Right Media executive put Mayer and Yahoo's billion-dollar ad-tech bet in starker terms.

"Keeping it is the easy part," says this source.

"Making it competitive after years of stagnation will be the hard part. I hope they can."