MM-61225: Revert session pooling (#28901)
This originated from https://github.com/mattermost/mattermost/issues/15249. However, the original idea was discarded https://github.com/mattermost/mattermost/issues/15249#issuecomment-709713065 as being too complicated to implement. Then I had another idea to implement it just for session objects. My thinking was that since every single request allocates a new session struct, it would be good to use a sync.Pool for that. However, 4 years later, now we know that the primary bottleneck in app performance comes from websocket event marshalling. Therefore, while it would be good to do this, it is difficult to do it correctly (as shown by the numerous racy tests). Hence, reverting this. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a8cf496e31
Коммит
6075b1cd4e
@@ -54,19 +54,9 @@ func TestContext(t testing.TB) *Context {
|
||||
return EmptyContext(logger)
|
||||
}
|
||||
|
||||
// Clone creates a deep copy of [CTX].
|
||||
// It should only be used to pass a [CTX] to a separate goroutine that
|
||||
// has a longer lifespan than the main goroutine handling the request.
|
||||
// It should be used sparsely as coping [CTX] is often unnecessary.
|
||||
func (c *Context) Clone() CTX {
|
||||
return c.clone()
|
||||
}
|
||||
|
||||
// clone creates a deep copy of [Context], allowing clones to apply per-request changes.
|
||||
// It unexported to prevent leaking the [Context] type from the [CTX] interface.
|
||||
// clone creates a shallow copy of Context, allowing clones to apply per-request changes.
|
||||
func (c *Context) clone() *Context {
|
||||
cCopy := *c
|
||||
cCopy.session = *c.session.DeepCopy()
|
||||
return &cCopy
|
||||
}
|
||||
|
||||
@@ -183,5 +173,4 @@ type CTX interface {
|
||||
WithLogger(mlog.LoggerIFace) CTX
|
||||
WithContext(ctx context.Context) CTX
|
||||
With(func(ctx CTX) CTX) CTX
|
||||
Clone() CTX
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user