|
@@ -62,11 +62,17 @@ public class TopRecommendPipeline {
|
|
|
|
|
|
public List<Video> feeds(final RecommendRequest requestData,
|
|
|
final int requestIndex,
|
|
|
- final User userInfo, Boolean logPrint) {
|
|
|
+ final User userInfo, Boolean logPrint,
|
|
|
+ Map<String, String> timeLogMap) {
|
|
|
// Step 1: Attention extraction
|
|
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
|
|
stopwatch.reset().start();
|
|
|
- List<RankItem> rankItems = feedByRec(requestData, requestIndex, userInfo, logPrint);
|
|
|
+ timeLogMap.put("uid", userInfo.getUid());
|
|
|
+ timeLogMap.put("mid", userInfo.getMid());
|
|
|
+ timeLogMap.put("requestId", requestData.getRequestId());
|
|
|
+
|
|
|
+ List<RankItem> rankItems = feedByRec(requestData, requestIndex, userInfo, logPrint, timeLogMap);
|
|
|
+ timeLogMap.put("feedByRec", stopwatch.elapsed().toMillis() + "");
|
|
|
if (rankItems == null || rankItems.isEmpty()) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
@@ -76,6 +82,7 @@ public class TopRecommendPipeline {
|
|
|
}
|
|
|
stopwatch.reset().start();
|
|
|
List<Video> videos = rankItem2Video(rankItems);
|
|
|
+ timeLogMap.put("rankItem2Video", stopwatch.elapsed().toMillis() + "");
|
|
|
if (logPrint) {
|
|
|
log.info("traceId = {}, cost = {}, videos = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(videos));
|
|
@@ -116,9 +123,9 @@ public class TopRecommendPipeline {
|
|
|
|
|
|
public List<RankItem> feedByRec(final RecommendRequest requestData,
|
|
|
final int requestIndex,
|
|
|
- final User userInfo, Boolean logPrint) {
|
|
|
+ final User userInfo, Boolean logPrint,
|
|
|
+ Map<String, String> timeLogMap) {
|
|
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
|
|
-
|
|
|
// Step 2: create top queue
|
|
|
stopwatch.reset().start();
|
|
|
StrategyQueue topQueue = MergeUtils.createTopQueue(MERGE_CONF, "top-queue");
|
|
@@ -126,6 +133,7 @@ public class TopRecommendPipeline {
|
|
|
log.info("traceId = {}, cost = {}, topQueue = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(topQueue));
|
|
|
}
|
|
|
+ timeLogMap.put("createTopQueue", stopwatch.elapsed().toMillis() + "");
|
|
|
|
|
|
// Step 3: Candidate
|
|
|
stopwatch.reset().start();
|
|
@@ -135,6 +143,7 @@ public class TopRecommendPipeline {
|
|
|
log.info("traceId = {}, cost = {}, candidates = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(candidates));
|
|
|
}
|
|
|
+ timeLogMap.put("topQueue-candidate-cost", stopwatch.elapsed().toMillis() + "");
|
|
|
|
|
|
|
|
|
// Step 4: Recalling & Basic Scoring
|
|
@@ -145,7 +154,8 @@ public class TopRecommendPipeline {
|
|
|
log.info("traceId = {}, cost = {}, items = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(items));
|
|
|
}
|
|
|
-
|
|
|
+ timeLogMap.put("recalling-cost", stopwatch.elapsed().toMillis() + "");
|
|
|
+ timeLogMap.put("recalling-size", items == null ? "0" : items.size() + "");
|
|
|
|
|
|
// Step 4: Advance Scoring
|
|
|
// timestamp = System.currentTimeMillis();
|
|
@@ -167,6 +177,9 @@ public class TopRecommendPipeline {
|
|
|
}
|
|
|
duplicate(mergeItems);
|
|
|
|
|
|
+ timeLogMap.put("mergeItems-cost", stopwatch.elapsed().toMillis() + "");
|
|
|
+ timeLogMap.put("mergeItems-size", mergeItems.size() + "");
|
|
|
+
|
|
|
if (logPrint) {
|
|
|
log.info("traceId = {}, cost = {}, mergeItems = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(mergeItems));
|
|
@@ -177,11 +190,14 @@ public class TopRecommendPipeline {
|
|
|
// TODO 前置和后置处理逻辑 hardcode,后续优化
|
|
|
stopwatch.reset().start();
|
|
|
List<RankItem> rovRecallRankNewScore = rankByScore(mergeItems, requestData);
|
|
|
+
|
|
|
+ timeLogMap.put("rankByScore-cost", stopwatch.elapsed().toMillis() + "");
|
|
|
+ timeLogMap.put("rankByScore-size", rovRecallRankNewScore.size() + "");
|
|
|
+
|
|
|
if (logPrint) {
|
|
|
log.info("traceId = {}, cost = {}, rovRecallRankNewScore = {}", requestData.getRequestId(),
|
|
|
stopwatch.elapsed().toMillis(), JSONUtils.toJson(rovRecallRankNewScore));
|
|
|
}
|
|
|
-
|
|
|
return rovRecallRankNewScore;
|
|
|
}
|
|
|
|