Refactor Run modules to use modern record extensions#830
Refactor Run modules to use modern record extensions#830mwihoti wants to merge 4 commits intoIntersectMBO:mainfrom
Conversation
|
Hi @jorisdral , I just pushed an update for Run module with the new record language extensions, I'm moving next to Index |
There was a problem hiding this comment.
Thank you very much for the contribution, I like the new field names for the Run and RunReader module 😄.
Two high-level comments:
- In modules where we refactor field names (
Run/RunReader), we should enableDuplicateRecordFields,NoFieldSelectors, andOverloadedRecordDot. In other modules where we only want to use the.fieldsyntax, it should be fine to only enableOverloadedRecordDot, so let's change that so that we only use the.fieldsyntax on values of typeRunandRunReader. That probably makes the diff of this PR also smaller - There are some residual parentheses here and there. In particular, we don't need parentheses around syntax like
value.field
| Run (Run, index, hasFS, hasBlockIO, dataCaching, | ||
| blobFile, bloomFilter, kOpsFile, fsPaths, numEntries, refCounter) |
There was a problem hiding this comment.
| Run (Run, index, hasFS, hasBlockIO, dataCaching, | |
| blobFile, bloomFilter, kOpsFile, fsPaths, numEntries, refCounter) | |
| Run (Run, index, hasFS, hasBlockIO, dataCaching, | |
| blobFile, bloomFilter, kOpsFile) |
There was a problem hiding this comment.
The fsPaths, numEntries, and refCounter fields are not exported on purpose. We should keep them internal
| rnf r = | ||
| rnf r.numEntries `seq` rwhnf r.refCounter `seq` rnf r.fsPaths `seq` | ||
| rnf r.bloomFilter `seq` rnf r.index `seq` rnf r.kOpsFile `seq` | ||
| rnf r.blobFile `seq` rnf r.dataCaching `seq` rwhnf r.hasFS `seq` rwhnf r.hasBlockIO | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
This was written like this before:
rnf (Run a b c d e f g h i j) = ...I think the previous definition was better, because the explicit pattern match will result in compiler errors if we forget to use one of the fields (and forgetting to use one of the fields is bad for performance tests)
|
|
||
| sizeInPages :: Ref (Run m h) -> NumPages | ||
| sizeInPages (DeRef run) = Index.sizeInPages (runIndex run) | ||
| sizeInPages (DeRef run) = Index.sizeInPages (run.index) |
There was a problem hiding this comment.
There a number of cases like this where there are residual parentheses even though they are not necessary anymore:
| sizeInPages (DeRef run) = Index.sizeInPages (run.index) | |
| sizeInPages (DeRef run) = Index.sizeInPages run.index |
Let's make sure that we remove obsolete parentheses in the rest of PR as well
| (\refCounter -> Run { | ||
| numEntries = runNumEntries | ||
| , refCounter = refCounter | ||
| , fsPaths = runRunFsPaths | ||
| , bloomFilter = runFilter | ||
| , index = runIndex | ||
| , kOpsFile = runKOpsFile | ||
| , blobFile = runBlobFile | ||
| , dataCaching = runRunDataCaching | ||
| , hasFS = runHasFS | ||
| , hasBlockIO = runHasBlockIO | ||
| }) |
There was a problem hiding this comment.
| (\refCounter -> Run { | |
| numEntries = runNumEntries | |
| , refCounter = refCounter | |
| , fsPaths = runRunFsPaths | |
| , bloomFilter = runFilter | |
| , index = runIndex | |
| , kOpsFile = runKOpsFile | |
| , blobFile = runBlobFile | |
| , dataCaching = runRunDataCaching | |
| , hasFS = runHasFS | |
| , hasBlockIO = runHasBlockIO | |
| }) | |
| (\refCounter -> Run { | |
| numEntries = runNumEntries | |
| , refCounter = refCounter | |
| , fsPaths = runRunFsPaths | |
| , bloomFilter = runFilter | |
| , index = runIndex | |
| , kOpsFile = runKOpsFile | |
| , blobFile = runBlobFile | |
| , dataCaching = runRunDataCaching | |
| , hasFS = runHasFS | |
| , hasBlockIO = runHasBlockIO | |
| }) |
| , dataCaching = runRunDataCaching | ||
| , hasFS = fs | ||
| , hasBlockIO = hbio | ||
|
|
| {-# LANGUAGE DuplicateRecordFields #-} | ||
| {-# LANGUAGE NoFieldSelectors #-} | ||
| {-# LANGUAGE OverloadedRecordDot #-} |
There was a problem hiding this comment.
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE NoFieldSelectors #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} |
| {-# LANGUAGE CPP #-} | ||
| {-# LANGUAGE DuplicateRecordFields #-} | ||
| {-# LANGUAGE MagicHash #-} | ||
| {-# LANGUAGE NoFieldSelectors #-} | ||
| {-# LANGUAGE OverloadedRecordDot #-} | ||
| {-# LANGUAGE UnboxedTuples #-} |
There was a problem hiding this comment.
| {-# LANGUAGE CPP #-} | |
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE MagicHash #-} | |
| {-# LANGUAGE NoFieldSelectors #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} | |
| {-# LANGUAGE UnboxedTuples #-} | |
| {-# LANGUAGE CPP #-} | |
| {-# LANGUAGE MagicHash #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} | |
| {-# LANGUAGE UnboxedTuples #-} |
| {-# LANGUAGE DuplicateRecordFields #-} | ||
| {-# LANGUAGE NoFieldSelectors #-} | ||
| {-# LANGUAGE OverloadedRecordDot #-} |
There was a problem hiding this comment.
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE NoFieldSelectors #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} |
| {-# LANGUAGE DuplicateRecordFields #-} | ||
| {-# LANGUAGE NoFieldSelectors #-} | ||
| {-# LANGUAGE OverloadedRecordDot #-} |
There was a problem hiding this comment.
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE NoFieldSelectors #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} |
| {-# LANGUAGE DuplicateRecordFields #-} | ||
| {-# LANGUAGE NoFieldSelectors #-} | ||
| {-# LANGUAGE OverloadedRecordDot #-} |
There was a problem hiding this comment.
| {-# LANGUAGE DuplicateRecordFields #-} | |
| {-# LANGUAGE NoFieldSelectors #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} | |
| {-# LANGUAGE OverloadedRecordDot #-} |
|
Thanks, I will work on the changes |
extension scope
- Remove unnecessary parentheses around dot-access expressions (value.field)
- Only enable DuplicateRecordFields/NoFieldSelectors in Run and RunReader
where field names were actually refactored; other modules get
OverloadedRecordDot only
343017b to
5823d35
Compare
Snapshot.hs: use exported runFsPaths accessor instead of internal r.fsPaths
Unsafe.hs: restore parens around function applications
Config/Override.hs: fix corrupted override instance for MergeBatchSize
Benchmarks: update to dot syntax with renamed fields (bloomFilter, index,
kOpsFile) and add OverloadedRecordDot pragma to both benchmark files
|
Hi @jorisdral I've updated changes based on the feedback |

Description
Following the successful pilot with Internal.Arena, this PR refactors the Run module and several related components to use the modern record language extensions.
changes
cabal build lsm-tree:lib:core -- Builds successfully
cabal test lsm-tree-test --pattern "Run" -- 129/129 tests pass
cabal test all -- Verified for compilation and linking
link
to the issue.
Checklist