You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by "lewismc (via GitHub)" <gi...@apache.org> on 2026/03/11 13:25:14 UTC
[PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
lewismc opened a new pull request, #906:
URL: https://github.com/apache/nutch/pull/906
PR for [NUTCH-3162](https://issues.apache.org/jira/browse/NUTCH-3162) which addresses shortcomings in job-level latency percentiles (p50, p95, p99) for Fetcher, ParseSegment, and Indexer by merging TDigest data from all map tasks and threads and writing counters in a single reducer (or a dedicated merge job for Indexer). It should fix the cases where per-task counters were summed and percentiles were not merged.
This patch touches the following jobs
* Fetcher: Per-thread latency merged in mapper; single reducer merges TDigests and sets job-level p50/p95/p99.
* ParseSegment:
* Mapper emits latency digest under `LATENCY_KEY`
* Custom partitioner sends `LATENCY_KEY` to partition 0 so one reducer merges all TDigests
* Reducer merges and sets correct percentile counters.
* Indexer:
* Reducer writes TDigest to side output
* IndexingJob runs *a new* “Indexer Latency Merge” job which merges reducer sets percentile counters. On merge failure: `LOG.error` and driver-level `ErrorTracker` categorization is only run.
I think this fixes the issues. Arguably it is more complex than logging to file and performing some ETL to extract metrics from logs however this solution does stick with convention by keeping metrics within the Hadoop ecosystem.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-4041328628
## [](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) **Quality Gate failed**
Failed conditions
 [43.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_nutch&pullRequest=906&metric=new_coverage&view=list) (required ≥ 80%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906)
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-4039380397
## [](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) **Quality Gate failed**
Failed conditions
 [36.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_nutch&pullRequest=906&metric=new_coverage&view=list) (required ≥ 80%)
 [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) (required ≥ A)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Fetcher and Parser latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-5041077207
Thanks for review @sebastian-nagel I attached the Indexer changes patch to https://issues.apache.org/jira/browse/NUTCH-3190 and will come back around to it in 1.24 development drive as I am strapped for time right now.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on code in PR #906:
URL: https://github.com/apache/nutch/pull/906#discussion_r2920120575
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -143,6 +145,8 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
+ RANDOM.nextInt());
FileOutputFormat.setOutputPath(job, tmp);
+ // Driver-level error tracking: categorization + LOG.error only (no job counters; see ErrorTracker Javadoc).
Review Comment:
I've put this comment in here for the time being. Ultimately I think it is fine to track driver-level errors in memory (via errorTracker) even though they are not written to the MapReduce counter(s). I've documented this behavior in ErrorTracker.java.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Fetcher and Parser latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-5041063757
## [](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) **Quality Gate failed**
Failed conditions
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_nutch&pullRequest=906&metric=new_coverage&view=list) (required ≥ 80%)
<!-- sqra:qg_revision=28e114f57c704c3eaaf18660c316fd30135d058ae6799bf9030583a308967827 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906)
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sebastian-nagel (via GitHub)" <gi...@apache.org>.
sebastian-nagel commented on code in PR #906:
URL: https://github.com/apache/nutch/pull/906#discussion_r3057465896
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -155,6 +159,25 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
LOG.error(StringUtils.stringifyException(e));
throw e;
}
+ Path latencyDir = new Path(tmp, "_latency");
+ FileSystem fs = tmp.getFileSystem(conf);
+ if (fs.exists(latencyDir)) {
+ try (Job mergeJob = IndexerMapReduce.createLatencyMergeJob(conf, latencyDir)) {
+ FileOutputFormat.setOutputPath(mergeJob, new Path(tmp, "_latency_merge_out"));
+ boolean mergeSuccess = mergeJob.waitForCompletion(true);
Review Comment:
Looked into [SequenceFileInputFormat.listStatus](https://hadoop.apache.org/docs/current/api/org/apache/hadoop/mapreduce/lib/input/SequenceFileInputFormat.html#listStatus(org.apache.hadoop.mapreduce.JobContext)): it either takes a single file or a directory tree with sequence files `_latency/part-xxx/data`.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sebastian-nagel (via GitHub)" <gi...@apache.org>.
sebastian-nagel commented on code in PR #906:
URL: https://github.com/apache/nutch/pull/906#discussion_r3053657797
##########
src/java/org/apache/nutch/parse/ParseSegment.java:
##########
@@ -98,15 +100,18 @@ public void setup(Mapper<WritableComparable<?>, Content, Text, ParseImpl>.Contex
}
@Override
- public void cleanup(Mapper<WritableComparable<?>, Content, Text, ParseImpl>.Context context)
+ public void cleanup(Mapper<WritableComparable<?>, Content, Text, Writable>.Context context)
throws IOException, InterruptedException {
- // Emit parse latency metrics
- parseLatencyTracker.emitCounters(context);
+ parseLatencyTracker.emitCountAndSumOnly(context);
+ byte[] digestBytes = parseLatencyTracker.toBytes();
+ if (digestBytes.length > 0) {
+ context.write(new Text(NutchMetrics.LATENCY_KEY), new BytesWritable(digestBytes));
Review Comment:
This makes the job fail:
```
2026-04-08 20:32:21,403 INFO mapreduce.Job: Task Id : attempt_1775672934348_0005_m_000000_0, Status : FAILED
Error: java.io.IOException: Type mismatch in value from map: expected org.apache.hadoop.io.Writable, received org.apache.hadoop.io.BytesWritable
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:1104)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:728)
at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112)
at org.apache.nutch.parse.ParseSegment$ParseSegmentMapper.cleanup(ParseSegment.java:108)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:148)
```
The solution is to wrap the ParseImpl or the BytesWritable into a NutchWritable object.
I've already implemented the fix. Will push it later, but continue testing now.
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -155,6 +159,25 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
LOG.error(StringUtils.stringifyException(e));
throw e;
}
+ Path latencyDir = new Path(tmp, "_latency");
+ FileSystem fs = tmp.getFileSystem(conf);
+ if (fs.exists(latencyDir)) {
+ try (Job mergeJob = IndexerMapReduce.createLatencyMergeJob(conf, latencyDir)) {
+ FileOutputFormat.setOutputPath(mergeJob, new Path(tmp, "_latency_merge_out"));
+ boolean mergeSuccess = mergeJob.waitForCompletion(true);
Review Comment:
Or when running on a single-node cluster (indexing to Solr):
```
2026-04-08 21:50:01,953 ERROR indexer.IndexingJob: Indexer: org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://localhost:9000/user/wastl/tmp_1775677717095--1619189953/_latency
```
This only affects the latency-merge job.
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -155,6 +159,25 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
LOG.error(StringUtils.stringifyException(e));
throw e;
}
+ Path latencyDir = new Path(tmp, "_latency");
+ FileSystem fs = tmp.getFileSystem(conf);
+ if (fs.exists(latencyDir)) {
+ try (Job mergeJob = IndexerMapReduce.createLatencyMergeJob(conf, latencyDir)) {
+ FileOutputFormat.setOutputPath(mergeJob, new Path(tmp, "_latency_merge_out"));
+ boolean mergeSuccess = mergeJob.waitForCompletion(true);
Review Comment:
```
2026-04-08 21:38:08,406 ERROR o.a.n.i.IndexingJob [main] Indexer: org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/mnt/data/wastl/proj/crawler/nutch/test/tmp_1775677086987-2006747810/_latency
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:342)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:281)
at org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat.listStatus(SequenceFileInputFormat.java:59)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:445)
at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:311)
at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:328)
at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:201)
at org.apache.hadoop.mapreduce.Job$11.run(Job.java:1677)
at org.apache.hadoop.mapreduce.Job$11.run(Job.java:1674)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.base/javax.security.auth.Subject.doAs(Subject.java:439)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1953)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1674)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1695)
at org.apache.nutch.indexer.IndexingJob.index(IndexingJob.java:167)
at org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:320)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82)
at org.apache.nutch.indexer.IndexingJob.main(IndexingJob.java:329)
```
when running
````
bin/nutch index -Dplugin.includes='indexer-dummy|index-(basic|more)' -nocrawldb /path/to/segments/20260408205641/
```
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-4041243446
## [](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) **Quality Gate failed**
Failed conditions
 [43.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_nutch&pullRequest=906&metric=new_coverage&view=list) (required ≥ 80%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906)
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-5040974800
## [](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906) **Quality Gate failed**
Failed conditions
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_nutch&pullRequest=906&metric=new_coverage&view=list) (required ≥ 80%)
<!-- sqra:qg_revision=bed0fbc4e9a02d41a52519e3cb0ae76523a1c17d90ea18ba0492cd401c6b1f38 -->
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_nutch&pullRequest=906)
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Fetcher and Parser latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc merged PR #906:
URL: https://github.com/apache/nutch/pull/906
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on code in PR #906:
URL: https://github.com/apache/nutch/pull/906#discussion_r3067764239
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -155,6 +159,25 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
LOG.error(StringUtils.stringifyException(e));
throw e;
}
+ Path latencyDir = new Path(tmp, "_latency");
+ FileSystem fs = tmp.getFileSystem(conf);
+ if (fs.exists(latencyDir)) {
+ try (Job mergeJob = IndexerMapReduce.createLatencyMergeJob(conf, latencyDir)) {
+ FileOutputFormat.setOutputPath(mergeJob, new Path(tmp, "_latency_merge_out"));
+ boolean mergeSuccess = mergeJob.waitForCompletion(true);
Review Comment:
Yes, I wondered about this. I am not a huge fan of the intermediate output being written for IndexerJob either. I think we could even remove the changes for this job and address them separately. This will NOT have an impact on the Job execution... however the counters are not accurate.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-4041256578
Refactored tests and introduced `LatencyTestUtil.java` to centralize boilerplate for latency-generating test code.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "sebastian-nagel (via GitHub)" <gi...@apache.org>.
sebastian-nagel commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-5032579717
Hi @lewismc, any chance that you could split the changes in the indexer from this PR? If not, let me know and I'll take over. Would be nice to get this in before the release of Nutch 1.23.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on code in PR #906:
URL: https://github.com/apache/nutch/pull/906#discussion_r2920120575
##########
src/java/org/apache/nutch/indexer/IndexingJob.java:
##########
@@ -143,6 +145,8 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
+ RANDOM.nextInt());
FileOutputFormat.setOutputPath(job, tmp);
+ // Driver-level error tracking: categorization + LOG.error only (no job counters; see ErrorTracker Javadoc).
Review Comment:
I've put this comment in here for the time. Ultimately I think it is fine to track driver-level errors in memory even though they are not written to the MapReduce counter(s).
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NUTCH-3162 Latency metrics to properly merge data from all threads and tasks [nutch]
Posted by "lewismc (via GitHub)" <gi...@apache.org>.
lewismc commented on PR #906:
URL: https://github.com/apache/nutch/pull/906#issuecomment-4228963368
The temp Indexer output isn't ideal. Thank you for reviewing. This "Indexer Latency Merge" is one solution. I will follow up with alternative(s) soon.
Additionally, even documentation the metrics evolution is something I need to get around to. As of right now I added a notice to the [wiki metrics documentation](https://cwiki.apache.org/confluence/display/NUTCH/Metrics) to state it is superseded.
The best current documentation is our Javadoc
* [NutchMetrics](https://ci-builds.apache.org/job/Nutch/job/Nutch-trunk/javadoc/org/apache/nutch/metrics/NutchMetrics.html)
* [ErrorTracker](https://ci-builds.apache.org/job/Nutch/job/Nutch-trunk/javadoc/org/apache/nutch/metrics/ErrorTracker.html)
* [LatencyTracker](https://ci-builds.apache.org/job/Nutch/job/Nutch-trunk/javadoc/org/apache/nutch/metrics/LatencyTracker.html)
I think we can do better than Javadoc and I am thinking about how we package better documentation.
--
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: dev-unsubscribe@nutch.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org