Comments (6)
Switch to using an hvec_map
instead? It has the same property of preserving the insertion order while allowing fast lookups (hash based), just needs a hash function.
from p4c.
Switch to using an
hvec_map
instead? It has the same property of preserving the insertion order while allowing fast lookups (hash based), just needs a hash function.
I am currently experimenting with different solutions, yes.
from p4c.
Another thing is that ordered_map
is often used in places which don't actually need it (e.g. which don't do key-based lookup and don't rely of ordered_map
to ensure deterministic iteration order). However, getting rid of it is a bit tricky as it risks easily introducing nondeterminism into the compiler later, if some iteration is added. One solution (although it has its downsides too) is to use non-iterable wrappers over (some) map/set types for these places so that attempt to iterate over them causes compiler error when building P4C. I had non-iterable wrappers over maps and sets in the Tofino P4C compiler, but they are lost there as I did not get to upstream them before leaving the team.
Having a higher-performing replacement would definitely help though.
from p4c.
However, getting rid of it is a bit tricky as it risks easily introducing nondeterminism into the compiler later, if some iteration is added.
Yeah. Another way (adopted by abseil, btw, if hash is not provided) is to randomize hashes, so the iteration order would be different in each invocation even on the same machine / same conditions. So, these issues would be exposed earlier. This is a bit aggressive though :)
from p4c.
However, getting rid of it is a bit tricky as it risks easily introducing nondeterminism into the compiler later, if some iteration is added.
Yeah. Another way (adopted by abseil, btw, if hash is not provided) is to randomize hashes, so the iteration order would be different in each invocation even on the same machine / same conditions. So, these issues would be exposed earlier. This is a bit aggressive though :)
The problem is, in my experience, that it is quite hard to find the nondeterminism by a test suite unless it specifically tests deterministic outputs. If all results are valid (which they absolutely should) and differ just in things like where something is allocated or how much resources are used, this can go unnoticed for a long time. Even when it is noticed, finding the culprit is very hard.
from p4c.
The problem is, in my experience, that it is quite hard to find the nondeterminism by a test suite unless it specifically tests deterministic outputs. If all results are valid (which they absolutely should) and differ just in things like where something is allocated or how much resources are used, this can go unnoticed for a long time. Even when it is noticed, finding the culprit is very hard.
Yes, I fully agree. Still it is a bit non-trivial to allow iterators and forbid iteration. But, anyway, care should be taken and it is review process designed to have spare pair of eyes to check for this.
from p4c.
Related Issues (20)
- `ComputeWriteSet` does not properly maintain the calling context HOT 1
- Error message for missing declaration in for loops is confusing.
- Reduce type checking overhead HOT 5
- Variant error while compiling
- Seeing test failures for several p4c test programs including test err/testdata/p4_16_errors/constructor3_e.p4 HOT 3
- Broken links on P4C docs page on P4Smith HOT 4
- Consider a CI/CD test run for DEBUG p4c build, instead of RELEASE HOT 4
- SourceInfo initializiation is inconsistent. HOT 2
- Compiler Bug: `Could not find type of <Type_Header> ...` on specialized generic struct type HOT 7
- How often we sync p4's pna.p4 with pna repo ? HOT 3
- Can't find `gc_mark.h` during build HOT 4
- Strange `IHasSourceInfo` interface
- Port Katran C application to P4. HOT 4
- bng.p4 is too large to be loaded into the kernel HOT 3
- Elevated memory usage in def-use HOT 2
- If the PSA frame NTK path set to true,the ARP packet will be sent as ipv4 . HOT 3
- Unexpected "Duplicates declaration" error when P4 program contains no duplicate declarations HOT 7
- `MoveInitializers` splits `start` state for parsers that do not need this
- Add mechanism for easily adding tests for command-line options HOT 1
- Error trying to compile 2024-sep-14 p4c source on Ubuntu Linux HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p4c.