Go to Post Achieving a goal by merely finishing, or reaching mediocrity is not acceptable; Excellence is the only satisfactory result. - AdamHeard [more]
Home
Go Back   Chief Delphi > Other > FIRST-related Organizations > The Blue Alliance
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-07-2010, 17:55
Andrew Schreiber Andrew Schreiber is offline
Data Nerd
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,055
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: [TBA]: TBATV v4 Development Log

Quote:
Originally Posted by Greg Marra View Post
Memcached will play a large role in reducing CPU usage as well. By memcaching certain requests like "give me the HTML for Connecticut 2010's matches", we can dodge hitting the datastore at all, instead making a single memcached call. We'll expire these memcached objects when we make updates to the underlying data they hold (such as getting new Match results), but this should be particularly useful for page views (fast!) and API calls from other apps (repetitive!).
Instead of memcaching the html you could memcache the data and fill in a django template with it. To me that seems like the cleanest way of putting data into HTML files without mixing python code in with html code.
__________________




.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-07-2010, 20:53
Greg Marra's Avatar Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
no team (The Blue Alliance)
Team Role: RoboCoach
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: [TBA]: TBATV v4 Development Log

Quote:
Originally Posted by Andrew Schreiber View Post
Instead of memcaching the html you could memcache the data and fill in a django template with it. To me that seems like the cleanest way of putting data into HTML files without mixing python code in with html code.
This is probably what we'll end up doing. I don't think rendering templates is very expensive compared to everything else, so that should be clean and easy.
__________________
Formerly Bobcat Robotics - Team 177 and X-Factor - Team 2124, now The Blue Alliance
Reply With Quote
  #3   Spotlight this post!  
Unread 02-07-2010, 20:55
Greg Marra's Avatar Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
no team (The Blue Alliance)
Team Role: RoboCoach
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: [TBA]: TBATV v4 Development Log

Here is a screenshot of AppStats showing the problem with the Match, MatchTeam, MatchScore object model. All of the database gets and puts to insert a Match add up to a lot of CPU time.

I wonder if storing everything in Match using a red1, red2, red3, blue1, blue2, blue3 system or a red_teams, blue_teams list reference property is a better idea. I'd really love for these relation objects to be faster, but when we render a full event worth of matches, it takes almost 20 seconds.

Does anyone know if it is possible to non-lazily query a bunch of objects ReferenceProperties all at once? Like say, "I want all the Matches, and their MatchTeam objects, and the Team objects on the other end of those"?
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2010-07-02 at 8.53.14 PM.jpg
Views:	63
Size:	72.1 KB
ID:	9183  
__________________
Formerly Bobcat Robotics - Team 177 and X-Factor - Team 2124, now The Blue Alliance

Last edited by Greg Marra : 02-07-2010 at 21:22.
Reply With Quote
  #4   Spotlight this post!  
Unread 31-07-2010, 14:11
Greg Marra's Avatar Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
no team (The Blue Alliance)
Team Role: RoboCoach
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: [TBA]: TBATV v4 Development Log

I am going to change the Match model to be less flexible so we can speed up datastore performance.

I am thinking we will have a Match have Match.teams, which will be a ListProperty that stores the Teams in the match. Separately, we will store Match.alliances, which will contain a dictionary shaped like {"red": ["frc177", "frc195", "frc125"], "blue": ["frc433", "frc190", "frc222"]}. The teams property will basically be an index to let us quickly search by team, and the alliances property will store the actual structure of the alliances.

We'll add another property to Matches called "game", where we write down which FRC game was being played. This way, if they change the game structure in the future (or we get data on past games), we'll easily be able to adjust Controllers to handle it without having to muck with the model.

New concept:
Code:
class Match(db.Model):
    """
    Matches represent individual matches at Events.
    Matches have many Videos.
    key_name is like 2010ct_qm10 or 2010ct_sf1m2
    """
    event = db.ReferenceProperty(Event,
                                 required=True)
    time = db.DateTimeProperty()
    comp_level = db.StringProperty(required=True,choices=set(["Qualifications", "Quarterfinals", "Semifinals", "Finals"])) # This choices set should probably become a global Constant somewhere. How do you do that in Python properly? -greg 5/20/2010
    set_number = db.IntegerProperty(required=True)
    match_number = db.IntegerProperty(required=True)
    teams = db.ListProperty(Team) #Primarily for indexing and searching
    alliances = db.StringProperty #Store a Dictionary as a JSON string
    scores = db.StringProperty #Store a Dictionary as a JSON string
This will reduce the number of Datastore lookups to display a Match (assuming we're not interested in more than the team number) by just under an order of magnitude. I think that's a good thing!

Similarly, by changing from having a bunch of EventTeam objects, we could make teams a ListProperty of an Event. Then to get all of the Teams at an Event would require just finding the Event, instead of finding all of the EventTeams. This is switching away from a many-to-many relationship to many one-to-many relationships.

I haven't had much time to work on development, but I think these new ideas will remove some of the major roadblocks that existed.
__________________
Formerly Bobcat Robotics - Team 177 and X-Factor - Team 2124, now The Blue Alliance
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TBA]: [TBA] Curie 2006 and soap108.com jblay The Blue Alliance 3 21-04-2010 00:25
[TBA]: Kickoff 2009 Liveblogging Site Development Greg Marra The Blue Alliance 23 30-12-2008 18:37
[TBA]: h.264 Video Analysis, and Improving TBATV Video Quality artdutra04 The Blue Alliance 5 29-09-2008 00:29
[TBA]: API Client Development Greg Marra The Blue Alliance 21 04-05-2008 20:06
[TBA] TBA Presents... Soldering and Multimeter Tutorials Greg Marra General Forum 0 27-01-2007 20:15


All times are GMT -5. The time now is 19:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi