How I accidentally slowed gr1d's server to a crawl... [modified]
-
Before I get started, some background: gr1d[^] is a (very new) persistent multiplayer programming AI game: the idea is you code your agents and upload them, and let them do their thing. (Check it out, if you haven't!) Now, with these agents, they have to inherit an interface. For brevity, I'll reduce it to the relevant details:
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
' Logic here
End Sub(VB is NOT the code horror, thank you very much! :P ) Now, in my infinite wisdom, I started some abstractions. This included building it so all AIs under that schema (my search/claim/don't go picking fights) operated under the same logic. How'd I do this? Well:
Public Module Logic
Public Sub Tick(ByVal agent As πRateSapient, ByVal update As Agent.IAgentUpdateInfo)
' Logic here
End Sub... Can you see where this is going? I didn't.
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
Me.Tick(agentUpdate)
End Sub... No debugging, no thought put into it, I just thought it'd call the extension method. Whoops. And yeah, it was sloooow. Moral of the story folks: think about your damn naming conventions, especially if you're using extension methods!!! :doh: (And I was wondering why my agents did nothing!) (Also, may I mention that running the game logic, and the site, on the same instance is also a bit of a horror?) Hope you laughed. :laugh: [edit] To be fair, I wasn't the only one with a recursive loop. But I sure as hell didn't help. xD [/edit]
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
modified on Wednesday, December 22, 2010 6:05 AM
-
Before I get started, some background: gr1d[^] is a (very new) persistent multiplayer programming AI game: the idea is you code your agents and upload them, and let them do their thing. (Check it out, if you haven't!) Now, with these agents, they have to inherit an interface. For brevity, I'll reduce it to the relevant details:
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
' Logic here
End Sub(VB is NOT the code horror, thank you very much! :P ) Now, in my infinite wisdom, I started some abstractions. This included building it so all AIs under that schema (my search/claim/don't go picking fights) operated under the same logic. How'd I do this? Well:
Public Module Logic
Public Sub Tick(ByVal agent As πRateSapient, ByVal update As Agent.IAgentUpdateInfo)
' Logic here
End Sub... Can you see where this is going? I didn't.
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
Me.Tick(agentUpdate)
End Sub... No debugging, no thought put into it, I just thought it'd call the extension method. Whoops. And yeah, it was sloooow. Moral of the story folks: think about your damn naming conventions, especially if you're using extension methods!!! :doh: (And I was wondering why my agents did nothing!) (Also, may I mention that running the game logic, and the site, on the same instance is also a bit of a horror?) Hope you laughed. :laugh: [edit] To be fair, I wasn't the only one with a recursive loop. But I sure as hell didn't help. xD [/edit]
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
modified on Wednesday, December 22, 2010 6:05 AM
Note that extension methods with the same name and signature as an interface or class method will never be called. http://msdn.microsoft.com/en-us/library/bb383977.aspx[^]
Dwayne J. Baldwin
-
Before I get started, some background: gr1d[^] is a (very new) persistent multiplayer programming AI game: the idea is you code your agents and upload them, and let them do their thing. (Check it out, if you haven't!) Now, with these agents, they have to inherit an interface. For brevity, I'll reduce it to the relevant details:
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
' Logic here
End Sub(VB is NOT the code horror, thank you very much! :P ) Now, in my infinite wisdom, I started some abstractions. This included building it so all AIs under that schema (my search/claim/don't go picking fights) operated under the same logic. How'd I do this? Well:
Public Module Logic
Public Sub Tick(ByVal agent As πRateSapient, ByVal update As Agent.IAgentUpdateInfo)
' Logic here
End Sub... Can you see where this is going? I didn't.
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1...
Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
Me.Tick(agentUpdate)
End Sub... No debugging, no thought put into it, I just thought it'd call the extension method. Whoops. And yeah, it was sloooow. Moral of the story folks: think about your damn naming conventions, especially if you're using extension methods!!! :doh: (And I was wondering why my agents did nothing!) (Also, may I mention that running the game logic, and the site, on the same instance is also a bit of a horror?) Hope you laughed. :laugh: [edit] To be fair, I wasn't the only one with a recursive loop. But I sure as hell didn't help. xD [/edit]
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
modified on Wednesday, December 22, 2010 6:05 AM
-
Note that extension methods with the same name and signature as an interface or class method will never be called. http://msdn.microsoft.com/en-us/library/bb383977.aspx[^]
Dwayne J. Baldwin
Kinda learned that one, didn't I? :P
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."