ucx-info.sh 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. #!/bin/bash
  2. # UCX Information and Testing Script
  3. # Provides detailed information about UCX configuration and capabilities
  4. set -e
  5. echo "📋 UCX (Unified Communication X) Information"
  6. echo "============================================="
  7. # Colors for output
  8. GREEN='\033[0;32m'
  9. YELLOW='\033[1;33m'
  10. BLUE='\033[0;34m'
  11. NC='\033[0m' # No Color
  12. print_section() {
  13. echo -e "\n${BLUE}📌 $1${NC}"
  14. echo "----------------------------------------"
  15. }
  16. print_info() {
  17. echo -e "${GREEN}ℹ️ $1${NC}"
  18. }
  19. print_warning() {
  20. echo -e "${YELLOW}⚠️ $1${NC}"
  21. }
  22. # Function to check UCX installation
  23. check_ucx_installation() {
  24. print_section "UCX Installation Status"
  25. if command -v ucx_info >/dev/null 2>&1; then
  26. print_info "UCX tools are installed"
  27. # Get UCX version
  28. if ucx_info -v >/dev/null 2>&1; then
  29. local version=$(ucx_info -v 2>/dev/null | head -1)
  30. print_info "Version: $version"
  31. fi
  32. else
  33. print_warning "UCX tools not found"
  34. echo "Install with: apt-get install ucx-tools libucx-dev"
  35. return 1
  36. fi
  37. # Check UCX libraries
  38. local libs_found=0
  39. for lib in libucp.so libucs.so libuct.so; do
  40. if ldconfig -p | grep -q "$lib"; then
  41. libs_found=$((libs_found + 1))
  42. fi
  43. done
  44. if [ "$libs_found" -eq 3 ]; then
  45. print_info "All UCX libraries found (ucp, ucs, uct)"
  46. else
  47. print_warning "Some UCX libraries may be missing ($libs_found/3 found)"
  48. fi
  49. }
  50. # Function to show UCX device information
  51. show_ucx_devices() {
  52. print_section "UCX Transport Devices"
  53. if command -v ucx_info >/dev/null 2>&1; then
  54. echo "Available UCX transports and devices:"
  55. ucx_info -d 2>/dev/null || {
  56. print_warning "Failed to get UCX device information"
  57. return 1
  58. }
  59. else
  60. print_warning "ucx_info command not available"
  61. return 1
  62. fi
  63. }
  64. # Function to show UCX configuration
  65. show_ucx_config() {
  66. print_section "UCX Configuration"
  67. if command -v ucx_info >/dev/null 2>&1; then
  68. echo "UCX configuration parameters:"
  69. ucx_info -c 2>/dev/null | head -20 || {
  70. print_warning "Failed to get UCX configuration"
  71. return 1
  72. }
  73. echo ""
  74. print_info "Key UCX environment variables:"
  75. echo " UCX_TLS - Transport layers to use"
  76. echo " UCX_NET_DEVICES - Network devices to use"
  77. echo " UCX_LOG_LEVEL - Logging level (error, warn, info, debug, trace)"
  78. echo " UCX_MEMTYPE_CACHE - Memory type caching (y/n)"
  79. else
  80. print_warning "ucx_info command not available"
  81. return 1
  82. fi
  83. }
  84. # Function to test UCX capabilities
  85. test_ucx_capabilities() {
  86. print_section "UCX Capability Testing"
  87. if command -v ucx_info >/dev/null 2>&1; then
  88. print_info "Testing UCX transport capabilities..."
  89. # Check for RDMA transports
  90. local ucx_transports=$(ucx_info -d 2>/dev/null | grep -i "transport\|tl:" || true)
  91. if echo "$ucx_transports" | grep -q "rc\|dc\|ud"; then
  92. print_info "✅ RDMA transports detected (RC/DC/UD)"
  93. else
  94. print_warning "No RDMA transports detected"
  95. fi
  96. if echo "$ucx_transports" | grep -q "tcp"; then
  97. print_info "✅ TCP transport available"
  98. else
  99. print_warning "TCP transport not detected"
  100. fi
  101. if echo "$ucx_transports" | grep -q "shm\|posix"; then
  102. print_info "✅ Shared memory transport available"
  103. else
  104. print_warning "Shared memory transport not detected"
  105. fi
  106. # Memory types
  107. print_info "Testing memory type support..."
  108. local memory_info=$(ucx_info -d 2>/dev/null | grep -i "memory\|md:" || true)
  109. if [ -n "$memory_info" ]; then
  110. echo "$memory_info" | head -5
  111. fi
  112. else
  113. print_warning "Cannot test UCX capabilities - ucx_info not available"
  114. return 1
  115. fi
  116. }
  117. # Function to show recommended UCX settings for RDMA
  118. show_rdma_settings() {
  119. print_section "Recommended UCX Settings for RDMA"
  120. print_info "For optimal RDMA performance with SeaweedFS:"
  121. echo ""
  122. echo "Environment Variables:"
  123. echo " export UCX_TLS=rc_verbs,ud_verbs,rc_mlx5_dv,dc_mlx5_dv"
  124. echo " export UCX_NET_DEVICES=all"
  125. echo " export UCX_LOG_LEVEL=info"
  126. echo " export UCX_RNDV_SCHEME=put_zcopy"
  127. echo " export UCX_RNDV_THRESH=8192"
  128. echo ""
  129. print_info "For development/debugging:"
  130. echo " export UCX_LOG_LEVEL=debug"
  131. echo " export UCX_LOG_FILE=/tmp/ucx.log"
  132. echo ""
  133. print_info "For Soft-RoCE (RXE) specifically:"
  134. echo " export UCX_TLS=rc_verbs,ud_verbs"
  135. echo " export UCX_IB_DEVICE_SPECS=rxe0:1"
  136. echo ""
  137. }
  138. # Function to test basic UCX functionality
  139. test_ucx_basic() {
  140. print_section "Basic UCX Functionality Test"
  141. if command -v ucx_hello_world >/dev/null 2>&1; then
  142. print_info "UCX hello_world test available"
  143. echo "You can test UCX with:"
  144. echo " Server: UCX_TLS=tcp ucx_hello_world -l"
  145. echo " Client: UCX_TLS=tcp ucx_hello_world <server_ip>"
  146. else
  147. print_warning "UCX hello_world test not available"
  148. fi
  149. # Check for other UCX test utilities
  150. local test_tools=0
  151. for tool in ucx_perftest ucp_hello_world; do
  152. if command -v "$tool" >/dev/null 2>&1; then
  153. test_tools=$((test_tools + 1))
  154. print_info "UCX test tool available: $tool"
  155. fi
  156. done
  157. if [ "$test_tools" -eq 0 ]; then
  158. print_warning "No UCX test tools found"
  159. echo "Consider installing: ucx-tools package"
  160. fi
  161. }
  162. # Function to generate UCX summary
  163. generate_summary() {
  164. print_section "UCX Status Summary"
  165. local ucx_ok=0
  166. local devices_ok=0
  167. local rdma_ok=0
  168. # Check UCX availability
  169. if command -v ucx_info >/dev/null 2>&1; then
  170. ucx_ok=1
  171. fi
  172. # Check devices
  173. if command -v ucx_info >/dev/null 2>&1 && ucx_info -d >/dev/null 2>&1; then
  174. devices_ok=1
  175. # Check for RDMA
  176. if ucx_info -d 2>/dev/null | grep -q "rc\|dc\|ud"; then
  177. rdma_ok=1
  178. fi
  179. fi
  180. echo "📊 UCX Status:"
  181. [ "$ucx_ok" -eq 1 ] && print_info "✅ UCX Installation: OK" || print_warning "❌ UCX Installation: Missing"
  182. [ "$devices_ok" -eq 1 ] && print_info "✅ UCX Devices: Detected" || print_warning "❌ UCX Devices: Not detected"
  183. [ "$rdma_ok" -eq 1 ] && print_info "✅ RDMA Support: Available" || print_warning "⚠️ RDMA Support: Limited/Missing"
  184. echo ""
  185. if [ "$ucx_ok" -eq 1 ] && [ "$devices_ok" -eq 1 ]; then
  186. print_info "🎉 UCX is ready for SeaweedFS RDMA integration!"
  187. if [ "$rdma_ok" -eq 1 ]; then
  188. print_info "🚀 Real RDMA acceleration is available"
  189. else
  190. print_warning "💡 Only TCP/shared memory transports available"
  191. fi
  192. else
  193. print_warning "🔧 UCX setup needs attention for optimal performance"
  194. fi
  195. }
  196. # Main execution
  197. main() {
  198. check_ucx_installation
  199. echo ""
  200. show_ucx_devices
  201. echo ""
  202. show_ucx_config
  203. echo ""
  204. test_ucx_capabilities
  205. echo ""
  206. show_rdma_settings
  207. echo ""
  208. test_ucx_basic
  209. echo ""
  210. generate_summary
  211. echo ""
  212. print_info "For SeaweedFS RDMA engine integration:"
  213. echo " 1. Use UCX with your Rust engine"
  214. echo " 2. Configure appropriate transport layers"
  215. echo " 3. Test with SeaweedFS RDMA sidecar"
  216. echo " 4. Monitor performance and adjust settings"
  217. }
  218. # Execute main function
  219. main "$@"