In an oped posted online Friday, Santa Clara County District Attorney Jeff Rosen cheered on sentencing reform in California that’s allowing many minor offenders a second chance through shorter prison terms and more drug treatment and other help on the outside. It is, by the way, saving money.

Proposition 47, the reform measure, was a major pendulum swing. And this week, the federal pendulum began its own swing back to reason: Federal officials began freeing 6,000 prisoners, at least a symbolic blow to the tough-on-crime dogma that has made the United States home to the world’s largest prison population — 2 million people nationwide. That approach has never been sustainable in any society for both economic and social reasons.

Last year the U.S. spent $7.3 billion to keep 209,000 people in federal detention. California alone spends another $10 billion annually. The vast drain on resources coupled with decades of declining crime has forced a national re-examination of the wisdom of mass incarceration. There should be no turning back.

A year ago, the U.S. Sentencing Commission reduced sentencing guidelines for nonviolent offenders. Of that first 6,000 freed, about a third will be deported. Unfortunately, many of the rest may not find the support they need to readjust to society, so recidivism is a concern.

California’s reforms have put more support in place, and Rosen says recidivism here is only 5 percent among those affected by the program. In 2014, the overall rate of people returning to prison for new crimes or parole violation was 61 percent.

The federal release comes on the heels of another, even more significant move to overhaul punishment in the United States: In October, Senate Judiciary Committee Chairman Charles E. Grassley, a conservative Republican from Iowa, and liberal Democrat Sen. Richard J. Durbin from Illinois introduced what they hailed as the biggest criminal justice reform in a generation.

The rare bipartisan bill would eliminate mandatory life sentences for three-time, nonviolent drug offenders and in some cases allow judges greater discretion in sentencing. It would also ban juvenile solitary confinement, which California can’t seem to bring itself to do despite strong evidence of the harm it causes.

This swing toward a more rehabilitative approach is the right path.

In February, the Brennan Center for Justice released a study on the decades-long decline in crime. The authors concluded there’s no clear link between increasing incarceration rates and declining crime rates; in fact, the report argues that prison’s effectiveness as a deterrent has subsided.

In California, some blame the state’s Prop. 47 reforms for recent increases in property crimes. But it is far too early to rule out other causes and see if there’s a connection.

Like California, it took the federal prisons a while to get into this mess. It will take time to get out. But finally, locally and nationally, we’re headed in the right direction.