-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path caching #1595
path caching #1595
Conversation
94d9c7b
to
ceae4ef
Compare
4b976fb
to
800ce11
Compare
be197fe
to
97fe6b0
Compare
800ce11
to
c5661c0
Compare
97fe6b0
to
23b914d
Compare
23b914d
to
2fc6257
Compare
c5661c0
to
2a571ca
Compare
2a571ca
to
86de12b
Compare
86de12b
to
195f81e
Compare
47ba7ff
to
05f7624
Compare
3d121a5
to
2442db2
Compare
This simplifies the implementation of #1595.
88bb8af
to
709bda4
Compare
6812c1e
to
1a1d577
Compare
1a1d577
to
2ffe099
Compare
@@ -74,6 +72,9 @@ updateEntityAt cLoc@(Cosmic subworldName loc) upd = do | |||
wakeWatchingRobots cLoc | |||
SRT.entityModified modType cLoc | |||
|
|||
pcr <- use $ pathCaching . pathCachingRobots | |||
mapM_ (revalidatePathCache cLoc modType) $ IM.toList pcr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache invalidation callback is here.
2ffe099
to
8df24b5
Compare
8df24b5
to
22a1a39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kostmo , thanks so much for the detailed comments and the amazing attention to detail with the whole cache logging system + tests!
I must admit I was skeptical of the idea of shortest path caching initially --- I was worried about performance, etc. --- but (1) the Horton's flower scenario is fun, and is a convincing demonstration of the utility of path caching, and (2) I am convinced that this will have minimal/zero impact whenever the path
command is not being used.
I would love to eventually see a series of challenges introducing the path
command (not saying you have to develop them).
Co-authored-by: Brent Yorgey <byorgey@gmail.com>
02d36d3
to
de162cc
Compare
Closes #1569
Performance
Path cache invalidation upon world modifications (i.e. entities inserted or removed) entails iterating over all of the previously-cached paths here. For efficiency's sake, we avoid iterating over "all existing robots".
Any scenario that does not use the
path
command is entirely unaffected by this change.Demo
Previously, this demo was virtually unplayable, since when moving between widely-spaced "clusters" of flowers, an expensive A-star search was invoked at almost every tick. Now, the vast majority of moves utilize the cache, and the demo exhibits minimal stuttering (e.g. when a single A-star search is performed when moving between distant clusters).
Event log
An event log specific to the path cache is maintained with its own ring buffer:
and view http://localhost:5357/paths/log