Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-1740

Improve precision of stats's values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.3.2
    • Metrics
    • None

    Description

      Improve precision of stats's values

      Conversion between types, such as RecInt(int64_t) to RecFloat(float),
      may lead to loss of precision.

      In the old code, token value was defined with StatFloat type, it would casue
      unnecessary conversion when type of token is not StatFloat.

      it's best to keep value with the same type of token as much as possiable.

      ===
      For example, we have defined such expression in stats.config.xml:

          <statistics>
              <destination>proxy.node.http.user_agent_total_request_bytes</destination>
              <destination scope="cluster">proxy.cluster.http.user_agent_total_request_bytes</destination>
             <expression>
                  proxy.process.http.user_agent_request_document_total_size +
                  proxy.process.http.user_agent_request_header_total_size
              </expression>
          </statistics>
      

      So:
      proxy.node.http.user_agent_total_request_bytes = \
      proxy.process.http.user_agent_request_document_total_size + \
      proxy.process.http.user_agent_request_header_total_size

      These three stats token are all RecInt types, but the code would convert them to RecFloat when evaluating the expression, like that:
      proxy.node.http.user_agent_total_request_bytes = \
      (RecFloat)proxy.process.http.user_agent_request_document_total_size + \
      (RecFloat)proxy.process.http.user_agent_request_header_total_size

      As a result, we might get the following output from stats http API:

      [root@test62 trafficserver]# cat ~/bin/list-cluster.sh 
      elinks -dump http://localhost:8080/stat/ | grep proxy_name
      elinks -dump http://localhost:8080/stat/ | grep nodes
      elinks -dump http://localhost:8080/stat/ | grep proxy.process.http.origin_server_request_document_total_size
      elinks -dump http://localhost:8080/stat/ | grep proxy.process.http.origin_server_request_header_total_size
      elinks -dump http://localhost:8080/stat/ | grep proxy.node.http.origin_server_total_request_bytes
      [root@test62 trafficserver]# list-cluster.sh 
       proxy.config.proxy_name=test62.63
       proxy.node.cluster.nodes=1
       proxy.process.cluster.nodes=1
       proxy.process.http.origin_server_request_document_total_size=0        <= #1
       proxy.process.http.origin_server_request_header_total_size=359209123  <= #2
       proxy.node.http.origin_server_total_request_bytes=359209120           <= #3 != (#1 + #2)
      

      As the value increasing, the loss of precision will become more and more seriously.

      Attachments

        Activity

          People

            zym Zhao Yongming
            yunkai Yunkai Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: