Auto merge of #101313 - SparrowLii:mk_attr_id, r=cjgillot
make `mk_attr_id` part of `ParseSess` Updates #48685 The current `mk_attr_id` uses the `AtomicU32` type, which is not very efficient and adds a lot of lock contention in a parallel environment. This PR refers to the task list in #48685, uses `mk_attr_id` as a method of the `AttrIdGenerator` struct, and adds a new field `attr_id_generator` to `ParseSess`. `AttrIdGenerator` uses the `WorkerLocal`, which has two advantages: 1. `Cell` is more efficient than `AtomicU32`, and does not increase any lock contention. 2. We put the index of the work thread in the first few bits of the generated `AttrId`, so that the `AttrId` generated in different threads can be easily guaranteed to be unique. cc `@cjgillot`
This commit is contained in:
@@ -1552,7 +1552,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let uc_nested = attr::mk_nested_word_item(uc_ident);
|
||||
attr::mk_list_item(allow_ident, vec![uc_nested])
|
||||
};
|
||||
attr::mk_attr_outer(allow)
|
||||
attr::mk_attr_outer(&self.tcx.sess.parse_sess.attr_id_generator, allow)
|
||||
};
|
||||
let attrs: AttrVec = thin_vec![attr];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user