[PATCH] D125979: [ADT] add ConcurrentHashTable class.
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 31 18:50:07 PDT 2022
MaskRay added inline comments.
================
Comment at: llvm/include/llvm/ADT/ConcurrentHashTable.h:117-118
+ else if (CurSlabNum > MaxNumberOfSlabs)
+ reportWarning("Too many slabs. Consider increasing initial size or "
+ "changing hash function.");
+
----------------
avl wrote:
> dblaikie wrote:
> > avl wrote:
> > > dblaikie wrote:
> > > > It's pretty weird to have warnings coming out of data structures. @MaskRay would it be reasonable to remove these/replace them with some other tool if we're promoting this to a more general purpose data structure rather than something more special-case in lld?
> > > Probably, instead of warning we can introduce method:
> > >
> > > ```
> > > bool IsInGoodState () const {
> > > return CurSlabNum <= MaxNumberOfSlabs && !hasFullSlab;
> > > }
> > >
> > >
> > > ```
> > >
> > > the consumer could call this method somewhere and inform the user:
> > >
> > > ```
> > > if (!HashTable.IsInGoodState()) {
> > > outs() << "Hash table is in suboptimal state";
> > > }
> > > ```
> > >
> > > ?
> > Maybe? I'd be curious to hear from @MaskRay here, since I guess he wrote the original/had the original motivation for the warning.
> that is me, who introduced the warning. Original lld implementation does not have it.
>
> My motivation is that it should be known somehow that hashtable is not in good state and it is necessary to revise initial size.
The root issue is that the patch does not implement proper grow/resize, so setting a capacity and having oversize warnings here look like hacks. For many general-purpose usages it's difficult to estimate the size beforehand, or without heavily refactoring the usage pattern. So I wish that we implement a proper resizable hashtable with amortized O(1) time complexity, not the current version which will be slow if the actual size is much more larger than the reserved capacity.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125979/new/
https://reviews.llvm.org/D125979
More information about the llvm-commits
mailing list