-
Notifications
You must be signed in to change notification settings - Fork 19
fix: Migrate persistent kernel stats to Redis to reduce database txn overheads #532
Conversation
Codecov Report
@@ Coverage Diff @@
## main #532 +/- ##
==========================================
- Coverage 49.37% 49.20% -0.18%
==========================================
Files 55 55
Lines 9008 9079 +71
==========================================
+ Hits 4448 4467 +19
- Misses 4560 4612 +52
Continue to review full report at Codecov.
|
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.
Just two minor code issues.
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.
leave a minor comment.
@@ -311,12 +314,23 @@ async def get_container_stats_for_period(request: web.Request, start_date, end_d | |||
result = await conn.execute(query) | |||
rows = result.fetchall() | |||
|
|||
async def _pipe_builder(r: Redis) -> RedisPipeline: |
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.
굉장히 사소하긴 하지만, 여기 async가 없어도 되나요?
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.
good catch 👍
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.
No, that's wrong;;;
https://github.com/lablup/backend.ai-common/blob/main/src/ai/backend/common/redis.py#L228-L234
It should return just pipeline, not awaitable of pipeline!
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.
common.redis.execute()
accepts a function that returns either:
- async function that executes Redis commands
- non-async function that returns a Redis pipeline to execute
To use pipeline, the callable must NOT be async.
I just added a PR to allow async pipeline builders: lablup/backend.ai-common#125. |
* Statistics are stored and queried per-container (=per-kernel), not per-session. * SessionStatistics should be implemented separately by aggregating its belong KernelStatistics.
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.
I think it's better to merge redis clear-history
with clear-history
command. How about your thoughts?
* Introduce more-itertools as a new dependency * Use attr-class instead of typed dict - When there is no need for serialization, it's generally faster and safer to use typed attr-classes or dataclasses. * Adjust the log message for Redis stats records cleanup.
This PR resolves lablup/backend.ai#348.