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

Inline index_offset_buffer_t methods #1439

Merged
merged 2 commits into from
Mar 29, 2022
Merged

Conversation

senderista
Copy link
Contributor

There were a number of trivial index_offset_buffer_t methods that showed up in profiles of the server, which turned out to be defined in a .cpp file, preventing inlining. Here is the most expensive one (about twice the overhead of gaia::db::server_t::sort_log):

Total time   Self time       Calls  Function
  ==========  ==========  ==========  ====================
    1.453  s   41.722 us           4  gaia::db::server_t::session_handler
    ...
    46.535 ms   46.535 ms     1000601  gaia::db::index::index_offset_buffer_t::size
    22.155 ms    3.122 ms          18  gaia::db::server_t::sort_log
    ...

Measurements using test_insert_perf.simple_table_insert do not show a clear improvement, but profiling confirms that server overhead is reduced.

@@ -133,3 +133,29 @@ typename T_structure::iterator index_t<T_structure, T_iterator>::find_physical_k

return m_data.end();
}

gaia_offset_t index_offset_buffer_t::get_offset(size_t index) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put these in the order in which they are listed in the header, or change that order to match this one? The latter is probably even better, because methods like insert should precede simple getters like the other methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@LaurentiuCristofor LaurentiuCristofor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor request to list the methods in the same order during definition as during declaration.

Comment on lines 60 to 64
inline void insert(gaia_offset_t offset, common::gaia_type_t type);
inline gaia_offset_t get_offset(size_t index) const;
inline common::gaia_type_t get_type(size_t index) const;
inline bool empty() const;
inline size_t size() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the inline keyword has almost no effect on the compiler's decision on whether to inline or not. The semantic of the keyword has drastically changed from "you should inline this method" to "allow multiple definitions of the function".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed in the int_type_t change the inline keyword hasn;t been specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to specify inline somewhere or you'll violate the ODR.

Copy link
Contributor

@simone-gaia simone-gaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@senderista senderista merged commit bb37304 into master Mar 29, 2022
@senderista senderista deleted the tobin/inline_index_methods branch March 29, 2022 12:57
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