No-SilverBullet commented on code in PR #3023:
URL: https://github.com/apache/dubbo-go/pull/3023#discussion_r2343760263
##########
filter/accesslog/filter.go:
##########
@@ -204,12 +273,52 @@ func (f *Filter) writeLogToFile(data Data) {
}
}
+// getOrOpenLogFile gets or opens the log file with proper caching and handle
management
+func (f *Filter) getOrOpenLogFile(accessLog string) (*os.File, error) {
Review Comment:
> Yes, exactly! This is the Double-Checked Locking pattern to minimize write
lock contention.
>
> Why two checks:
>
> 1. First check (read lock): Fast path - most requests find existing valid
files and return immediately
> 2. Second check (write lock): Prevents race conditions - ensures another
goroutine didn't already create/rotate the file while we were acquiring the
write lock
Great idea, I think DCLP should have a significant performance improvement
when used here. Excellent work, thanks for your contribution :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]