Commit f7bf94c
perf: Reduce mutex contention and avoid batch clone (#5230)
* perf: Reduce mutex contention and avoid batch clone
Two performance improvements:
1. Lock Optimization (glide-core cluster_async)
Release mutex immediately after mem::take() instead of holding it
during the entire request processing loop. This eliminates contention
when multiple clients share the tokio runtime.
Before: Mutex held while iterating and spawning futures
After: Mutex released immediately after draining the queue
2. Clone Removal (java executeBatchAsync)
Take ownership of batch instead of cloning it before the async spawn.
For large batches, this avoids expensive deep clones of command data.
Before: let batch_clone = batch.clone(); // Expensive for large batches
After: Move batch directly into the async block
Both changes are safe:
- Lock optimization: mem::take atomically moves all requests out
- Clone removal: batch is consumed by the async block anyway
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
* Clean up verbose comments
Signed-off-by: Ubuntu <ubuntu@ip-172-31-25-236.us-east-2.compute.internal>
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
* fix: Use expect() for mutex lock consistency
Address Copilot review comment - use .expect(MUTEX_WRITE_ERR) instead
of if let Ok() for consistency with line 3079 and the rest of the
codebase. Mutex poisoning should not be silently ignored.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
* perf(java): Optimize UTF-8 string decoding
Replace decode().toString() with new String(bytes, UTF_8) for simpler
and more consistent decoding. Benchmarks show this is equivalent in
performance while being cleaner code.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
* fix(java): Ensure consistent byte order for direct buffer decoding
Set explicit BIG_ENDIAN byte order on duplicated buffer to ensure
consistent behavior across platforms.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
---------
Signed-off-by: Avi Fenesh <aviarchi1994@gmail.com>
Signed-off-by: Ubuntu <ubuntu@ip-172-31-25-236.us-east-2.compute.internal>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Shoham Elias <shohame@amazon.com>1 parent dec91f5 commit f7bf94c
File tree
4 files changed
+50
-49
lines changed- glide-core/redis-rs/redis/src/cluster_async
- java
- client/src/main/java/glide
- managers
- utils
- src
4 files changed
+50
-49
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3207 | 3207 | | |
3208 | 3208 | | |
3209 | 3209 | | |
3210 | | - | |
3211 | | - | |
3212 | | - | |
3213 | | - | |
3214 | | - | |
3215 | | - | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
3219 | | - | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
3220 | 3230 | | |
3221 | | - | |
3222 | | - | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
3226 | | - | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
3227 | 3236 | | |
3228 | | - | |
3229 | 3237 | | |
3230 | | - | |
3231 | 3238 | | |
3232 | 3239 | | |
3233 | 3240 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| 547 | + | |
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
42 | 34 | | |
43 | 35 | | |
44 | 36 | | |
| |||
49 | 41 | | |
50 | 42 | | |
51 | 43 | | |
52 | | - | |
| 44 | + | |
| 45 | + | |
53 | 46 | | |
54 | 47 | | |
55 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
56 | 51 | | |
57 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1532 | 1532 | | |
1533 | 1533 | | |
1534 | 1534 | | |
1535 | | - | |
1536 | | - | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
1537 | 1541 | | |
1538 | 1542 | | |
1539 | 1543 | | |
1540 | 1544 | | |
1541 | 1545 | | |
1542 | 1546 | | |
1543 | | - | |
1544 | | - | |
1545 | 1547 | | |
1546 | 1548 | | |
1547 | 1549 | | |
| |||
1551 | 1553 | | |
1552 | 1554 | | |
1553 | 1555 | | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | 1556 | | |
1559 | 1557 | | |
1560 | 1558 | | |
| |||
1575 | 1573 | | |
1576 | 1574 | | |
1577 | 1575 | | |
1578 | | - | |
1579 | | - | |
| 1576 | + | |
| 1577 | + | |
1580 | 1578 | | |
1581 | 1579 | | |
1582 | 1580 | | |
1583 | 1581 | | |
1584 | | - | |
| 1582 | + | |
1585 | 1583 | | |
1586 | 1584 | | |
1587 | 1585 | | |
| |||
1605 | 1603 | | |
1606 | 1604 | | |
1607 | 1605 | | |
1608 | | - | |
| 1606 | + | |
1609 | 1607 | | |
1610 | 1608 | | |
1611 | 1609 | | |
1612 | 1610 | | |
1613 | | - | |
1614 | | - | |
| 1611 | + | |
| 1612 | + | |
1615 | 1613 | | |
1616 | 1614 | | |
1617 | 1615 | | |
1618 | 1616 | | |
1619 | 1617 | | |
1620 | 1618 | | |
1621 | 1619 | | |
1622 | | - | |
1623 | | - | |
| 1620 | + | |
| 1621 | + | |
1624 | 1622 | | |
1625 | | - | |
| 1623 | + | |
1626 | 1624 | | |
1627 | 1625 | | |
1628 | | - | |
| 1626 | + | |
1629 | 1627 | | |
1630 | 1628 | | |
1631 | 1629 | | |
| |||
0 commit comments