# Bounds Check Elimination In Go

DevFeed: [Bounds Check Elimination In Go](<https://devfeed.tech/articles/bounds-check-elimination-in-go-22134.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2018/04/bounds-check-elimination-in-go.html>)

Published: 2018-04-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [blog](<https://devfeed.tech/tags/blog.md>), [coding](<https://devfeed.tech/tags/coding.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [memory](<https://devfeed.tech/tags/memory.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [ssa](<https://devfeed.tech/tags/ssa.md>)

## AI overview

This tutorial explains Bounds Check Elimination in Go, a compiler optimization that removes runtime checks when the compiler can establish that index-based memory access is safe. It describes how slice operations can obscure bounds information and how explicit upper bounds can help eliminate checks.

## Source excerpt

Introduction One day I was talking to Damian Gryski in Slack about some performance improvements he made to his go-metro package. When I first looked at the changes I was completely confused how this could have any effect on the performance of the code. I felt the code was more readable, but more performant? I didn't see it. Then Damian started to talk to me about a compiler optimization called Bounds Check Elimination or BCE. The idea behind BCE is to give the compiler hints that index-based memory access is guaranteed to be safe and therefore the compiler didn't have to add extra code to check the memory access at runtime. The safe elimination of these integrity checks can help improve performance.