Go - prevent race condition


  • Prevent race condition
    • Initialize variables when package initialization phase, it will happen before main function. And don't modify those variables after initialization.
    • Avoid modifying variables by multiple goroutine => Every goroutine take care of different variable modification.
    • Dont communicate by sharing memory, share memory by communicating
    • Can pass variable address to pipeline to confine goroutine to modify variable
    • Confine variables to different stages
    • Allow many goroutines to access one variable, but only one access variable at a time



沒有留言:

張貼留言

Lessons Learned While Benchmarking vLLM with GPU

Recently, I benchmarked vLLM on a GPU to better understand how much throughput can realistically be expected in an LLM serving setup. One ...