The worst thing “I’m Dying Up Here” has going for it is Jim Carrey’s name attached as executive producer. It’s not Carrey’s fault. Despite his valiant efforts to stretch (“The Truman Show,” “Eternal Sunshine of the Spotless Mind”), he’ll forever be known as a hyperactive cartoon character spewing catchphrases out of his butt.

I launched into the first six episodes braced for so many fart jokes I’d have to call a fumigator.

Instead, “Dying,” an all-access pass into the backstage of an L.A. comedy club, plays to Carrey’s most ambitious instincts and will certainly end up on my shortlist for best new series of the year.

Premiering Sunday on Showtime, the drama is set in 1973, long before Carrey cut his teeth. The setting is important. Back then, opportunities were scarce and the pay was zero.

One newbie who can barely book time during open-mic nights at his home club, the fictional Goldie’s, joins Alcoholics Anonymous simply to test out new material at meetings. Another contemplates switching allegiances because a competitor offers free breaded shrimp.

The only path to fame was Johnny Carson, played by Dylan Baker with none of the host’s on-air charm and every fiber of his off-air ruthlessness.

Of course, all of the struggling comics are convinced they’re just four killer jokes away from earning a spot on “The Tonight Show” and will do almost anything to curry favor with the club’s gatekeeper, Goldie, played by Oscar winner Melissa Leo.

While they have each other’s backs — no one else could stand them — they shower one another with the kind of tough love that would make Gordon Ramsay cower in the pantry. They’ll watch each other’s sets, even force themselves to laugh. But in the back of their minds, they’re assembling a new putdown to unleash over a post-mortem at an all-night diner.

If “Dying” was just a sitcom version of the TV reality competition “Last Comic Standing,” it’d be just fine. But creator Dave Flebotte is aiming higher. Through the prism of Goldie’s, he and his top-notch writing staff manage to touch on the issues of the day — race, the Vietnam War, drug abuse — without making viewers feel as if they’ve accidentally wandered into a history class.

Sexism is the most prevalent and powerful theme, explored primarily through the struggles of Cassie (Ari Graynor), the club’s only female performer, who must decide how much — or how little — to rely on her cleavage. Graynor is one of the few cast members who isn’t a professional stand-up in a group that includes Andrew Santino, Al Madrigal and (a very, very good) Erik Griffin.

Leo, the show’s other most prominent non-comedian, once again proves why there’s no one better today at playing “tough broads.” While she keeps you guessing about whether she really cares about her charges or is only in it for herself, one thing is for sure: This is an Emmy-worthy performance.

I’m not sure how much Carrey had to do with making all this work so brilliantly. Yes, there are fart jokes.

And they’re terrific.