Skip to content

versioned cache entries for collections#34424

Closed
gingerlime wants to merge 4 commits intorails:masterfrom
gingerlime:collection-versioned-cache-entries
Closed

versioned cache entries for collections#34424
gingerlime wants to merge 4 commits intorails:masterfrom
gingerlime:collection-versioned-cache-entries

Conversation

@gingerlime
Copy link
Contributor

@gingerlime gingerlime commented Nov 11, 2018

Summary

  • Recyclable cache keys #29092 introduced versioned (recyclable) cache entries
  • Active Record relations however do not yet have support for versioned
    cache entries
  • This can lead to performance issues, irrespective of when versioning
    is on or off
    (see Recyclable cache keys #29092 (comment))
  • besides this, cache utilization can improve if AR relations also
    supported recyclable keys, and it would be more consistent
  • This change added cache_version method in addition to
    cache_key to relations, and delegating to collection_cache_version
    similarly to collection_cache_key
  • updated tests to cover non-versioned relations as well as versioned

Other Information

  • this is just a first stab, to gauge interest and explore this
    direction

* rails#29092 introduced versioned (recyclable) cache entries
* Active Record relations however do not yet have support for versioned
  cache entries
* This can lead to performance issues, irrespective of when versioning
  is on or off
  (see rails#29092 (comment))
* Irrespective, cache utilization can improve if AR relations also
  supported recyclable keys
* This change added cache_version method in addition to
  cache_key to relations, and delegating to collection_cache_version
  similarly to collection_cache_key
* updated tests to cover non-versioned relations as well as versioned
* this is just a first stab, to gauge interest and explore this
  direction
@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@gingerlime
Copy link
Contributor Author

gingerlime commented Nov 12, 2018

Travis reports a strange failure

Failure:
PostgresqlMoneyTest#test_default [/home/travis/build/rails/rails/activerecord/test/cases/adapters/postgresql/money_test.rb:40]:
Expected: "$150.55"
  Actual: "150.55"
rails test home/travis/build/rails/rails/activerecord/test/cases/adapters/postgresql/money_test.rb:37

I can't reproduce the test failures locally, and they seem unrelated to this change, even with the same seed


vagrant@rails-dev-box:/vagrant/rails/activerecord$ bundle exec rake SEED=37429 postgresql:test
/usr/bin/ruby2.5 -w -I"lib:test"  "/usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb" "test/cases/date_time_precision_test.rb" "test/cases/connection_adapters/adapter_leasing_test.rb" "test/cases/connection_adapters/type_lookup_test.rb" "test/cases/connection_adapters/schema_cache_test.rb" "test/cases/connection_adapters/connection_handler_test.rb" "test/cases/connection_adapters/connection_handlers_multi_db_test.rb" "test/cases/connection_adapters/mysql_type_lookup_test.rb" "test/cases/connection_adapters/connection_specification_test.rb" "test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb" "test/cases/dup_test.rb" "test/cases/reload_models_test.rb" "test/cases/clone_test.rb" "test/cases/test_fixtures_test.rb" "test/cases/connection_pool_test.rb" "test/cases/boolean_test.rb" "test/cases/statement_cache_test.rb" "test/cases/instrumentation_test.rb" "test/cases/enum_test.rb" "test/cases/attribute_methods/read_test.rb" "test/cases/custom_locking_test.rb" "test/cases/invertible_migration_test.rb" "test/cases/date_time_test.rb" "test/cases/migration_test.rb" "test/cases/errors_test.rb" "test/cases/types_test.rb" "test/cases/schema_dumper_test.rb" "test/cases/ar_schema_test.rb" "test/cases/associations/has_one_associations_test.rb" "test/cases/associations/has_one_through_associations_test.rb" "test/cases/associations/join_model_test.rb" "test/cases/associations/inverse_associations_test.rb" "test/cases/associations/eager_test.rb" "test/cases/associations/left_outer_join_association_test.rb" "test/cases/associations/inner_join_association_test.rb" "test/cases/associations/belongs_to_associations_test.rb" "test/cases/associations/eager_singularization_test.rb" "test/cases/associations/has_many_through_associations_test.rb" "test/cases/associations/nested_through_associations_test.rb" "test/cases/associations/has_many_associations_test.rb" "test/cases/associations/required_test.rb" "test/cases/associations/extension_test.rb" "test/cases/associations/has_and_belongs_to_many_associations_test.rb" "test/cases/associations/eager_load_nested_include_test.rb" "test/cases/associations/callbacks_test.rb" "test/cases/associations/bidirectional_destroy_dependencies_test.rb" "test/cases/associations/eager_load_includes_full_sti_class_test.rb" "test/cases/associations/cascaded_eager_loading_test.rb" "test/cases/bind_parameter_test.rb" "test/cases/disconnected_test.rb" "test/cases/attribute_decorators_test.rb" "test/cases/hot_compatibility_test.rb" "test/cases/json_serialization_test.rb" "test/cases/core_test.rb" "test/cases/mixin_test.rb" "test/cases/coders/json_test.rb" "test/cases/coders/yaml_column_test.rb" "test/cases/fixtures_test.rb" "test/cases/adapter_test.rb" "test/cases/defaults_test.rb" "test/cases/attribute_methods_test.rb" "test/cases/invalid_connection_test.rb" "test/cases/type/date_time_test.rb" "test/cases/type/integer_test.rb" "test/cases/type/type_map_test.rb" "test/cases/type/adapter_specific_registry_test.rb" "test/cases/type/string_test.rb" "test/cases/type/unsigned_integer_test.rb" "test/cases/validations_test.rb" "test/cases/tasks/mysql_rake_test.rb" "test/cases/tasks/postgresql_rake_test.rb" "test/cases/tasks/sqlite_rake_test.rb" "test/cases/tasks/database_tasks_test.rb" "test/cases/integration_test.rb" "test/cases/forbidden_attributes_protection_test.rb" "test/cases/column_alias_test.rb" "test/cases/secure_token_test.rb" "test/cases/database_statements_test.rb" "test/cases/store_test.rb" "test/cases/associations_test.rb" "test/cases/nested_attributes_with_callbacks_test.rb" "test/cases/schema_loading_test.rb" "test/cases/view_test.rb" "test/cases/modules_test.rb" "test/cases/unsafe_raw_sql_test.rb" "test/cases/comment_test.rb" "test/cases/touch_later_test.rb" "test/cases/unconnected_test.rb" "test/cases/migrator_test.rb" "test/cases/query_cache_test.rb" "test/cases/readonly_test.rb" "test/cases/persistence_test.rb" "test/cases/collection_cache_key_test.rb" "test/cases/counter_cache_test.rb" "test/cases/transactions_test.rb" "test/cases/relation_test.rb" "test/cases/aggregations_test.rb" "test/cases/migration/columns_test.rb" "test/cases/migration/change_schema_test.rb" "test/cases/migration/references_foreign_key_test.rb" "test/cases/migration/references_statements_test.rb" "test/cases/migration/create_join_table_test.rb" "test/cases/migration/command_recorder_test.rb" "test/cases/migration/change_table_test.rb" "test/cases/migration/index_test.rb" "test/cases/migration/column_attributes_test.rb" "test/cases/migration/logger_test.rb" "test/cases/migration/references_index_test.rb" "test/cases/migration/pending_migrations_test.rb" "test/cases/migration/foreign_key_test.rb" "test/cases/migration/compatibility_test.rb" "test/cases/migration/rename_table_test.rb" "test/cases/migration/column_positioning_test.rb" "test/cases/serialization_test.rb" "test/cases/multiparameter_attributes_test.rb" "test/cases/fixture_set/file_test.rb" "test/cases/binary_test.rb" "test/cases/type_test.rb" "test/cases/arel/update_manager_test.rb" "test/cases/arel/delete_manager_test.rb" "test/cases/arel/table_test.rb" "test/cases/arel/attributes/math_test.rb" "test/cases/arel/attributes/attribute_test.rb" "test/cases/arel/crud_test.rb" "test/cases/arel/visitors/to_sql_test.rb" "test/cases/arel/visitors/dot_test.rb" "test/cases/arel/visitors/informix_test.rb" "test/cases/arel/visitors/ibm_db_test.rb" "test/cases/arel/visitors/mssql_test.rb" "test/cases/arel/visitors/oracle12_test.rb" "test/cases/arel/visitors/postgres_test.rb" "test/cases/arel/visitors/oracle_test.rb" "test/cases/arel/visitors/dispatch_contamination_test.rb" "test/cases/arel/visitors/mysql_test.rb" "test/cases/arel/visitors/depth_first_test.rb" "test/cases/arel/visitors/sqlite_test.rb" "test/cases/arel/factory_methods_test.rb" "test/cases/arel/insert_manager_test.rb" "test/cases/arel/attributes_test.rb" "test/cases/arel/collectors/composite_test.rb" "test/cases/arel/collectors/sql_string_test.rb" "test/cases/arel/collectors/bind_test.rb" "test/cases/arel/collectors/substitute_bind_collector_test.rb" "test/cases/arel/nodes/unary_operation_test.rb" "test/cases/arel/nodes/false_test.rb" "test/cases/arel/nodes/distinct_test.rb" "test/cases/arel/nodes/sum_test.rb" "test/cases/arel/nodes/bin_test.rb" "test/cases/arel/nodes/or_test.rb" "test/cases/arel/nodes/ascending_test.rb" "test/cases/arel/nodes/delete_statement_test.rb" "test/cases/arel/nodes/update_statement_test.rb" "test/cases/arel/nodes/not_test.rb" "test/cases/arel/nodes/count_test.rb" "test/cases/arel/nodes/select_core_test.rb" "test/cases/arel/nodes/window_test.rb" "test/cases/arel/nodes/table_alias_test.rb" "test/cases/arel/nodes/infix_operation_test.rb" "test/cases/arel/nodes/named_function_test.rb" "test/cases/arel/nodes/binary_test.rb" "test/cases/arel/nodes/bind_param_test.rb" "test/cases/arel/nodes/true_test.rb" "test/cases/arel/nodes/node_test.rb" "test/cases/arel/nodes/and_test.rb" "test/cases/arel/nodes/select_statement_test.rb" "test/cases/arel/nodes/casted_test.rb" "test/cases/arel/nodes/extract_test.rb" "test/cases/arel/nodes/equality_test.rb" "test/cases/arel/nodes/insert_statement_test.rb" "test/cases/arel/nodes/grouping_test.rb" "test/cases/arel/nodes/descending_test.rb" "test/cases/arel/nodes/as_test.rb" "test/cases/arel/nodes/over_test.rb" "test/cases/arel/nodes/sql_literal_test.rb" "test/cases/arel/nodes/case_test.rb" "test/cases/arel/select_manager_test.rb" "test/cases/arel/nodes_test.rb" "test/cases/calculations_test.rb" "test/cases/reflection_test.rb" "test/cases/inheritance_test.rb" "test/cases/numeric_data_test.rb" "test/cases/validations/presence_validation_test.rb" "test/cases/validations/association_validation_test.rb" "test/cases/validations/i18n_generate_message_validation_test.rb" "test/cases/validations/uniqueness_validation_test.rb" "test/cases/validations/absence_validation_test.rb" "test/cases/validations/i18n_validation_test.rb" "test/cases/validations/length_validation_test.rb" "test/cases/habtm_destroy_order_test.rb" "test/cases/primary_keys_test.rb" "test/cases/transaction_isolation_test.rb" "test/cases/base_test.rb" "test/cases/json_attribute_test.rb" "test/cases/filter_attributes_test.rb" "test/cases/cache_key_test.rb" "test/cases/null_relation_test.rb" "test/cases/connection_specification/resolver_test.rb" "test/cases/time_precision_test.rb" "test/cases/multiple_db_test.rb" "test/cases/i18n_test.rb" "test/cases/relations_test.rb" "test/cases/date_test.rb" "test/cases/attributes_test.rb" "test/cases/nested_attributes_test.rb" "test/cases/locking_test.rb" "test/cases/connection_management_test.rb" "test/cases/column_definition_test.rb" "test/cases/finder_respond_to_test.rb" "test/cases/timestamp_test.rb" "test/cases/reserved_word_test.rb" "test/cases/legacy_configurations_test.rb" "test/cases/callbacks_test.rb" "test/cases/reaper_test.rb" "test/cases/yaml_serialization_test.rb" "test/cases/suppressor_test.rb" "test/cases/relation/merging_test.rb" "test/cases/relation/where_test.rb" "test/cases/relation/or_test.rb" "test/cases/relation/predicate_builder_test.rb" "test/cases/relation/update_all_test.rb" "test/cases/relation/mutation_test.rb" "test/cases/relation/where_clause_test.rb" "test/cases/relation/where_chain_test.rb" "test/cases/relation/delete_all_test.rb" "test/cases/relation/select_test.rb" "test/cases/relation/record_fetch_warning_test.rb" "test/cases/relation/delegation_test.rb" "test/cases/transaction_callbacks_test.rb" "test/cases/log_subscriber_test.rb" "test/cases/batches_test.rb" "test/cases/explain_test.rb" "test/cases/sanitize_test.rb" "test/cases/autosave_association_test.rb" "test/cases/finder_test.rb" "test/cases/serialized_attribute_test.rb" "test/cases/pooled_connections_test.rb" "test/cases/dirty_test.rb" "test/cases/quoting_test.rb" "test/cases/scoping/default_scoping_test.rb" "test/cases/scoping/named_scoping_test.rb" "test/cases/scoping/relation_scoping_test.rb" "test/cases/explain_subscriber_test.rb" "test/cases/result_test.rb" "test/cases/adapters/postgresql/numbers_test.rb" "test/cases/adapters/postgresql/enum_test.rb" "test/cases/adapters/postgresql/ltree_test.rb" "test/cases/adapters/postgresql/xml_test.rb" "test/cases/adapters/postgresql/datatype_test.rb" "test/cases/adapters/postgresql/integer_test.rb" "test/cases/adapters/postgresql/active_schema_test.rb" "test/cases/adapters/postgresql/full_text_test.rb" "test/cases/adapters/postgresql/change_schema_test.rb" "test/cases/adapters/postgresql/hstore_test.rb" "test/cases/adapters/postgresql/infinity_test.rb" "test/cases/adapters/postgresql/composite_test.rb" "test/cases/adapters/postgresql/utils_test.rb" "test/cases/adapters/postgresql/money_test.rb" "test/cases/adapters/postgresql/bit_string_test.rb" "test/cases/adapters/postgresql/case_insensitive_test.rb" "test/cases/adapters/postgresql/domain_test.rb" "test/cases/adapters/postgresql/bytea_test.rb" "test/cases/adapters/postgresql/range_test.rb" "test/cases/adapters/postgresql/collation_test.rb" "test/cases/adapters/postgresql/transaction_test.rb" "test/cases/adapters/postgresql/foreign_table_test.rb" "test/cases/adapters/postgresql/array_test.rb" "test/cases/adapters/postgresql/type_lookup_test.rb" "test/cases/adapters/postgresql/json_test.rb" "test/cases/adapters/postgresql/geometric_test.rb" "test/cases/adapters/postgresql/cidr_test.rb" "test/cases/adapters/postgresql/statement_pool_test.rb" "test/cases/adapters/postgresql/uuid_test.rb" "test/cases/adapters/postgresql/connection_test.rb" "test/cases/adapters/postgresql/serial_test.rb" "test/cases/adapters/postgresql/date_test.rb" "test/cases/adapters/postgresql/schema_authorization_test.rb" "test/cases/adapters/postgresql/citext_test.rb" "test/cases/adapters/postgresql/timestamp_test.rb" "test/cases/adapters/postgresql/referential_integrity_test.rb" "test/cases/adapters/postgresql/network_test.rb" "test/cases/adapters/postgresql/partitions_test.rb" "test/cases/adapters/postgresql/explain_test.rb" "test/cases/adapters/postgresql/schema_test.rb" "test/cases/adapters/postgresql/extension_migration_test.rb" "test/cases/adapters/postgresql/prepared_statements_disabled_test.rb" "test/cases/adapters/postgresql/quoting_test.rb" "test/cases/adapters/postgresql/rename_table_test.rb" "test/cases/adapters/postgresql/postgresql_adapter_test.rb"
Using postgresql
Run options: --seed 37429

# Running:

..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Finished in 208.985626s, 32.6051 runs/s, 86.3696 assertions/s.
6814 runs, 18050 assertions, 0 failures, 0 errors, 2 skips

You have skipped tests. Run with --verbose for details.

@kamipo
Copy link
Member

kamipo commented Nov 12, 2018

that failure is fixed on master by aea9c9a.

@kamipo
Copy link
Member

kamipo commented Nov 12, 2018

This duplicates with #34378.

@gingerlime
Copy link
Contributor Author

Thanks @kamipo. I somehow missed it. Shall I close this one then?

@kamipo
Copy link
Member

kamipo commented Nov 12, 2018

Yeah, we basically discuss it on the first one unless that is stale or inactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants