Here’s one you won’t have heard before. A stand-up comedian takes to the stage in a small club in Israel, gets the audience’s attention by smacking himself in the face and, over the next two hours, wracked with self-loathing and despair, wrestles with his demons before an uneasy, often hostile audience.

A few days earlier, the 57-year-old comic, Dovaleh Greenstein, contacted a man he hadn’t seen since they were both 14 and asked him to come to the show. He wants Avishai Lazar, a retired judge who has written many perceptive and insightful judgements of defendants, to watch him perform and then to tell him what he sees.

Spanning two hours and 200 pages, A Horse Walks Into A Bar immerses us in the claustrophobic, gladiatorial intensity of the comedy club, where the relationship between performer and audience teeters on the edge of a razor. Forsaking crowd-pleasing jokes for stories about his childhood, memories of a father who beat him and sorrowful reminiscences of a mother who escaped the Holocaust by hiding in a railway carriage, Dov turns the gig into a public exorcism of his own wretchedness.

Naturally, most of the patrons, who have come here to unwind after a hard week, are unamused. Many complain, heckle and walk out. The ones who remain are those who have long given up on the pretence that this is a comedy show and are willing the tortured comic on towards his cathartic climax. The judge, sitting alone, realises that this is all building up to the revelation of an unknown trauma that Dov has been silently wrestling with for years, and feels the creeping suspicion that Dov invited him to the club to implicate him in some way. There’s one other person at the show tonight who knew Dovaleh as a child: a diminutive lady who shakes her head at his outrageous utterances, insisting to those around her that this cynical provocateur is not the same person as the “good boy” she knew in their hometown, whose trademark eccentricity was that he liked to walk on his hands. Together they form a triangle, playing out their own tense psychodrama in the midst of an anonymous audience.

Grossman inserts a few good jokes that bear repeating. But really this book is a compelling study of the relationship between artist and spectator, and how suffering feeds into art, and he’s made of it a bravura performance, capturing on the printed page the rhythm, pacing, energy, desire to connect and the second-by-second decisions of a good comedy set, albeit one that’s set to self-destruct. We could almost be right there in the club with them. Grossman clearly harbours a lot of admiration for – perhaps even envy of – a performer who lives in the moment, constantly recalibrating his act to keep his audience on side while confronting them head on. And, with this extraordinary novel, he claims at least a little of that sense of danger and fearlessness for himself.

David Grossman will be at the Edinburgh Internationall Book Festival on August 16