{"issue":{"milestone":null,"user":{"id":52733,"login":"adum","url":"https://api.github.com/users/adum","avatar_url":"https://secure.gravatar.com/avatar/61c6f5907efc093b91e8d1cd53443f76?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"61c6f5907efc093b91e8d1cd53443f76"},"title":"SQLite integration","created_at":"2011-12-11T00:59:53Z","labels":[],"updated_at":"2011-12-17T22:35:46Z","state":"open","id":2514196,"html_url":"https://github.com/justinweiss/dragongoclient/issues/6","closed_at":null,"pull_request":{"patch_url":"https://github.com/justinweiss/dragongoclient/pull/6.patch","html_url":"https://github.com/justinweiss/dragongoclient/pull/6","diff_url":"https://github.com/justinweiss/dragongoclient/pull/6.diff"},"body":"this branch is all about speeding up the client. i play about 40 games at a time, and need it to go quickly! :)\r\n\r\nThis set of changes integrates SQLite into the client, storing game records in a local database. when the table page becomes visible, it only reloads the games if the interval has passed (5 mins by default). previously, it would reload every time you made a move.\r\n\r\nafter the game list has loaded, the app tries to prefetch the SGF for each game in the background such that loading is instant and doesn't require a network fetch.\r\n\r\nin FuegoBoard, there was an O(n^2) operation for loading games, where it called GoInDirection repeatedly until the end. the problem was that GoInDirection internally executed every node up to the new node for each step due to what i would call internal Fuego laziness. now it skips to the end quickly. this cuts two or three seconds off a game load on my iphone 4 for games that have a lot of moves.\r\n\r\nin the original, after submitting a move, the app would wait to confirm its acceptance before continuing. that delay drove me nuts, so i simply took that out confirmation, which works 98% of the time for me. 2% of the time it fails to submit the move and you have to redo it later. this i need to fix by saving moves into SQLite and doing them in the background, which would also enable true offline play.","number":6,"url":"https://api.github.com/repos/justinweiss/dragongoclient/issues/6","comments":1,"assignee":null},"comment":{"user":{"id":1020,"login":"justinweiss","url":"https://api.github.com/users/justinweiss","avatar_url":"https://secure.gravatar.com/avatar/81cb8ff8ba584785c33bc786997624bc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"81cb8ff8ba584785c33bc786997624bc"},"created_at":"2011-12-17T22:35:46Z","updated_at":"2011-12-17T22:35:46Z","id":3191922,"body":"Looks great so far. \r\n\r\nSomething I was thinking about, though, was if there was a way to encapsulate the sqlite3 logic in its own class (or classes). I wonder if the caching code could become a CachingGameServer, that could do what it needs to in order to cache and return the correct data, and proxy any network access to another GameServer (like DGS or DGSDev). You'd then talk to an instance of CachingGameServer, which would do sqlite access, proxy network access or calls it doesn't handle to DGS, and return either the network data or the cached data immediately to the controllers. \r\n\r\nI think this would allow you to get the caching logic outside of the controllers and DGS.m. It would probably make things easier to maintain and test, especially because it would make it easy to temporarily disable the caching to remove some moving parts when trying to develop or debug new network-facing features. It'd also probably let us remove some of the changes you had to make to special-case around the caching.\r\n\r\nDoes that make sense? I could also be completely missing something, and it might not work as cleanly as I think it will, but it's the first thing that came to my mind :-)\r\n\r\nGreat work with the perf boost too, that's an issue I'd been meaning to take a look at for a while, but hadn't got around to investigating. Towards the end of games it currently gets pretty slow :-)\r\n\r\nThe code looks good. I don't have much feedback yet as far as specifics are concerned, but I'd like to know what you think about refactoring some of the sqlite code, and once we get closer to integrating this, I'll probably be able to come up with more feedback. Thanks for the patch, this will definitely be worth getting into the app!","url":"https://api.github.com/repos/justinweiss/dragongoclient/issues/comments/3191922"},"action":"created"}