Browse Source

Don't worry so much about helping the GC

Let's just hope the GC does its job correctly and don't try to help it
out. This case is probably triggered very infrequently since most people
set up their middleware before they accept a single request, and it's
worth about 100ns of perf on the common case for us if we get rid of the
defer.
Carl Jackson 12 years ago
parent
commit
7f50cf60d3
1 changed files with 0 additions and 12 deletions
  1. +0
    -12
      web/middleware.go

+ 0
- 12
web/middleware.go View File

@ -82,12 +82,7 @@ func (m *mStack) findLayer(l interface{}) int {
}
func (m *mStack) invalidate() {
old := m.pool
m.pool = make(chan *cStack, mPoolSize)
close(old)
// Bleed down the old pool so it gets GC'd
for _ = range old {
}
}
func (m *mStack) newStack() *cStack {
@ -134,13 +129,6 @@ func (m *mStack) release(cs *cStack) {
if cs.pool != m.pool {
return
}
// It's possible that the pool has been invalidated (and closed) between
// the check above and now, in which case we'll start panicing, which is
// dumb. I'm not sure this is actually better than just grabbing a lock,
// but whatever.
defer func() {
recover()
}()
select {
case cs.pool <- cs:
default:


Loading…
Cancel
Save