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

Improve update_expired_feeds performance #1093 #1180

Merged
merged 16 commits into from
Jul 27, 2018

Conversation

abitmore
Copy link
Member

PR for #1093, rebased from #1113.

The old bug is cryptonomex/graphene#615 .

Due to the bug, `update_median_feeds()` and `check_call_orders()`
will be called when a feed is not actually expired, normally this
should not affect consensus since calling them should not change
any data in the state.

However, the logging indicates that `check_call_orders()` did
change some data under certain circumstances, specifically, when
multiple limit order matching issue (#453) occurred at same block.
* #453
* changed an `assert()` to `FC_ASSERT()`
* replaced one `db.get(asset_id_type())` with `db.get_core_asset()`
* capture only required variables for lambda
pmconrad
pmconrad previously approved these changes Jul 25, 2018
Copy link
Contributor

@pmconrad pmconrad left a comment

Choose a reason for hiding this comment

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

Pointers should be safe because the objects are only ever created during init/load. Good idea.

(Originally reviewed #1113, but when I tried to post my review it had already been closed.)

a.current_supply = 0;
a.fee_pool = core_fee_paid - (hf_429 ? 1 : 0);
});
if( fee_is_odd && !hf_429 )
{
const auto& core_dd = db().get<asset_object>( asset_id_type() ).dynamic_data( db() );
db().modify( core_dd, [=]( asset_dynamic_data_object& dd ) {
const auto& core_dd = db().get_core_asset().dynamic_data( db() );
Copy link
Contributor

Choose a reason for hiding this comment

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

Use db().get_core_dynamic_data() instead

const auto last_budget_time = get_dynamic_global_properties().last_budget_time;
const auto passed_time_ms = head_time - last_budget_time;
const bool passed_time_is_a_day = ( passed_time_ms == fc::days(1) );
// the variable above is more likely false on BitShares mainnet, so do calculations below anyway
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO can simplify the code and remove the passed_time_is_a_day check because it's unlikely to ever be true

else
{
_p_core_asset_obj = &get( asset_id_type() );
_p_core_dynamic_data_obj = &get( asset_dynamic_data_id_type() );
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no FC_ASSERT that ensures that _p_core_asset_obj->dynamic_asset_data_id == asset_dynamic_data_id_type(), better do a regular lookup on _p_core_asset_obj->dynamic_asset_data_id

Copy link
Member Author

@abitmore abitmore Jul 26, 2018

Choose a reason for hiding this comment

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

asset_dynamic_data_id_type() was used in account_object::process_fees():

d.modify(asset_dynamic_data_id_type()(d), [network_cut](asset_dynamic_data_object& d) {
d.accumulated_fees += network_cut;
});

IMHO we need to add a FC_ASSERT. Update: added 4d40398

_p_global_prop_obj = &get( global_property_id_type() );
_p_chain_property_obj = &get( chain_property_id_type() );
_p_dyn_global_prop_obj = &get( dynamic_global_property_id_type() );
_p_witness_schedule_obj = &get( witness_schedule_id_type() );
Copy link
Contributor

Choose a reason for hiding this comment

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

I get compilation errors on lines 172, 174, 175?!

invalid static_cast from type ‘const graphene::db::object’ to type ‘const graphene::chain::chain_property_object&’
invalid static_cast from type ‘const graphene::db::object’ to type ‘const graphene::chain::special_assets_meta_object&’
invalid static_cast from type ‘const graphene::db::object’ to type ‘const graphene::chain::witness_schedule_object&’

Apparently need to

#include <graphene/chain/chain_property_object.hpp>
#include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/chain/special_authority_object.hpp>

Copy link
Member Author

Choose a reason for hiding this comment

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

What's your compiler version? I don't know where to add these header includes. Perhaps you can submit a PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

gcc-5.3.1 - please add them at the top of db_management.cpp

@abitmore
Copy link
Member Author

abitmore commented Jul 26, 2018

Travis-CI reported:

  • latest commit:

The job exceeded the maximum time limit for jobs, and has been terminated.

Update: restarted Travis-CI job and it passed.

  • earlier commit:

INFO: Total time: 7:18.836s (Sonar)

@abitmore abitmore requested a review from pmconrad July 26, 2018 20:48
@abitmore abitmore dismissed pmconrad’s stale review July 27, 2018 13:31

New commits added

Copy link
Contributor

@pmconrad pmconrad left a comment

Choose a reason for hiding this comment

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

Thanks!

@abitmore abitmore merged commit 2b8bccc into develop Jul 27, 2018
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.

2 participants