|
@@ -78,7 +78,7 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
long time1 = System.currentTimeMillis();
|
|
|
|
|
|
- List<AdRankItem> adRankItems = new ArrayList<>(request.getAdIdList().size());
|
|
|
+ List<AdRankItem> adRankItems = new ArrayList<>();
|
|
|
Random random = new Random();
|
|
|
long time2 = 0;
|
|
|
if (similarityConcurrent) {
|
|
@@ -145,57 +145,67 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
} else {
|
|
|
|
|
|
List<Future<AdRankItem>> futures = new ArrayList<>();
|
|
|
+ CountDownLatch cdl1 = new CountDownLatch(adRankItems.size());
|
|
|
for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
Future<AdRankItem> future = ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
AdRankItem adRankItem = new AdRankItem();
|
|
|
- adRankItem.setAdId(dto.getCreativeId());
|
|
|
- adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
- adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
- adRankItem.setVideoId(request.getVideoId());
|
|
|
- adRankItem.setCpa(dto.getCpa());
|
|
|
- adRankItem.setId(dto.getAdId());
|
|
|
- adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
- adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
- adRankItem.setRandom(random.nextInt(1000));
|
|
|
-
|
|
|
- String cidStr = dto.getCreativeId().toString();
|
|
|
- Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
- Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
|
- Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
-
|
|
|
- Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
+ try {
|
|
|
+ adRankItem.setAdId(dto.getCreativeId());
|
|
|
+ adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
+ adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
+ adRankItem.setVideoId(request.getVideoId());
|
|
|
+ adRankItem.setCpa(dto.getCpa());
|
|
|
+ adRankItem.setId(dto.getAdId());
|
|
|
+ adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
+ adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
+ adRankItem.setRandom(random.nextInt(1000));
|
|
|
+
|
|
|
+ String cidStr = dto.getCreativeId().toString();
|
|
|
+ Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, new HashMap<>());
|
|
|
+ Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", new HashMap<>());
|
|
|
|
|
|
- Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
+ Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), new HashMap<>());
|
|
|
|
|
|
- this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
+ Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", new HashMap<>());
|
|
|
|
|
|
- this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
+ this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
|
|
|
- this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
+ this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
|
- this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
+ this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
|
|
|
- this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
+ this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
|
|
|
- this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
+ this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
|
|
|
+ this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
+ return adRankItem;
|
|
|
+ } finally {
|
|
|
+ cdl1.countDown();
|
|
|
+ }
|
|
|
// adRankItem.setFeatureMap(cidFeatureMap);
|
|
|
-
|
|
|
- return adRankItem;
|
|
|
});
|
|
|
futures.add(future);
|
|
|
}
|
|
|
+ try {
|
|
|
+ cdl1.await(200, TimeUnit.MILLISECONDS);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
+ }
|
|
|
for (Future<AdRankItem> future : futures) {
|
|
|
try {
|
|
|
- adRankItems.add(future.get(200, TimeUnit.MILLISECONDS));
|
|
|
+ if (future.isDone()) {
|
|
|
+ adRankItems.add(future.get());
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
- log.error("Feature handle time out >200ms", e);
|
|
|
+ log.error("Feature handle error", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
time2 = System.currentTimeMillis();
|
|
|
|
|
|
- CountDownLatch cdl = new CountDownLatch(adRankItems.size());
|
|
|
+ CountDownLatch cdl2 = new CountDownLatch(adRankItems.size());
|
|
|
for (AdRankItem item : adRankItems) {
|
|
|
ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
try {
|
|
@@ -206,12 +216,12 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap());
|
|
|
this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap());
|
|
|
} finally {
|
|
|
- cdl.countDown();
|
|
|
+ cdl2.countDown();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
try {
|
|
|
- cdl.await(200, TimeUnit.MILLISECONDS);
|
|
|
+ cdl2.await(200, TimeUnit.MILLISECONDS);
|
|
|
} catch (Exception e) {
|
|
|
log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
}
|
|
@@ -269,7 +279,8 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
}
|
|
|
|
|
|
long time6 = System.currentTimeMillis();
|
|
|
- log.info("cost={}, feature1={}, feature={}, feature3={}, feature4={}, getScorerPipeline={}, loop={}",
|
|
|
+ log.info("cost={}, feature1={}, feature={}, feature3={}, feature4={}, getScorerPipeline={}, loop={}, " +
|
|
|
+ "adIdSize={}, adRankItemsSize={}",
|
|
|
time6 - start, time1 - start, time2 - time1, time3 - time2, time4 - time3, time5 - time4,
|
|
|
time6 - time5);
|
|
|
|