diff options
| author | chrislu <chris.lu@gmail.com> | 2025-10-30 21:03:13 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-10-30 21:03:13 -0700 |
| commit | 498922dbb2f7f2ac02bd695367b459fe1fe57a8e (patch) | |
| tree | a4826586639cbd111cd03c6c802744b31475db70 /postgres-examples/test_client.py | |
| parent | bba8931d64e412a296a20f153b9a62f7b7d4f4dc (diff) | |
| download | seaweedfs-498922dbb2f7f2ac02bd695367b459fe1fe57a8e.tar.xz seaweedfs-498922dbb2f7f2ac02bd695367b459fe1fe57a8e.zip | |
Optimize locking: Reduce lock acquisitions and use helper methods
Two optimizations to further reduce lock contention and improve code consistency:
1. LookupFileIdWithFallback: Eliminated redundant lock acquisition
- Before: Two separate locks to get vidMap and dataCenter
- After: Single lock gets both values together
- Benefit: 50% reduction in lock/unlock overhead for this hot path
2. KeepConnected: Use GetDataCenter() helper for consistency
- Before: Manual lock/unlock to access DataCenter field
- After: Use existing GetDataCenter() helper method
- Benefit: Better encapsulation and code consistency
Impact:
- Reduced lock contention in high-traffic lookup path
- More consistent use of accessor methods throughout codebase
- Cleaner, more maintainable code
Verified with: go test -race ./weed/wdclient/... (passes)
Diffstat (limited to 'postgres-examples/test_client.py')
0 files changed, 0 insertions, 0 deletions
