Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay: cache metrics so we don't keep looking them up. #2161

Merged

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Jun 19, 2019

Description

Somewhat embarrassingly, stellar-core currently looks up a metric (due to the peer load manager) once every message read, and due to medida's not-very-fast representation of metric names and their lookup, this accounts for a nontrivial amount of CPU usage when dealing with regular network load. It's not even a different metric or a peer-specific one: we just look up the same one over and over and over.

This PR caches the lookup. Along the way it moves all the overlay metrics into their own helper struct that outlives any individual peer.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v5.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document
before
======

 Performance counter stats for './src/stellar-core test Flooding' (5 runs):

       6325.809263      task-clock (msec)         #    0.597 CPUs utilized            ( +-  1.23% )
             3,771      context-switches          #    0.596 K/sec                    ( +-  1.04% )
               281      cpu-migrations            #    0.044 K/sec                    ( +-  3.29% )
            30,473      page-faults               #    0.005 M/sec                    ( +-  2.09% )
    17,987,544,025      cycles                    #    2.844 GHz                      ( +-  0.51% )
    10,770,607,881      stalled-cycles-frontend   #   59.88% frontend cycles idle     ( +-  0.92% )
    17,816,610,829      instructions              #    0.99  insn per cycle         
                                                  #    0.60  stalled cycles per insn  ( +-  0.32% )
     2,603,758,090      branches                  #  411.609 M/sec                    ( +-  0.32% )
        76,597,631      branch-misses             #    2.94% of all branches          ( +-  0.58% )

      10.594307901 seconds time elapsed                                          ( +-  0.74% )


after
=====

 Performance counter stats for './src/stellar-core test Flooding' (5 runs):

       5857.014959      task-clock (msec)         #    0.586 CPUs utilized            ( +-  3.01% )
             3,632      context-switches          #    0.620 K/sec                    ( +-  2.82% )
               315      cpu-migrations            #    0.054 K/sec                    ( +-  2.30% )
            29,182      page-faults               #    0.005 M/sec                    ( +-  2.50% )
    16,403,055,117      cycles                    #    2.801 GHz                      ( +-  1.99% )
     9,945,123,289      stalled-cycles-frontend   #   60.63% frontend cycles idle     ( +-  1.80% )
    15,904,421,871      instructions              #    0.97  insn per cycle         
                                                  #    0.63  stalled cycles per insn  ( +-  2.87% )
     2,171,237,679      branches                  #  370.707 M/sec                    ( +-  4.37% )
        68,549,465      branch-misses             #    3.16% of all branches          ( +-  1.18% )

      10.002086645 seconds time elapsed                                          ( +-  2.95% )

@MonsieurNicolas
Copy link
Contributor

Looks good. Just need to update the VS project files

@graydon
Copy link
Contributor Author

graydon commented Jun 19, 2019

@MonsieurNicolas whoops, done!

@MonsieurNicolas
Copy link
Contributor

r+ 1ee554d

latobarita added a commit that referenced this pull request Jun 20, 2019
…y-packet

overlay: cache metrics so we don't keep looking them up.

Reviewed-by: MonsieurNicolas
@latobarita latobarita merged commit 1ee554d into stellar:master Jun 20, 2019
@graydon graydon deleted the stop-looking-up-metrics-on-every-packet branch January 3, 2020 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants