has_many_polymorphs icon indicating copy to clipboard operation
has_many_polymorphs copied to clipboard

Development performance

Open chriseppstein opened this issue 16 years ago • 7 comments

The runtime performance of hmp is killing me in development mode. How can we make this better? Code generation maybe? I'm willing to help build it.

chriseppstein avatar Sep 04 '09 00:09 chriseppstein

What part of it is slow?

ghost avatar Sep 04 '09 00:09 ghost

I have this declaration:

acts_as_double_polymorphic_join(
  :parents => [:pages],
  :children => [:pages] + Item.type_names(:primary => true),
  :children_order => "parent_children.position ASC"
)

And every request does this:

** has_many_polymorphs: associating Page.parents
** has_many_polymorphs: associating Article.parents
** has_many_polymorphs: associating BlogPost.parents
** has_many_polymorphs: associating BuyingGuide.parents
** has_many_polymorphs: associating Calculator.parents
** has_many_polymorphs: associating Checklist.parents
** has_many_polymorphs: associating CommunityPost.parents
** has_many_polymorphs: associating CommunityDiscussion.parents
** has_many_polymorphs: associating Quiz.parents
** has_many_polymorphs: associating MedicareInformation.parents
** has_many_polymorphs: associating News.parents
** has_many_polymorphs: associating Poll.parents
** has_many_polymorphs: associating Question.parents
** has_many_polymorphs: associating Task.parents
** has_many_polymorphs: associating Tip.parents
** has_many_polymorphs: associating ToDoList.parents
** has_many_polymorphs: associating Interview.parents
** has_many_polymorphs: associating Reflection.parents
** has_many_polymorphs: preloading parent model Tag
** has_many_polymorphs: associating Tag.taggables

chriseppstein avatar Sep 04 '09 00:09 chriseppstein

There is some env flag that causes it to generate code, which you could paste in...otherwise...cache_classes = true?

ghost avatar Sep 04 '09 00:09 ghost

I tried caching classes. it's not a better solution. The acts_as_double_polymorphic_join declaration rarely changes... it seems silly to do a bunch of work with every request instead of when the declaration changes.

I saw the code generation stuff. I was wondering if we could productize that with some rake tasks, etc.

chriseppstein avatar Sep 04 '09 00:09 chriseppstein

That seems like it would work...optional way to cache the declarations only, basically.

ghost avatar Sep 04 '09 00:09 ghost

are the "declarations" the hard work that hmp performs?

chriseppstein avatar Sep 04 '09 00:09 chriseppstein

yeah...setting up all the association declarations for you.

ghost avatar Sep 04 '09 00:09 ghost