How to improve rust performance?

I would like to ask how to improve the performance of the program.
The main behavior of the program is after the query cassandra shows to the web page. But the same behavior, performance is not faster than python.
Already using cargo build --release,full code.

config set:

tsc:
  ip: '127.0.0.1'
  port: 9042
thread:
  num: 8
web:
  worker: 16
  port: '3009'
log:
  path: '/home/jeremy/log/'

In hardware performance (aws instance), rust cpu usage is around 100%, memory usage is not high (normal performance). And python is both fully loaded.

I use a lot of for loops in my program, maybe for this reason. However, because the library used is mostly iter(), in addition to the for loop, is there a way to get the corresponding value?

It's hard to guess. If you're building with --release, then it should definitely be faster than equivalent Python code, even if the code is not optimal.

You should run the program with a profiler, such as perf, to see what's going on.

1 Like

One likely reason is the Future::wait() calls used three times in a source code, they are blocking current thread while waiting for the value.

7 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.