rammmaa opened a new pull request, #60518:
URL: https://github.com/apache/spark/pull/60518

   ### What changes were proposed in this pull request?
   
   `EventLogFileReader.openEventLog` now opens event logs with 
`FileSystem.openFile()` and sets `fs.option.openfile.read.policy` to 
`sequential`, instead of calling `FileSystem.open()`. The buffering and 
compression codec handling after that are unchanged.
   
   `openEventLog` is used by `FsHistoryProvider` (listing and replay), 
`EventLogFileCompactor` and `EventFilter`, so all of them get the new read 
policy.
   
   The SPARK-24948 test in `FsHistoryProviderSuite` mocked `FileSystem.open()` 
to throw `AccessControlException`. It now mocks `FileSystem.openFile()`, which 
is what `openEventLog` calls.
   
   ### Why are the changes needed?
   
   Event logs are always read from start to end, but `FileSystem.open()` does 
not tell the filesystem about that.
   
   Since HADOOP-19559 (Hadoop 3.4.3 and 3.5.0), the default S3A input stream is 
the analytics stream. It keeps per-object state for the lifetime of the 
filesystem, and only removes an object's state when the stream is closed if the 
stream was opened with a sequential read policy (HADOOP-20058). A History 
Server that reads event logs from S3 keeps one cached `FileSystem` for its 
whole life, so its heap grows with every event log it reads until it runs out 
of memory.
   
   I measured this locally against an S3-compatible server (moto), reading 
4,000 small event logs with hadoop-aws 3.5.0 and the default stream type, and 
forcing GC after 2,000 and 4,000 logs:
   
   | How the log is opened | Live heap after 2,000 | Live heap after 4,000 | 
Growth per log | Retained `MeanStatistic` |
   |---|---|---|---|---|
   | `FileSystem.open()` | 135 MB | 201 MB | about 34 KB | 144,100 |
   | `openFile()` with the sequential policy | 77 MB | 77 MB | none | 100 |
   
   `HadoopLineRecordReader` already opens files with `openFile()` 
(SPARK-52482), so this follows an existing pattern in Spark.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Filesystems that do not use the read policy ignore it.
   
   ### How was this patch tested?
   
   - Existing tests: `RollingEventLogFilesWriterSuite`, 
`RollingEventLogFilesReaderSuite`, `SingleFileEventLogFileReaderSuite`, 
`SingleEventLogFileWriterSuite`, `EventLogFileCompactorSuite`, 
`RocksDBBackendFsHistoryProviderSuite`, `LevelDBBackendFsHistoryProviderSuite` 
and `RocksDBBackendHistoryServerSuite` pass locally.
   - The heap measurement above used a small program that makes the same Hadoop 
calls as `openEventLog`, not a full History Server build.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to