You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/07/17 02:51:58 UTC
[GitHub] [skywalking] wu-sheng commented on a change in pull request #7318: Logically revert #6642 and partial #7153 to reduce unnecessary thread and concurrency process
wu-sheng commented on a change in pull request #7318:
URL: https://github.com/apache/skywalking/pull/7318#discussion_r671597729
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java
##########
@@ -104,167 +92,51 @@ public void start(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
}
private void extractDataAndSave(IBatchDAO batchDAO) {
-
if (log.isDebugEnabled()) {
log.debug("Extract data and save");
}
long startTime = System.currentTimeMillis();
- HistogramMetrics.Timer allTimer = allLatency.createTimer();
- // Use `stop` as a control signal to make fail-fast in the persistence process.
- AtomicBoolean stop = new AtomicBoolean(false);
- DefaultBlockingBatchQueue<PrepareRequest> prepareQueue = new DefaultBlockingBatchQueue(
- this.maxSyncOperationNum);
- try {
+ try (HistogramMetrics.Timer allTimer = allLatency.createTimer()) {
List<PersistenceWorker<? extends StorageData>> persistenceWorkers = new ArrayList<>();
persistenceWorkers.addAll(TopNStreamProcessor.getInstance().getPersistentWorkers());
persistenceWorkers.addAll(MetricsStreamProcessor.getInstance().getPersistentWorkers());
- // CountDownLatch makes sure all prepare threads done eventually.
- CountDownLatch prepareStageCountDownLatch = new CountDownLatch(persistenceWorkers.size());
-
+ CountDownLatch countDownLatch = new CountDownLatch(persistenceWorkers.size());
persistenceWorkers.forEach(worker -> {
prepareExecutorService.submit(() -> {
- if (stop.get()) {
- prepareStageCountDownLatch.countDown();
- return;
- }
-
- HistogramMetrics.Timer timer = prepareLatency.createTimer();
- try {
+ try (HistogramMetrics.Timer timer = prepareLatency.createTimer()) {
if (log.isDebugEnabled()) {
log.debug("extract {} worker data and save", worker.getClass().getName());
}
List<PrepareRequest> innerPrepareRequests = new ArrayList<>(5000);
worker.buildBatchRequests(innerPrepareRequests);
- // Push the prepared requests into DefaultBlockingBatchQueue,
- // the executorService consumes from it when it reaches the size of batch.
- prepareQueue.offer(innerPrepareRequests);
- worker.endOfRound();
- } finally {
- timer.finish();
- prepareStageCountDownLatch.countDown();
- }
- });
- });
- List<Future<?>> batchFutures = new ArrayList<>();
- for (int i = 0; i < syncOperationThreadsNum; i++) {
- Future<?> batchFuture = executorService.submit(() -> {
- // consume the metrics
- while (!stop.get()) {
- List<PrepareRequest> partition = prepareQueue.poll();
- if (partition.isEmpty()) {
- break;
- }
- HistogramMetrics.Timer executeLatencyTimer = executeLatency.createTimer();
- try {
- if (CollectionUtils.isNotEmpty(partition)) {
- batchDAO.flush(partition);
+ try (HistogramMetrics.Timer executeLatencyTimer = executeLatency.createTimer()) {
Review comment:
I will fix this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org